pty 882 Posting Pro

While you're at it Dani, I think there should be a preference somewhere to hide (or group, maybe) the "began watching a topic" and "viewed a topic" cards. Am more interested in posts and replies.

The data can still be presented I think, just maybe a little less promenant. Maybe the watcher avatars like on a GitHub ticket?

pty 882 Posting Pro

MySQL binds current_timestamp()/now() at the beginning of the statement so I believe all of your records would have the same created_at value.

If you wanted them to differ I think you'd need to use a cursor and separate insert statements.

pty 882 Posting Pro

These days, just build responsive.

jQuery Mobile has always been a kludge, I wish it didn't have the jQuery name because that made people think it was actually good. It's not, avoid it.

pty 882 Posting Pro

So you have a target database (the one you'll be left with at the end) and a source database, the one you'll copy from. Take a backup of both of your databases before you start.

If you have any unique fields you need to remove them from the source database. So, if you have an auto-incrementing id field, drop it. Once it's ready, you can export it as a CSV. Note that if you miss this step, your import is likely to fail because the ID's assigned to your records and his records will clash.

Now, in your target database, click 'Import from Text File' (this varies depending on the version you're using) and pick the freshly-exported CSV file. Go through the wizard and try it out. Hopefully his data will be alongside yours in the table.

pty 882 Posting Pro

Excluding your aggregate columns you need to group by all you select by. That's just the way it works.

pty 882 Posting Pro

If you're not even going to read the links I post there's no point in responding. The algorithms are even listed and annotated. You could convert that code to SQL quite easily, or do the heavy lifting in SQL and the ranking in PHP.

Nobody's going to spoonfeed you code.

pty 882 Posting Pro

It's not just the algorithm, as @alan.davies said, the data plays a part. Instead of storing up or down votes as integers, you probably need to introduce a new relation (let's refer to it as Vote) that has a post_id and a user_id which are foreign keys to the posts and users tables respectively.

Now, a user can only vote once per post so add a unique index that covers post_id and user_id. And obviously you need a direction (up or down, perhaps you could store this as a +1 or -1) and timestamps (created_at, updated_at).

Now, it's trivial to work out not only how people voted but when they voted. You have enough data to implement the Hacker News or Reddit algorithms.

pty 882 Posting Pro

I quite enjoy puzzles like this. Of course, I suspect that your problem will get much harder once you start adding stuff like (Banana, fruits, or) to the equation, as then you'll need to worry about brackets and presedence.

However, for this simple version here's how I tackled it in Ruby. You can pretty much translate this to PHP but it won't be as succinct or elegant.

puts "(Mango, fruits, and), (Maize, cereals, and), (Mango juice, beverages, and)"
  .scan(/\((.*?)\)/)                                                    # grab all the text that appears inside brackets
  .flatten                                                              # scan yields an array of arrays, flatten it
  .map{|chunk| chunk.split(",")}                                        # split each trio into a word array
  .map{|fruit, category, operation| "(#{fruit}[#{category.strip}])" }   # build the keywords into strings in the desired format
  .join(" AND ")                                                        # join the built strigns with 'AND'

(Mango[fruits]) AND (Maize[cereals]) AND (Mango juice[beverages])

pty 882 Posting Pro

I'm more of an editor than IDE kind of guy but VSCode might fit the bill. It has a built in package manager so you can install PHP (or any other language, technology etc) specific functionally. I use it for Go, JavaScript, CSS and HTML/Vue templates and it works just fine.

pty 882 Posting Pro

If you're a developer and list your skills and past places of work there you simply become a magnet for recruiters and are inundated with requests. Some recruiters are ok, most aren't, and a large proportion of the offers I get are extremely low quality or not even remotely suitable.

Additionally, LinkedIn employs plenty of dark UI patterns which I really don't enjoy. "27 people have viewed your profile, click here to find out who! Not really"

pty 882 Posting Pro

Microsoft has a mixed record. LinkedIn was barely touched (and remains a cesspit of the highest order), Skype was mangled and is a shadow of its former self, as was Nokia. Others, like Yammer and aQuantive were just absorbed.

If Microsoft change too much too soon, GitHub users may leave for new pastures. However, if they stay hands off, it's not necessarily an awful move. Microsoft aren't the toxic open source hating company that Balmer ran, even if that memory is still fresh in our minds.

pty 882 Posting Pro

Change the id of one of the inputs, perhaps?

pty 882 Posting Pro

Like my post perhaps?

pty 882 Posting Pro

And the reason your code wasn't working is that you were calling include?on a string and passing an array. Both string and array have an include? method, string's only accepts strings but array's accepts any object.

I'd add an example but I'm typing on my phone

rproffitt commented: +1 for effort. On a phone too. +15
pty 882 Posting Pro

As John suggests, array intersection will work. If you don't need to know what clashes, this might be faster due to any? stopping as soon as it's fulfilled.

colours = %w{red green blue orange}
targets = %w{yellow black pink red blue}
colours.any? {|colour| targets.include? colour}
pty 882 Posting Pro

There's a progress HTML element, you shouldn't need to use any additional libraries or plugins and you can style it with CSS. It's as simple as:

<progress value="75" max="100"></progress>
pty 882 Posting Pro

The week selector is based on ISO8601, and Monday was decided as the first day of the week.

You would need to use a custom widget to customise that. Alternatively, use two inputs, one with the year and one with numbers 1-52. But where possible, I try to stick to standards.

Templating is definitely the way to go for dynamic sections, don't try to build HTML manually with jury or similar. Simplicity is key.

Jon_7 commented: OK, I'm gonna figure this out and post back here when I have it officially solved. Thx a ton! +0
pty 882 Posting Pro

but how can I add HTML instead of the 1-word you used for each day?

Yes, you can add whatever you like. If you structure your data something like this, you can easily use a simple templating library to insert any HTML you like

    let data = {
        "2018-W12": {
            "Monday": {
                exercise: "Squats",
                reps: 50,
                intensity: "medium",
            },
            "Tuesday": {
                exercise: "Pressups",
                reps: 30,
                intensity: "hard",
            }

        }      
    };

Also noticed the 2018 references in the javascript

I did this for speed. You could write it by hand, or easily programatically generate a schedule for the next several years, or you could write some code that generates them on the fly. Without knowing your plans for creating the exercise schedule it's difficult to say, but providing your data is well-structured it's not that difficult.

Jon_7 commented: Wow, I've never even seen that templating thing before. I'm gonna play with that a ton. Thx! +0
pty 882 Posting Pro

Perhaps I didn't fully understand what you're after, but I'd steer clear of using plugins when you can use standard inputs.

Here's a five minute stab at what I think you're asking for. If it's not it should be easy to customise. Where I've defined let data = {...} you should be reading that from your data (or API) and not hardcoding it in the function!

Oh, and I've only added data for W12 2018 and W13 2018 so it'll throw errors for other weeks. You'd have to revert to a default schedule or handle the error sensibly.

ryantroop commented: pretty nifty +9
Jon_7 commented: That's very close, but how can I add HTML instead of the 1-word you used for each day? Also wondering how I can get the week to start on Sunday . Thx +1
pty 882 Posting Pro
pty 882 Posting Pro

Have you changed the character set and collations (from utf8 to utf8mb4) of the database and tables you're dealing with? As far as I remember in MySQL you need to do them individually, the changes don't cascade.

pty 882 Posting Pro

Create a JS fiddle demonstrating your problem. Nobody wants to clone and set up a entire project.

pty 882 Posting Pro

+1 for Flexbox, it makes dolving these problems much simpler

Another useful link https://philipwalton.github.io/solved-by-flexbox/

Soon with CSS grid landing too, the whole process will be fun again.

pty 882 Posting Pro

Looks like you're actually going to have to write some code then!

pty 882 Posting Pro

Working out the difference between two files is trivial using (like I said earlier) diff and comm, both of which have existed since at least the 1970s.

The two provided files, diffed by word. Red bits have been removed, green added.

Screen_Shot_2018-02-15_at_16_18_03.png

Now, comm outputs three columns

  1. lines only in file 1
  2. lines only in file 2
  3. lines in both files

So by default, lines that were deleted in file 2 will be in column 1, lines that were added in file 2 will be in column 2, and lines that remain unchanged will be in column 3. You can surpress columns using -1, -2 or -3, so we can run the command multiple times to get a nice summary.

Lines deleted in f2:
deleted.png

Lines added in f2:
added.png

Lines unchanged:
unchanged.png

pty 882 Posting Pro

Use comm or diff.

pty 882 Posting Pro

This is a shady tactic at best. If someone doesn't submit the form, calling them to offer your services is likely to make them run a mile and choose a less-scummy competitor. I certainly would.

If you're selling on their data it's even worse. But, you know, it's your call.

gentlemedia commented: +1 this is bad, really... really bad! +7
pty 882 Posting Pro

No, that's how you're currently trying to do it. It being something confusing.

What is the outcome? Simple, a couple of sentences max. For example:

I'm trying to implement some kind of custom phone number validation where numbers follow [this pattern]

or

I'm trying to record someone's phone number without them actually submitting the form

By using words out of context and nonsensical phrases like "assign it to a session" confuses matters to the point where I can't tell what you're actually attempting to write.

pty 882 Posting Pro

This is an integration with payment gateway so this data should be passed to them via this way so that why I don't post or get this to another php file.

Really? Which gateway requires this kind of ridiculous gymnastics?

I think that your problem is self-inflicted.

In one or two sentences, what are actually you trying to do?

pty 882 Posting Pro

Not that it matters, but here it is in Ruby.

Simple, elegant and concise. Dare I say, beautiful?

lower, upper = 20, 400

lower.upto(upper)
    .select{|i| i.modulo(3).zero? && i.modulo(4).zero?}
    .each_slice(5){|m| puts m.join("  ")}

.upto loops from the called number to the arg. Normally I'd have written this (lower..upper).select… but this makes it a bit clearer.

.select returns an array containing elements where the block returns true.

.each_slice iterates through the enumerable object in chunks (the first arg, 5 in this case) and executes the block for each chunk (printing the array joined by two spaces).

pty 882 Posting Pro

What's the error?

pty 882 Posting Pro

That sounds like what he's after. With more than one level you'd need to use a window query to do this. Here's an example I wrote many years ago.

pty 882 Posting Pro

You can't expect anyone to work out what's going on without posting the accompanying JavaScript. I suggest you make a JSFiddle or similar.

diafol commented: Davy has been here 6 years. You'd think... +15
pty 882 Posting Pro

Keeping questions and scenarios fresh helps prevent lesser students (like this one) from just finding the answers online.

This problem has been solved hundreds of times, and there's an exact duplicate in this forum.

I don't mind helping but I like to see some effort first, not just pasting the question directly into a forum. If you want to help the OP do his homework without actually learning anything, go ahead.

pty 882 Posting Pro

I'd ask for the money back on whatever course you're doing, the material hasn't changed for seven years.

pty 882 Posting Pro

Easy to forget how much power you have with the Unix toolbelt at your fingertips.

Screen_Shot_2017-08-21_at_15_49_23.png

rproffitt commented: Toolbelt, power? Batman using the force? +12
pty 882 Posting Pro

Nobody's going to try and decipher/run all that code. What exactly is the problem? Try creating a JSFiddle or something.

pty 882 Posting Pro

Yes, you can definitely normalise further, like with the nutrients approach @diafol suggests, but you need to know the data before making a judgement on whether it's worth it.

There are advantages and disadvantages in cases like that.

ddanbe commented: Thanks for the advise! +15
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

I'd start by learning Java. Then SQL. When you've learned Java and SQL, then learn HTML. Now you've mastered those relatively simple subjects, just learn all of the glue that connects them together. Once you've done that, it's quite simple:

Your attendence is probably represented by a join table; a student attends a lesson. so your attendance table will contain student_id and lesson_id.

Now, on your HTML form you should generate a list of checkboxes for every student who might attend the class (probably based on their subject and grade, or whatever). The checkbox's value should equal the student's ID:

<input type="checkbox" name="attendance" value="2345"/>

When the form is submitted, only the checked checkboxes that are checked (i.e. those who have attended the lesson) will be included in the form data. Save each of the IDs you recieve as a row in the attendance table. Easy.

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

The XPath works, your PHP looks wrong.

$xmllint --xpath "/solar/solardata/solarwind|/solar/solardata/magneticfield" solarxml.xml

<solarwind>511.8</solarwind><magneticfield> -0.7</magneticfield>

I assume you didn't read the documentation. I don't know PHP, there may be preferred libraries for this type of thing.

pty 882 Posting Pro

XPath /solar/solardata/solarwind|/solar/solardata/magneticfield yields:

<solarwind>509.4</solarwind>
<magneticfield>  1.9</magneticfield>
pty 882 Posting Pro

True, and if she wants to continue and learn then fair play, and I hope she manages to build something great.

However, she's using a discontinued tool that outputs unmaintainable HTML, and developing her site clearly isn't her goal; letting people know about her jewelry (which looks fantastic, by the way Sanda) is.

Plus, as there's a products tab on her site, one would expect that some kind of 'web shop' is on the radar. That won't be doable in Webplus, and it's not the easiest thing to implement from scratch at the best of times.

pty 882 Posting Pro

I'd suggest using something like SquareSpace for this kind of site, rather than attempting to build it yourself. It has an e-commerce module built-in and plenty of easy templates to choose from.

A note unrelated to the original question, when at 100% zoom, I can only see 2/3 of the page, I need to scroll right to see the whole thing (or zoom out to about 80%).

pty 882 Posting Pro

I was going to help, but rather than just help you in the way that you want (that'd be too boring) I thought I'd give the answer in Ruby.

[2,4,6,3,2,4,3,8]
  .group_by{|i| i}
  .select{|_,matches| matches.count > 1}
  .keys

=> [
    [0] 2,
    [1] 4,
    [2] 3
]
pty 882 Posting Pro

I doubt it's your query that's slow. What happens if you simply run the query select * from Doopgegevens; in a shell? For ~10k rows, providing your table is holding 'normal' data (and not base64 encoded movie files or something) it should be fast. If it is fast, try changing your data list to only use a subset of your table's columns, which will indicate if that's where your performance problem is.

pty 882 Posting Pro

This should help explain the differences between UNIX and Linux.

alaa sam commented: thanks alot +0
pty 882 Posting Pro

I want to get the row number of a specific row in the table.

Also is this legal?

INSERT INTO (SELECT * FROM myTable WHERE mynumber=2) VALUES ........

Getting the row number depends on the DB you're using; Oracle supports this (via ROWNUM ) but MySQL for example does not.

Your statement is invalid; if you want to update a row you should be doing:

update myTable set foo = 'bar' where mynumber = 2;
pty 882 Posting Pro

In your controller do you have

@user = User.find(:first)

or something similar? Could you post your controller code?