I'm a big fan of using PHPUnit's data providers feature because it allows you to easily run a lot of data through the same kinds of tests over and over again without having a bunch of duplicate code sitting around. But they aren't always the easiest thing to come back to an understand.
I just finished reading Test Driven Development: By Example by Kent Beck (more on this later because this has really changed my workflow) and as I was reflecting on the concepts explained in the book I've started to wonder if people are learning to program all wrong.
One of the more interesting projects I've worked on while at STAGES has been our time machine.
I know what you're thinking but it's not a real time machine, it's just a way for use to look into the past and see the state of our site on a given day. The idea is that if a user says they did something on June 15th but the data isn't there we can go back and say "at 6 PM the data wasn't there" and then use one of the mid-day backups to investigate further. This way instead of having to restore lots of backups to determine the date the data was deleted we have easy to access data that our support department can look at without even having to involve DevOps.
It's information like this that makes me happy I'm not dependent on ad revenue for my lively hood. I can't say I wouldn't do the same if I were in their shoes.
I think 90% of my google searches are now answered using on of the Stack Exchange sites but this article make some good points.
I used this to get a bunch of colors for a graphing program that needed a bunch of colors.
I wasn't aware there were this many projects that had these shields. It's a little crazy if you ask me.
In my line of work, I get to see a whole lot of SQL Server projects – both good and bad – and work with the teams involved in building them. More often than not, I see contracting companies who have taken some disturbing shortcuts with horrifying results.
See, bad contracting companies have a huge sales force that goes out and asks customers, “Hey, what problems are you having? Sure, we can solve those. Just sign here.” They make impossible promises about their – well, YOUR – capabilities and timelines.
I had a client email me a PDF that was rotated 90 degrees and they wanted it posted. This page made it a quick fix.
The items that I know needed to be changed are nice to see but I wonder how many pieces of software are going to break because of this and the quick fix is going to be change the settings back. Still a good step forward for new deployments.
This post has some examples of what will happen.
I was thinking I was going to need to write a wrapper to upgrade the old mysql_* functions in my code but it looks like someone has already done that.
This one is my favorite:
5 years experience – that framework came out 2 years ago!
An interesting discussion on how to thing about how our code fits into the bigger picture. I know we've had conversations about features that seemed like a quick no brainier but then ate up a lot of time adding refinements and fixing bugs.
Another interesting conversation about geeks and how they fit in with normals. Also some comic book talk that went a little over my head...
I don't have to do this type of meeting much but this has some helpful times (including to practice fully [not just read the slides in your head]).
In this episode, Adam talks to Corey Haines, author of "Understanding the 4 Rules of Simple Design". They talk about the importance of low-level design decisions, tricks for naming things well, why you shouldn't model your objects after the real world, and of course, Active Record.
I've written about how you can use mysqldump to output specific records before but what if you need to export data from a complex query for a one off report:
SELECT lastName, firstName, count(*)
FROM User
INNER JOIN User_Log on User.id = User_Log.UserId
GROUP BY lastName, firstName;
In order to export this to a CSV file you can tack the following on to the end of you're query and it will be exported:
INTO OUTFILE '/tmp/data.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
Then you just need to download the file and send it to your client.
The other day I needed to determine the type of an element returned from a jQuery search. It's done through the prop()
function and it returns an upper case string:
var element = $(this);
if (element.prop('tagName') == 'TD') {
// do something
}
The existence of BAD CODE being copied and pasted by newcomers is probably the biggest source of exploitable security vulnerabilities in the entire industry.
**Disclamer: ** I'm sure MySQL database administrators will tell me that this is SUPER wrong because I should always let the database engine pick what indexes to use but this feature exists for a reason. That being said I'm NOT a database administrator I'm just a programmer that plays one on TV.
The other day we ran into an issue where a page would take about 60 seconds to rendering and the problem was tracked back to a single query. Lets say it looked like something like this:
SELECT *
FROM Table1
INNER JOIN Table2 ON Table2.id = Table1.Table2Id
WHERE Table2.column = 'true';
When I ran explain
on the query I got the following:
I've never seen it use intersection before and I had a index set for all the columns I was using. In MySQL you can force it to use an index:
SELECT *
FROM column
INNER JOIN Table2 USE INDEX (column_idx) ON Table2.id = Table1.Table2Id
WHERE Table2.column = 'true';
This simple change took the query from 60 seconds to 0.5.
An overview of some of the more important improvements to PHP7. I'm super happy to see the mysql_*
functions going away.
An overview of how you should be adding indexes to your MySQL tables.
Horrible take away from this article:
1.1% of people aren't getting JavaScript enhancements
I love the way they tested this:
So @tombaromba hacked some code in the GOV.UK homepage (similar to an approach inspired by an experiment Yahoo! Conducted in 2010). We chose this page because of its high volume of traffic and low likelihood of any bias towards a particular user group or demographic.
This code included three images, of which browsers should request two.
First, an image that virtually all browsers would request (the ‘base image’).
And either
- an image that only browsers executing JavaScript would request (the ‘script image’)
- an image that only browsers not executing JavaScript would request (the ‘noscript image’)
We deployed this code and then collected the log data from over half a million visits. I expected that number of ‘base image’ requests would closely equal the combined ‘script image’ and ‘noscript image’ requests.
I'm curious what the numbers are for sites I manage...
I wish more sites would get behind this:
User identity is always email, plain and simple. What happens when you forget your password? You get an email, right? Thus, email is your identity. Some people even propose using email as the only login method.
This is the scariest one in the bunch:
Remove all local untracked files (and directories) from your local clone
Careful! You might want to take a backup before doing this:
git clean -f -d
A good overview of why you should be using a static asset pipelines but it doesn't go into enough details to actually be helpful. :-)
A curated list of resources for learning about application security
The main topics of this cheatsheet include an intro to the shell, navigating around the shell, common commands, environment variables, connectors, piping, I/O redirection, permissions, and keyboard shortcuts.
I've been trying to figure out how to communicate Podcasts and links that I found to be informational or interesting but I don't want to clutter up my site with junk so I'm going to start creating roundups every month so I can still communicate these but not have 100 one link posts.
This sounds like a really interesting Agile project management system. I've created an account and it looks amazing.
This is a really interesting presentation about a bunch of topics that are important if you're creating a project. I've listened to it twice and I'll keep coming back to it. I might even listen to it again and post my notes. It was packed with information.
An overview of various tools use in PHP development. I'm always looking for better tools to improve my work.
An interesting overview of command buses.
TIL a11y = Accessibility because it starts with an "a", ends with a "y", and has 11 characters in between.
Accessibility is one of those things that I think I should do more with but never do. I'm really going to make it a goal to get my stuff together and test my sites for accessibility.
Bletchley Park is where Turing helped create the computer that broke the Enigma. This interview talks to one of the people who was involved in converting it to a mueseum and clears up some inaccuracies in The Imitation Game (a great movie if you haven't seen it yet)
We just finished hiring a new programmer at Zimco and almost all of the candidates we got were white men (a lot of that is due to our office's location in Mid-Michigan). It was interesting to hear two separate podcasts that discussed diversity hiring within as many days.
subscribe via RSS