Joined October 2012
·

Richard Clifford

Web Developer at Cybershade
·
Plymouth, UK
·
·

Posted to console.table over 1 year ago

console.table([{name:'Gaurav', email: 'name@email.com'}, {name:'Max', email: 'name@email.net'}])

For anybody who wants the correct copy ^

Posted to Sublime Text: The most badass config over 1 year ago

Awesome Protip! Thanks for sharing. I have added some of my own options to it and changed some others for PHP Programming, but awesome.

Posted to Me, my self and that over 1 year ago

Don't get me wrong, I don't really mind, I see what you're saying about the private variables, but I was just asking to see what the reasons were, and that explains it :)

Posted to Me, my self and that over 1 year ago

So what's wrong with using _self ?

Hi Nathan,

The issue I have found with phpbench is that I did a very simular test with the "foreach vs for vs while" loops and my tests differed from their results.

My foreach loop was faster than both for and while, now this came to me as a big surprise as the way that foreach works, so I got another couple of developers to check over it and they were as surprised as I was, but the results were conclusive throughout all of our tests.

So just bare in mind to not take these tests as 100% guaranteed and do your own research to ensure that they are correct.

Posted to Check a 1D array for emptiness over 1 year ago

@kanuj Then why not do something like

if( !isset( $array['email'] ) || empty( $array['email'] ) )
Posted to Random Lightning over 1 year ago

@mdeiters I slapped it in JSFiddle to play with: http://jsfiddle.net/XFzET/1/

It's quite cool!

Posted to MySQL Query Optimization over 1 year ago

@smidwap A database schema once setup correctly shouldn't need to be changed, and if it does then you should be updating the version of the software which you are 'releasing', which means you should update the code to a newer version too.

It is a well known performance issue to not use * as it takes MySQL a while enumerate which columns are in that table and if you are not using all of the data that it brings back then it is wasted time for the server to process.

If I had a table with the following columns in it:
id, username, password, email, sex, dob, city, country, avatar

and I just wanted to check whether the username exists in the database, there would be no need for me to select * when I could just select username/id.

I couldn't agree with you more on the query caching and view caching, however I did state in the start of this 'ProTip' that it was a very basic query optimisation technique and that I will be going deeper into it when I have a moment to write up a good article.

Anyway, thanks for your feedback, much appreciated!

Posted to Object Orientated Javascript over 1 year ago

I apologize, my Javascript really isn't up to scratch by anybodies standards, and I totally forgot you could manage "Classes" like that.

So yes, I agree with you totally there. I should have done more research into this before "jumping the gun".

Kudos.

Awesome tip, you have no idea how long I look at my server for wondering how to make my life more simple, and that is defiantly something that I will be bookmarking. Thanks!

Posted to Random String/Code Generator over 1 year ago

@richthegeek It's always good to see someone who can really optimize their code effectively.

Thanks for the update as well, it's always appreciated.

I personally don't think that there is really that much in either of them, even before you optimized your code, if anything I would lean towards using your function over mine, even at the extra cost of 0.03* seconds. Solely because yours does a better job than mine does.

Good work!

Posted to Random String/Code Generator over 1 year ago

@richthegeek Okay, I've done a bench mark on the two functions and mine is marginally faster than yours (tried to make the test as even as possible).

However, yours does seem to be a more thought out function which would return a better result.

------- Bench for generate_string() ------
0.84907793998718
------- </of> Bench for generate_string() ------

------- Bench for randCode() ------
0.33225393295288
------- </of> Bench for randCode() ------

Result : http://codepad.org/IQJSuY7A

Posted to Random String/Code Generator over 1 year ago

@richthegeek Seems like we have a very similar function all in all. Even the purpose. I used mine to create test data as well as session IDs for my Session Class which was then MD5'd (+ salt).

I would be interested in the performance output of each to be honest. I might do a test on them and get back to you.

Posted to Web Security: File Names over 1 year ago

I Couldn't agree more with you, I wish I had mentioned this in my Pro Tip about sanitizing variables.

The only one thing I can add is HOW:

a) htmlspecialchars()
b) striptags()

c) stripslashes() / addslashes()
d) mysql
realescapestring()
e) htmlentities()
And to be honest, hundreds of more methods of sanitizing data.

Awesome post.

Posted to jQuery shift() implementation over 1 year ago

Very nice function!

I might have to implement this into my current piece of work. Thanks!

Posted to Perfect Workflow in Sublime Text over 1 year ago

@nmalcolm Brilliant, I haven't made my way through them all yet, but the ones I've seen look great!

Posted to Perfect Workflow in Sublime Text over 1 year ago

Thank you for this, I've recently-ish moved to SublimeText2 and There were just a few things which were missing from it IMO. This has just got me the plugins that I required.

Thanks again!

Posted to DRY? - best practice for coding over 1 year ago

I couldn't agree with you more.

Anybody who understands the OO concept should be able to separate their logic from their views. This is the basics for most systems I have worked on personally.

Achievements
171 Karma
19,213 Total ProTip Views