pty 867

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 867

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 867

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 867

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 867

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

pty 867

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 867

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 867

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 867

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 867

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 867

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 867

Change the id of one of the inputs, perhaps?

pty 867

Like my post perhaps?

pty 867

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 867

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 867

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 867

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 867

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 867

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 867

pty 867

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 867

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

pty 867

+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 867

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

pty 867

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 867

Use comm or diff.

pty 867

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 867

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 867

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 867

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).