Page 5 of Software Development Articles

Migrating from Mandrill to SparkPost

If you’re reading this then you where probably slapped by MailChimp’s latest announcement to merge Mandrill into MailChimp. You may be outraged because you were on their free tier which is going away. Personally I don’t agree with your rage. In fact, I think you’re a freeloader. That being said, […]

Multiple buttons with Hubspot's Vex

I’ve been implementing HubSpot’s Vex library as a replacement for stock alert(), confirm() and prompt() dialogs on SceneKids recently. In one use case, I wanted to be able to have 3 buttons on the dialog with each button returning a value, instead of just boolean true for the OK buttons. […]

How to Capitalize the First Letter in a String in JavaScript

I’m still kind of spoiled by the built-in functions in PHP (as well as Ruby and Python for this particular task). Something like capitalizing the first letter of a string is a trivial task in most languages: <?php // Capitalize first letter with PHP ucfirst('some string that needs the first […]

Using an 11” MacBook Air for development

I do it, and I do it well. In fact, I’ve built an iOS game on it and used one exclusively without an external display while working at Sumo HQ in Austin, TX this past week. The 11” MacBook Air is a decent machine, even if you think the screen […]

Tracking peak users online with Redis

This probably isn’t the best way to track things, but it’s the best I came up with. Tracking the total number of users that log in per day or month is trivial as I have discussed in a previous post. To track the peak users online at a given time […]

Email validation via MX lookup in PHP

Validating that an email addresses ain’t what it used to be. I remember writing simple regular expressions that worked out really well. These days there are a bajillion TLDs with more being added all of the time. Something I started doing is checking that the domain of the email being […]

Check if a string contains a character with PHP

Checking if a string contains a character could be accomplished easily with a regular expression or you can use the built-in PHP functions. To check if a string contains a character of a specific case you can use strpos. $haystack = 'This is my haystack that we shall check' $has_A […]

Generate random hex color with PHP

There’s many ways to skin a cat, or generate a color. You could randomize a number between 0 and 16777215 then convert it to hex: $rand_color = '#' . dechex(mt_rant(0, 16777215)); Or you could do what I like to do, just md5 a random string and grab the first 6 […]

Run a block of PHP code a certain percentage of the time

Sometimes, you may want to run code all of the time. Other times, you may want to run code some of the time. This is how garbage collection in PHP works. Based on your configuration for gc_probability and gc_divisor, garbage collections runs a fraction of the time (defaulting to 1/100 […]

CSS :not issue in Safari on iOS9

Seems that every time that Apple releases a new version of iOS I encounter some weird rendering issue. This time around with iOS9 I encountered an issue where the full / desktop version of the site looked like it still using some of the mobile / smaller device stylings. After […]

Stop submitting feature requests for Open Source Software

A few years back I wrote about my experiences contributing to and maintaining open source projects. Since then, I’ve done my share of forking, pull requesting and even starting up new projects that people are forking and pull requesting. I make a very conscious effort to contribute to projects that […]

Bitmaps vs. Sets to track Monthly Active Users in Redis

Recently I was building a piece of functionality to track the daily and monthly active users on one of my sites. I already track this data in MySQL but retrieving the data was sluggish, even after creating a few new indexes, so I decided that I would use Redis. The […]

How to block AdBlock users without JavaScript

This is probably one of the most rotten experiments I have done in recent times. I wanted to see what would happen if I blocked site usage from folks using ad blocking software. Would it cause a stir? Would people figure out that their ad blocker is to blame? Would […]

Detect bots and spammers with Project Honey Pot and PHP

Project Honey Pot is one of my favorite services. They offer an API that allows you to pull information on an IP address. This comes in very handy when vetting traffic coming to your website. I discovered the service a few years back after realizing that I had some spammers […]

How to convert a string to a time with PHP

Converting a string to a timestamp is one of my favorite things about PHP. In fact when trying to decide which language to build [HolidayAPI][holidayapi] in I couldn’t find an implementation of PHP’s strtotime() that rivaled the original. The strtotime() function takes a textual string as input and then spits […]

Set array pointer to a specific key or value in PHP

PHP arrays are absolutely fantastic. They hold stuff, doesn’t really matter what. The interfacing is pretty consistent and there’s a boat load of built-in array functions. What PHP lacks is the ability to set the array pointer to an arbitrary key or value. There are ways to move forward and […]

Basic page routing in PHP

Last week we talked about setting up a local development server with PHP’s built-in web server and I mentioned that we’d delve into page routing. Routing refers to taking the URI that a person was requested, let’s say /about and routing that to the appropriate code. Sure, you could just […]

Using PHP's built-in web server

I recently updated [HolidayAPI][holidayapi] to no longer use my PHP framework because I wanted the system to be easier for new developers to get up and running. Instead of including configuration files for Apache or nginx, I decided that I should just use the web server that’s baked right into […]

Outline numbering for an object tree

Last week I had talked about a layout dilemma that my buddy Justin was having. This reminded me of an issue that programming challenge he hit me with a few months prior. The challenge was to take an object tree and generate the proper outline numbering for it. The object […]

Layout with fixed header and independently scrolling columns

Update April 4th, 2019 Seems at some point between May of 2015 and now, the code in this post went terribly stale. It wasn’t working in either Firefox or Chrome and I’ve since updated the code with a working example. Many thanks to everybody that blew up my comments about […]

Working with Dynamic variable names a/k/a Variable variables in PHP

Variable variables are one of my favorite things about PHP. PHP allows you to use a variable to reference another variable. This comes in exceptionally handy when you need to create variable names dynamically: $variable = 'This is my variable'; $var = 'variable'; echo $$var; Let’s say you have you […]

Open Challenge: Learn Lisp with Me

Starting on May 1st, 2015, I am setting out to learn Lisp because I feel like I’m missing out by not knowing it. I see it come up pretty regularly, it’s stood the test of time and there are a plethora of dialects. I am going to target Common Lisp […]

Get all defined variables in PHP

I’ve never actually used this function, but could definitely see using it to help profile a system and/or to help identify defined but unused variables. To obtain an array of all of the defined variables you would: $defined = get_defined_vars(); The function returns a multi-dimensional array of all of the […]

Working with JSON in PHP

JSON is one of my favorite human readable formats. It’s widely used and has great support in PHP as well as other languages. PHP allows you to easily convert variables into JSON and JSON into objects or arrays. First, let’s take a look at how we can convert an array […]

Handling click and touch events on the same element

I’m starting to feel behind the curve. I started receiving feedback that some clickable elements on my social networks were not working on touch devices. Without much thought, I went ahead and added touchstart along side of click to bind both events: $(document).on('click touchstart', '.feeny', function(e) { alert('Believe in yourselves. […]