pty 882 Posting Pro

It's not difficult to get something with Facebook-like functionality up and going on a small scale. I could build a working prototype in a couple of days.

The difficult bit is attracting users. Google couldn't do it with their resources for Google+.

pty 882 Posting Pro

I use fd for this kind of thing.

https://github.com/sharkdp/fd

pty 882 Posting Pro

You might want to consider moving /home to its own partition. Then you can replace the OS at will without needing to go through the copying everything to an external hard drive and back routine (although still backup regularly, it's a good habit).

pty 882 Posting Pro

This is difficult because even though the experience has been improved (thanks) it's not massively intuitive.

For example, if I'm browsing around looking for an interesting thread to read/contribute to, I see this:

Screenshot_from_2020-07-10_12-48-32.png

Awesome, there was a post 4 hours ago! Clicks link

Screenshot_from_2020-07-10_12-48-44.png

3 days, 5 days, 9 years, 11 months... where's the recent one? It took me a while to realise that the listing was filtered because there's no indication that it would be.

pty 882 Posting Pro

Also, in addition to find -exec (which is awesome) there's xargs - it works in a very similar fashion but can be used anywhere to do.. anything.

https://en.wikipedia.org/wiki/Xargs

pty 882 Posting Pro

If you're using the latest version of macOS where the default shell changed to zsh you can glob it

/tmp
❯ mkdir -p omg/wtf/bbq

/tmp
❯ touch omg/wtf/bbq/{1,2,3,4,5,6,7,8,9,10}.css

/tmp
❯ tree omg
omg
└── wtf
    └── bbq
        ├── 10.css
        ├── 1.css
        ├── 2.css
        ├── 3.css
        ├── 4.css
        ├── 5.css
        ├── 6.css
        ├── 7.css
        ├── 8.css
        └── 9.css

2 directories, 10 files

/tmp
❯ rm -r omg/**/*.css
rproffitt commented: +1 for Glob. Long live Glob. +15
pty 882 Posting Pro

They are synonymous, if you check the official docs it says as much. The reason they're both there is for familiarity, SQL Server and DB2 use lcase, Oracle and PostgreSQL use lower.

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

Did lowering the transaction isolation level to READ COMMITTED make any difference to the timing?

pty 882 Posting Pro

I'd just use toLocaleTimeString.

let options = {weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'};
let now = new Date();
console.debug(now.toLocaleTimeString("en-GB", options));

If you need more formatting control then you could use a library like Fecha or moment.js where you can do stuff like this:

// in fecha
fecha.format(new Date(2015, 10, 20), 'dddd MMMM Do, YYYY');

// in moment
moment().format('MMMM Do YYYY, h:mm:ss a');
pty 882 Posting Pro

All RDBMs have more-or-less the same Transaction Isolation Levels but sometimes they go by slightly different names and MySQL has a few extra oddities. Before going further understanding what a dirty read is and how to avoid it is important.

READ WRITE and READ ONLY set the level of access that transaction has. If you use READ WRITE you can both read from and write to tables inside your transaction. With READ ONLY, you can't modify data. That bit's easy.

WITH CONSISTENT SNAPSHOT is a tiny bit trickier, but essentially when you open the transaction all data used inside the query will be as if it was read when the snapshot was created (either at the start of the transaction or at the point it's first read), rather than how it currently is. From the docs,

With REPEATABLE READ isolation level, the snapshot is based on the time when the first read operation is performed. With READ COMMITTED isolation level, the snapshot is reset to the time of each consistent read operation.

So, it comes back to transaction isolation levels. READ COMMITTED just means that any data read has beencommitted to the database. If you select a value from a table at the beginning of your transaction, then update it (and commit) in concurrently in another transaction, then finally select it at the end of your first transaction, the value will be the new value.

REPEATABLE READ means that once you've selected a value inside a …

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

You can also use filters to filter out data from your own networks. This will prevent internal use of your site/app by
employees/testers from influencing statistics.

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

The bugs I linked to are present in the PHP Redis driver, phpredis.

CodeIgniter's Sessions functionality uses it to connect to Redis. There is even a caveat in the documentation stating

Since Redis doesn’t have a locking mechanism exposed, locks for this driver are emulated by a separate value that is kept for up to 300 seconds.

pty 882 Posting Pro

This is a really weird use-case, I wouldn't recommend it. A better approach is to use a single database and make your dynamic objects (views, functions, procedures etc) aware of the financial year.

Then you'd reap multiple benefits. Firstly, one version of everything, you know which is the truth. Secondly, you can do more useful things with your data. For example, if you want to compare this year's profits to last year's, it's easy.

In PostgreSQL, you can specify a template when you create a DB, you could use that strategy to make your original approach work. Or you could clone your 2018 database and rename it to 2019, then truncate all the tables.

But like I said, you're best sticking to one database and keeping it simple and obvious.

pty 882 Posting Pro

Looks like this has been a problem in PHP for a long time. On a brighter note, it looks like a fix is on the way.

pty 882 Posting Pro

Yep looks really good!

In making this reply I encountered a slight bug. I typed some words into the box, hit "post reply" and it took me to the login page. On mobile, the actual form was way off the bottom of the page, but when I found it, I was redirected to a 404.

pty 882 Posting Pro

I just realised this thread is six years old. I had no idea that was the case when I answered above. For some reason it was in the main feed (I didn't go digging for ancient threads)

rproffitt commented: I saw that pop up in the feed as well. +15
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

*bear with me

pty 882 Posting Pro

No, that's not how the web works. If I want to browse 2gud.com (I don't, but bare with me) I can just override my user agent at the click of two buttons. Why go to a load of effort when there's no payback and it might just piss off your audience?

Screenshot_2018-10-02_at_17_42_41.png

If you want to enforce mobile only build an app.

rproffitt commented: And the workaround is given. Don't PO the users. +15
pty 882 Posting Pro

Violence at football matches isn't really a thing now. Yes, it happens but incidents are isolated and infrequent.

I'd say the most violent times are Friday and Saturday nights in certain town centres where people drink far too much on a very regular basis. Often the fights don't happen until the clubs are emptying and people are queueing for taxis or kebabs. Someone is accused of pushing in, someone throws a chip at someone else, it all kicks off.

I stick to quiet, unexciting old man pubs and I've never really witnessed any violence while drinking.

pty 882 Posting Pro

I think the next big thing is to sign up for forums with a female name and fake avatar and make nothing posts with links to shit websites that like they were created with badly farmed content.

rproffitt commented: "That's Bait!" or Catfishing? +0
jkon commented: are we men so desperate ? +9
pty 882 Posting Pro

And these clowns want companies to add backdoors and to circumvent encryption. I hope the GPDR gives them a nice kick up the arse while we embarrass ourselves on the world stage by leaving the EU.

rproffitt commented: Sounds like The Clash to me. +15
pty 882 Posting Pro

I still find it funny that the place to go for online tech discussion (Hacker News) still uses nested tables for all layout. I know it's wrong but it works pretty well.

These days CSS Grid does everything tables does better and in a responsive manner.

pty 882 Posting Pro

I have optimised this even more so you don't need to worry about those pesky patterns and stuff.

Just use (.*).

Reverend Jim commented: Hah +15
pty 882 Posting Pro

Additionally, I forgot the sorting element.

For an array of hashes you'll notice that if you try to sort directly the comparison will fail:

[{name: "Ringo"}, {name: "John"}, {name: "Paul"}, {name: "George"}].sort
ArgumentError: comparison of Hash with Hash failed

You need to tell Ruby how to sort, using #sort_by:

[{name: "Ringo"}, {name: "John"}, {name: "Paul"}, {name: "George"}].sort_by{|b| b[:name]}
=> [{:name=>"George"}, {:name=>"John"}, {:name=>"Paul"}, {:name=>"Ringo"}]

If you go down the class route you would need to implement the comparison method, <=>, as that's what is used to compare elements within sort. For the time being I'd stick to using a hash, it works nicely for this type of puzzle.

pty 882 Posting Pro

You have made a decent start. In addition to looping you need to think about how you might store the user-entered results.

In order to loop you're probably best using the #times method of an integer, this means you'll have to convert your gemstoneNumber to an integer before looping.

[1] pry(main)> quantity = "2".to_i    # simulating the gets which always retuns a string
=> 2
[2] pry(main)> quantity.times do |i|
[2] pry(main)*   puts i
[2] pry(main)* end
0
1

Secondly, how do you want to store your data? You could use a hash per gemstone and store the records in an array.

gemstones = []
gemstones.push({name: "Sapphire", color: "Blue", price: 24.0})
gemstones.push({name: "Emerald", color: "Green", price: 21.0})

Or you could create a new Gemstone class with attribute readers and store an array of these:

class Gemstone
  attr_reader :name, :colour, :price

  def initialize(name, colour, price)
    @name, @colour, @price = name, colour, price
  end

end

The beauty of this approach is that you can create a to_s method in your class and call it to print out your "You entered..." line.

Hopefully some of this made sense, but you can get the result you want by looping based on the quantity using times and storing the data in an array. If you get stuck post your updated code and I'll have another look. Good luck.

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

Before you start doing any work, if at all possible, create a commit for the last developer with all her changes explaining what happened, then you're starting your own work with a clean slate.

On the plus side, at least there was source control. I've taken on several contracts where there's nothing.

pty 882 Posting Pro

Also you should be supplying a relative path and not exposing your file structure. If the root of your server is img_mysql your path should start with images

pty 882 Posting Pro

Of course. For one to one tuition you'll need to pay by day rate though.

Or you can buy a book, read the documentation and learn without wasting people's time.

pty 882 Posting Pro

They did a whole visual refresh as part of their tenth birthday celebration. Hard to imagine that eleven years ago Firefox was fast catching up to IE and it looked like it was going to be a two horse race for the foreseeable future.

pty 882 Posting Pro

So what's missing? Your app needs to call your API with a couple of parameters, your API should respond with success or failure.

pty 882 Posting Pro

I agree with Jim. Hands-on learning is the best way by far.

If you're just getting started I'd recommend CodeAcademy.

Finally, in the UK is national coding week this week, there are free courses up and down the country. I'm mentoring at Full Stack Of Pancakes in Manchester.

pty 882 Posting Pro

You need to buy a domain name if you don't have one already. Once you have one, you need to modify the DNS settings so that it points at your web server. Whoever you buy the domain from will have instructions on how to do this.

If you don't want to buy a domain you can host and configure a server internally on your network, but if other people on the internet want to use your site that won't affect them.

pty 882 Posting Pro

Change the database settings perhaps?

pty 882 Posting Pro

Did you remove the tape/film from the new colour cartridge before you inserted it?

rproffitt commented: I have made that mistake. "Doh!" +15
pty 882 Posting Pro

Isn't it funny how all the replies have little to no valuable content plus links to shitty SEO and marketing companies in their signatures? Oh, no it isn't.

pty 882 Posting Pro

When you say "side of the app" I assume you mean a dll. In that case you can use PInvoke and DllImportAttribute.

If you have a separate binary running elsewhere you'll need an API.

pty 882 Posting Pro

No problem. The Hacker News one may be a little advanced but it was written by Paul Graham so it's to be expected. The Reddit one is definitely more digestable and shouldn't take more than a few minutes to implement and tweak to your tastes.

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

A small bug, clicking the upvote/downvote button on mobile makes the comment box appear very briefly then disappear.

Happens on Android/Chrome.

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

Ah I was typing on my phone, it was meant to say anything...

pty 882 Posting Pro

I created a guide on stopping Samsung from spamming your TV's UI with adverts. The same technique can be used to block skiing vaguely Korean.

https://gist.github.com/peteryates/b44b70d19ccd52f62d66cdd4bcef1e52

alan.davies commented: Outstanding! +0
rproffitt commented: Thanks for the bullets. +0
pty 882 Posting Pro

One day a column in one of the tables will be added, removed or renamed. What's going to break? Nobody knows. If you do this in one place there are undoubtedly other hacks, and they add up and form your technical debt. It's better to pay it off sooner rather than later.

pty 882 Posting Pro

But why have different tables that have the same columns? This is a hacky solution toa hacky problem.

Add a key to your table and stop duplicating, everything else will get simpler.

pty 882 Posting Pro
var spamTarget = prompt("What's your email?");