pty 882 Posting Pro

Should I turn those into an extra column or should they become seperate tables?

They should definitely be stored in a separate table (say, food_category) and you should add an appropriately-named foreign key to the table you posted (let's called that food).

In SQL, you'd use a statement like this to create the tables with the foreign-key relationship in place, note the references line:

create table food_category (
        id     serial primary key,
        name   varchar(32) not null unique
);

create table food (
        id          serial primary key,
        category_id int references food_category(id) not null,
        name        varchar(32) not null unique,
        calories    numeric,
        cholesterol numeric,
        sugar       numeric
);
pty 882 Posting Pro

On another note, this is where the StackOverflow 'style' of questions and answers, with plenty of non-nonsense moderators, works well.

Homework questions like this are good for nothing. If the student can't be bothered to formulate a sensible question they are weakening whatever community is left and making it more difficult for any potential non-chump users to find something worth reading.

If someone has made an effort and posted some code that's stripped down to the essentials and well-formatted, I'm more than happy to go out of my way to help. When it's a case of

NEED STUDENT ATTENDANCE SYSTEM PLS HALP

Yeah.. no.

As someone of Indian descent, it's pretty embarrassingly focussed, too.

pty 882 Posting Pro
Grade F: rahul_63
pty 882 Posting Pro

For every image you want to store a separate watermarked version of that image. So, you need a 'task' that runs per upload. For your already-uploaded images you need to also be able to run that task.

In Rails, let's say you have a class called Image with method generate_watermark

class < ActiveRecord::Base

  after_save :generate_watermark, if: :image_changed?

  def generate_watermark
    ...
  end

end

So, this method is called every time the image is changed. Easy. Now, for your backlog you need to call this method for every Image that has no watermark. Fire up a Rails console:

Image
  .where(watermark: :nil)
  .each(&:generate_watermark)

Easy, huh? You'd use the same approach in Laravel.

pty 882 Posting Pro

Back in 2012, I once built a .exe bot that finds you WP blogs that still have their commenting section open and then posts your comment.

Well done, your posting bot has obviously evolved to posting to forums and ever since you added the Rambling::Bullshit module and pointed it at daniweb.com it's gone from strength to strength. Keep up the good work, with all your amazing ideas you're clearly destined for the top.

pty 882 Posting Pro

You can't create a table if a something with the same name already exists. If you have created it in error and it doesn't contain any important data, drop it.

drop table PO;

Now your create table PO ... command should work.

pty 882 Posting Pro

Nope, FINDSTR only returns whole matching lines. You're best creating something in Powershell to return only what you want.

pty 882 Posting Pro

Another advantage of Python (and other interpreted languages) is that you can learn the syntax much more quickly and easily while using a REPL. For those who don't know, you can just type in code and it evaluates it and prints the result:

>>> colours = ["red", "yellow", "pink", "green"]
>>> for colour in colours:
...     print(colour)
...
red
yellow
pink
green

If you make a mistake, you'll see it as soon as you hit enter.

>>> for colour in colours:
...     print(uh_oh)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
NameError: name 'uh_oh' is not defined

For people learning to code, this is way more intuitative and less frustrating than the way I learned many years ago; the feedback loop is much tighter and there isn't much that can go wrong inside a REPL, you don't have to take the extra steps of learning to use a compiler and a shell, troubleshoot non-executable files and permissions and other things that we don't think twice about but trip up newbs.

pty 882 Posting Pro

Python is a solid first choice, it's really easy to get up and running, it's very sensibly designed and has plenty of libraries to choose from when you start doing more advanced things.

pty 882 Posting Pro

To cut a long story short, you don't want to connect to the database directly, you want to build an API that sits in-between. Let the API service talk to the database and communicate with the API via HTTP calls or some other protocol.

pty 882 Posting Pro

The problem looks like it's the quote symbol on your require line, require ‘watir’.

In Ruby, this needs to be either a standard ' or " pairing. If you really want to you can use percent string syntax, in therequire %q{watir} style, but in more than 14 years of Ruby I have never seen that syntax used in a require statement.

In short, you'll have more luck with require 'watir'.

pty 882 Posting Pro

I'd start by getting someone who speaks native English to proof-read your text. I'd also drop the name Microsoft from your company name, it's likely to make potential customers think you're a scam outfit. Get rid of the obviously fake customer reviews and dodgy stock photos.

Think about what you are actually trying to provide and make that clear on your site. Summarise it in 3 sentences and throw away everything else.

Getting backlinks by posting useless questions in other support forums and having the URL in your sig isn't going to do you any good in the long run, I'd nip that in the bud.

pty 882 Posting Pro

Using tables for borders like that is no longer required, it's very brittle (as you've found out) and unnecessarily fiddly.

Drop shadows can be implemented with a single line of CSS:

.card.login-form {
  margin-top: 8rem;
  box-shadow: 6px 6px 66px 6px rgba(0,0,0,0.39);
}

Here's how your login form would look using a modern CSS framework (Bootstrap, here). Code is here. Screenshot below:

Screen_Shot_2017-06-21_at_11_46_10.png

pty 882 Posting Pro

I don't envy the task ahead of you Dani. There just isn't the enthusiasm there once was.

Tech support has largely been supplanted by stackoverflow, the social/discussion aspect by Reddit, Facebook, etc.

Maybe putting DW on ice and concentrating on Dazah making inroads into its intended market is best. The idea sounds like it could work and things that grease the wheels of commerce tend to, but without a solid example of a market where it's actually connecting people I think it's going to be an uphill struggle.

I get the impression (and would bet you agree) that the current users of Daniweb, the fifteen or twenty regular posters and the people needing homework help aren't the cohort you need to be targetting.

diafol commented: Clear thinking +0
pty 882 Posting Pro

You could always switch to a language where indexing starts at 1. FORTRAN, Lua, Pascal and Smalltalk to name a few.

rproffitt commented: Oh Pascal, where I spent too much time. +12
pty 882 Posting Pro

What's APACHE_RUN_DIR set to? It will be defined elsewhere in your config

pty 882 Posting Pro

So you're building an OS and an IDE but the contents of a project file are confusing?

Just do yourself a favour and use something built by experts until you see a shortfall that you'd like to address.

Note, I'm not saying don't build an OS, an IDE or a language, but don't try to do all three at once unless you are Fabrice Bellard.

ddanbe commented: Nice! +15
rproffitt commented: That's Fab! +12
pty 882 Posting Pro

Or, add a fulltext index to your table (across all the columns you care about) and use match (cols...) against syntax.

seularts commented: This did the trick. The stupid script that generated the table with its content is not all that retarded because it had added fulltext indexes! +3
diafol commented: Good +15
pty 882 Posting Pro

Just find the ban hammer.

pty 882 Posting Pro

I think Social Bookmarking services are a niche trend at best. They were very popular in the early-mid 2000's but the need for them was erroded from multiple angles.

Chrome came along with its excellent browser syncing, which in turn forced Firefox to up its game and follow suit. This negated the 'access my bookmarks from anywhere' angle, as once you're signed into your browser, you have full access to not only your bookmarks but also your logins, passwords, sesssions etc.

Secondly, sites like Digg, Reddit and even Pinterest filled the 'sharing cool stuff' niche.

Here's the trend for Delicious over the last 13 or so years.

Screen_Shot_2017-05-17_at_11_40_06.png

Screen_Shot_2017-05-17_at_11_49_21.png

pty 882 Posting Pro

Don't worry, my program does this. Thank you for your concern.

pty 882 Posting Pro
pty 882 Posting Pro

Here's how I'd do it (and have done it for years). It's the canonical, accepted answer for Linux too.

The SSH program has support for 'shortcuts' built in, you simply need to add the hostnames (or aliases) in your ~/.ssh/config file.

So, in my config file, if I have the following entry:

# Github
host github
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_work

Then, on the command line I simply type ssh git and hit tab a couple of times, and all of the entries that start with git automatically appear for selection/autocompletion:

Screen_Shot_2017-05-06_at_11_53_14.png

Note that in the config file I'm specifying which private key (IdentityFile) to use for that host, SSH will use this whenever connecting to this specified host. Previous commenters have already gone through how to set up key pairs; this is definitely the best and most secure way of connecting to remote machines. Ideally you should turn off password based login and rely entirely on a key pair.

If you really want desktop shortcusts, just create a bash script (and make sure it's executable) with the .command suffix. However, with nice tab completion on the command line it's quicker and easier (imho) to just use the built-in command.

Edit: here are Digital Ocean's instructions for setting up SSH keys. They are very thorough and generic enough to use anywhere.

cereal commented: +1 +14
pty 882 Posting Pro

There are plenty of esoteric programming languages, some of which have been around for a long time.

I'm not sure actually teaching students syntax is too important, but demonstrating that there are many languages each with their own strengths and weaknesses is. Readability and succinctness are definitely advantages.

Dani commented: Great link that explains what I was trying to say perfectly = +16
pty 882 Posting Pro

You can't have it because immediately after assigning it you're overwriting the value.

I believe you can fix it by turning your computer upside down so the first line runs after the second. Hope this helps.

rubberman commented: pty, you are evil! :-) +14
pty 882 Posting Pro

Has anyone tried Mastodon yet? For those who don't know it's a federated, distributed and (currently) technology-orientated social network (well, rather a group of interoperable social networks) that's fully open source and ad-free. I've been impressed so far but as with every new network, whether it flies or not will depend on how many people join, contribute and keep the ball rolling.

pty 882 Posting Pro

You're calling worldmapA() but your function is called worldMapA().

Chrome dev tools will help you in situations like this.

Screenshot_from_2017-04-14_13-18-12.png

pty 882 Posting Pro

Plus, the CSS is totally different between the first and second fiddles. Posting examples with minimised code is a bad idea, it's clearly broken because while it looks like Bootstrap 2 the fonts aren't applied in the preview window. Total failure.

pty 882 Posting Pro

Did you actually read the source? Assuming you want to replace the icon-cog:

<div class="icon-cog box-icon"></div>

Replace the contents of the div with an img tag:

<div class="box-icon">
    <img width="60" height="60" src="http://i.imgur.com/vPkeDtI.png"/>
</div>

Results in beautiful images whever you like.

Screen_Shot_2017-03-25_at_14_38_25.png

rproffitt commented: Good example. +12
newbi11 commented: Thanks a lot +2
pty 882 Posting Pro

If you plan on writing in English, I'd master it first.

Yes, I know you're actually linking to that site for SEO purposes. Kind of lame at the best of times.

pty 882 Posting Pro

A graph database alone isn't the right choice for a chat application. A message would be represented as an edge between two nodes (people) and too many edges will hurt performance.

Storing the actual social network portion of a chat app in one makes a lot of sense, though. It's the perfect use case for a graph database.

Something like OrientDB might make more sense. There's even a chat program in the use cases section of the documentation.

pty 882 Posting Pro
pty 882 Posting Pro
pty 882 Posting Pro

I've been following this with some interest. Bad practice to end with a verb?

I think the distinction is between an API and a web app. In a web app, /widgets/123/edit (obtained via a GET) should contain a form that allows you to edit Widget number 123. Submitting the form should send aPATCH to /widgets/123.

In the case of an API, you don't need an edit form so you can omit verbs from the route entirely.

pty 882 Posting Pro

Of course it's possible, but just do everyone (yourself included) a favour and use an existing client. What advantage is there of having your own? Written by a non-expert, without having thousands (or millions, billions) of hours of hands-on testing, your client is likely to be pretty poor.

diafol commented: Most definitely +15
pty 882 Posting Pro

While yes, I'm annoyed by spammers, the notification problem exists for legitimate posts too. It just so happens that this chap was top of the list!

rproffitt commented: I think we look the other way since our hero has been busy busy. +0
pty 882 Posting Pro

It would appear that too many notifications are added to the feed for certain events, making it difficult to sort the wheat from the chaff.

Take the example of this annoying spammer creating a post:

Screen_Shot_2017-01-26_at_15_16_46.png

Aside from the fact he's a waste of oxygen, that's more than one whole screen of notifications for a post creation and quick edit (less than a minute after posting). Also, I don't see any replies, so perhaps the "replied to a post" notification is superflouous. Perhaps these could be condensed; do we need to know who started watching each post - it might make more sense to display that on the post page; "being watched by..."

rproffitt commented: That and now I want a Black Mirror "Block" mode. +0
pty 882 Posting Pro

D3 isn't the correct choice for in this situation; it's aimed at visualisation (as per the request in the original post). If you want to interact with scales by dropping different-weighted balls on them in anything but the simplest of interfaces, you need a physics engine. Matter-JS provides this and makes it really simple to get fantastic results.

gentlemedia commented: Wow! matter.js is cool :) +6
pty 882 Posting Pro

So basically, you probably want to store the time that you serve the question to them and the time at which they submit an answer. You can determine how long it took them to answer by subtracting the former from the latter.

pty 882 Posting Pro

In Chrome, open the dev tools and click "Toggle Device Toolbar". In the toolbar's dropdown, you'll see entries for common devices (Nexus 5X, Nexus 6P, iPhone 5, iPhone 6, iPad and iPad Pro).

pty 882 Posting Pro

For Unix-like system users, there are quite a few options here. Classically, find (super super powerful but doesn't use any index) and locate (uses an index but has fewer options for searching).

However, 99% of the time I know roughly where the file is; it's usually in the project I'm working on. FZF. Here it is in action

pty 882 Posting Pro

That's definitely possible in d3, but d3 is more for visualisation than interactive 'physics' stuff, which sounds like what you're after.

Perhaps something like matter-js would be more suitable.

diafol commented: d3 +15
pty 882 Posting Pro

Regarding PUT and PATCH, I looked and looked, and was unable to find a working tutorial on how to implement them in Nginx. Everything I read said that Nginx does not have support??

NGINX definitely supports them, as far as I know you don't need to enable anything. It should just work.

I just wrote (well, copied, pasted and amended) a tiny app in PHP (the first time I've ever tried PHP!) and it handled PUT like a boss.

pty 882 Posting Pro

I'm not sure exactly what you'll be visualising, so it's difficult to suggest anything, but I'm sure that d3 will have you covered. It's immensely powerful and incredibly well-designed.

pty 882 Posting Pro

I use snippets heavily. For non-work stuff, Github's gists are perfect. You can add multiple files to a single gist (which would help if some of the code you're pasting is spread across a model, controller and view), and everything's syntax highlighted.

Github allows gists to be embedded. Perhaps this would be a better approach than creating one from scratch. To build anything with that kind of functionality that people will actually want to use is a project in itself.

pty 882 Posting Pro
   select * from company where has_made_profit_every_year_for_the_last_five_years = 1;

Hope this helps.

rproffitt commented: I understand this line of thinking. +11
pty 882 Posting Pro

I'm no PHP expert, so forgive my ignorance.

If you test in a basic manner, rather than by using AJAX, what happens? By using your browser's inspector, you can see that doing:

$.ajax({
  url: "my_service",
  data: {f_date1: "yesterday", t_date1: "today"},
  success: function(msg) {
    console.debug("yay")
  }
});

will result in a GET request like this:

my_service?f_date1=yesterday&t_date1=today

If you paste that into a browser's URL bar (or better yet use something like HTTPie or Postman), you can make sure that you can access the query string properly. Once you know that works, and you know that jQuery's .ajax method does the same thing, you'll have a much better chance at solving your problem.

pty 882 Posting Pro

@hinaraees I'll show you what you need to know. Just send me your Facebook login and password and I'll send you everything you need!

rproffitt commented: Better yet, just post it here so all of us can contribute. +11
pty 882 Posting Pro

What probably happened is that your customer created an order, then while the above code was running they created another. As you're using max to work out which number to allocate and you've not yet saved the first record, both have the same id. Without knowing your transaction isolation level I can't say why your sequence looked correct.

Rule of thumb, for automatically generating numbers, use a sequence (known as auto increment in MySQL). Also, if your ids are meant to be unique, consider making that column a primary key; if not use a unique index.

pty 882 Posting Pro

It sounds like you aren't working to the strengths of the database. MySQL, unlike Oracle, PostgreSQL etc doesn't support arrays, and searching on text is unlikely to be optimal.

I don't know the context of the original query, so it's difficult to suggest a solution, but it could be something like this:

 Tags:
 - id: 1
   name: Programming
 - id: 2
   name: Databases
 - id: 3
   name: Web Development
 - id: 4
   name: Floristry
 - id: 5
   name: Kids TV

 Posts:
 - id: 1
   name: Making pages faster
   tags: [1, 2, 3]
 - id: 2
   name: CBeebies top ten
   tags: [5]

So, to find all posts about Web Development you'd look through all of the posts, filtering on the tags field for the inclusion of 5. In PostgreSQL, using the array type, we'd do something like this:

select * from posts;
┌────┬──────────────┬─────────┐
│ id │     name     │  tags   │
├────┼──────────────┼─────────┤
│  1 │ CBeebies     │ {5}     │
│  2 │ Fast Website │ {1,2,4} │
│  3 │ Programming  │ {4,6}   │
└────┴──────────────┴─────────┘
(3 rows)

Time: 0.282 ms
peter=# select * from posts where tags @> '{5}';
┌────┬──────────┬──────┐
│ id │   name   │ tags │
├────┼──────────┼──────┤
│  1 │ CBeebies │ {5}  │
└────┴──────────┴──────┘
(1 row)

That's fine, but that doesn't give you the benefits of using a relational database. What if someone deletes the Kids TV tag from the tags table? Well, our arrays (or strings full of comma separated values) will point to nothing. That's precisely …

cereal commented: nice explanation, thanks for sharing! +14