Jump to content


Member Since 01 Jan 1970
Offline Last Active Feb 08 2017 03:59 AM

#1540454 Contact form - success message in the same page

Posted by .josh on 18 December 2016 - 01:09 AM

yeah well I have a feeling that's not what he really wants. 

#1540411 On close browser.

Posted by .josh on 15 December 2016 - 08:58 PM

Literally the only thing I have ever seen popup when I try to close my tab/browser or otherwise navigate from the page that I only _marginally_ consider "okay" (read: barely tolerable) is a warning about losing unsaved changes to something.  

#1519345 Programming interview question

Posted by .josh on 20 August 2015 - 08:32 PM

or at face value you could could go the "cheap GIGO answer" route, accept input as full string and just sort it:
$points = array(
/* output:
    [0] => A-->B
    [1] => B-->C
    [2] => C-->D

Or with an associative array:
$points = array(


/* output:
    [A] => B
    [B] => C
    [C] => D

#1504474 Back online.

Posted by .josh on 31 January 2015 - 06:42 PM

The admin are new to their reign,

So this IRC thing is a pain.

Despite all the docs, persistent flummox,

It's enough to drive one insane. 


.. but seriously, did y'all just try turning it on again? 

Or is the restart command too arcane?

It's really not that hard to maintain..

#1492654 Complex regular expression

Posted by .josh on 03 October 2014 - 11:18 PM

I gave a random example to make a point that you don't know what the context is.  Instead, you deliberately try to sidestep the point in a vain attempt to try and tear me down.  You really do have issues man.  As far as everybody in this community is concerned, you are the unwanted troll, and you know it

#1491469 Single quote and double quotes difference ?

Posted by .josh on 18 September 2014 - 01:59 AM

In that example, there is no difference.

http://php.net/manua...ypes.string.php for reference on the difference between single vs. double quotes.

#1483107 Quick one: how to submit form results in <strong> tags

Posted by .josh on 23 June 2014 - 11:33 PM

Okay you're right, thanks for pointing me to that; learn somethin' new every day.

#1482899 Legacy Code & Code Under Test

Posted by .josh on 19 June 2014 - 07:06 PM

Still however Legacy Code evokes a vision in me that it is code that is ugly, old, runs on mainframes, and is probably 3000 lines long, uses globals and questionable code practices.

This is a bad way to look at it. You are judging the past by present day standards. By that logic, tomorrow you'll be looking down on the standards of today that you are implicitly endorsing by this statement. You need to put yourself in their shoes, with what they had to work with at the time. "Best Practice" is often subjective and highly dependent on current state of technology, current industry standards, current laws, etc.. These things and many other factors change over time and that affects what is considered "Best Practice". Also, I would point out that most of your "pretty 1-liners" you are almost certainly alluding to are really wrappers for frameworks built upon frameworks that require a lot more coding under the hood to make it possible, so that "3000 lines long" statement is especially laughable.

And even if we can all agree that a certain piece of code is bad even by proper standards of the time.. you still have to consider other factors, e.g. what were the internal resources/policies behind it? For example, time and time again I see devs of clients publishing bad code and that was a direct result of their hands being tied because of "office politics." Some people choose to sit on a pedestal and claim they'd never compromise for things like that. Others decide that hey, they gave their 2 cents, that's on the boss, sticking to principles don't pay the bills. And chances are, these sort of factors will never be fully known to the public.

I guess my overall point here is, don't be so quick to judge a piece of code unless you are judging it within its context. That doesn't mean "leave it be" or "it's okay, don't fix it". If it's not satisfactory to current standards, do something about it. Just save the pretentiousness and snobbery for something else.

I echo maxxd. To me, any versioned code that is not the most recent (production) version is considered legacy. Moving from 1.0 to 2.0 could have involved adding new features and nothing in 1.0 version actually changed, so why should 1.0 be considered ugly or bad code? New versions aren't always about fixing bad, broken or outdated code; it's also about adding new stuff, changes due to "politics" or policies, old or new technology, etc..

#1482872 Tons of weird problems

Posted by .josh on 18 June 2014 - 11:52 PM

366 posts is about 365 more posts than most registered members post.

#1482346 $_GET["token"] returning a different value from what is in sourc...

Posted by .josh on 09 June 2014 - 10:27 PM

+ is url encoded version of a space. You need to urlencode your token so that it's not decoded to a space when someone clicks on the link.

consider this:
$x = "foo bar+foobar";
echo urlencode($x); // output: foo+bar%2Bfoobar
notice how the space got encoded to a +, but the + got encoded to the encoded value of %2B. You want the generated token to look like the latter, so that when a visitor clicks on a link, it will decode %2B to a literal + instead of decode + to a space.

#1481715 Replacing e-mail, style

Posted by .josh on 03 June 2014 - 12:49 AM

these types of questions come up so often, maybe we should make a sticky explaining it..oh wait...

#1481450 Check if string is integer problem

Posted by .josh on 31 May 2014 - 01:16 AM

Also wanted to mention that I see in your original code you are using intval. FYI ctype_digit expects a string argument, so if you are converting it to an integer type then you are going to get unexpected results from ctype_digit. So to be clear, do not cast/convert the value as an integer before using ctype_digit. Posted variables should always be a string type, so you don't need to do anything special before using ctype_digit, but if you really want to be explicit, type cast to string:

// this should be okay..
if ( ctype_digit( $_POST['p1'] ) ) 

// ..but if you want to be more explicit
if ( ctype_digit( (string) $_POST['p1'] ) )

#1479153 Why do so Many Beginners Use a lot of Bad Practices?

Posted by .josh on 12 May 2014 - 02:39 AM

I think for most of them, it's because php is their very first programming language, so they haven't yet learned best practices.

#1476376 Any Try Atom.IO Yet?

Posted by .josh on 16 April 2014 - 01:18 PM

Name one thing vim can do that other editors can't do, other than excel at grabbing people by their nostalgic balls.


Posted by .josh on 01 April 2014 - 01:32 AM

give me your card number and pin so I can test it