Page 3 of Software Development Articles

URL routing in PHP

The other day I was checking out what folks are querying to get to my site. Of course a ton of people get here looking for VPS comparison, but what surprised me was the volume of queries for “PHP routing”. Back in 2015 I had posted a basic page rounding […]

PHPUnit with multiple versions of PHP and HHVM on Travis CI

Recently I was updating my PHP Lorem Ipsum library in an attempt to get it testing on HHVM on Travis CI alongside the other versions of PHP I was testing against. Incidentally, the last time I had worked on the project, I had to work out some kinks with older […]

Days until Christmas in JavaScript

Time again for one of my holiday cop out posts :) Here’s a couple of ways to calculate the number of days until Christmas: Vanilla JavaScript Math.floor((+new Date('2018-12-25') - +new Date()) / 86400000) Using momentjs moment('2018-12-25').diff(moment(), 'days') Merry Christmas! […]

Adding comments to JSON

From time to time I’ve wanted to be able to comment out lines in a JSON file. This typically comes up when I’m making a butt load of changes to package.json and I want to keep a visual history as I’m tweaking things. Just last week, it came up with […]

Configuring Jest to show code coverage for all of your files

Jest is a great tool. It’s fast, actively maintained and has been working well for us with both our front-end and back-end systems. Simply put, Jest helps us make CrowdSync better and more stable. Out of the box though, code coverage is only shown for the files that you’ve written […]

Setting defaults for all your SuperAgent requests

SuperAgent is an HTTP request library for both Node.js and client-side JavaScript. It’s our current choice here at CrowdSync for making requests because it’s lightweight and easy to use. Unfortunately, out of the box, it doesn’t support setting defaults on all of your requests. The simplest approach would be to […]

Simple cache busting with Webpack

Here at CrowdSync, we’re huge fans of CloudFlare. As customers, we are leveraging the power of CloudFlare’s caching mechanisms. Part of our deployment process to production involving flushing the cache via the CloudFlare API. Problem there is that only solves half of the caching dilemma. Even with our CloudFlare cache […]

Stop over configuring Vim

Over the year, I’ve waxed and waned with the size of my .vimrc. In the early days, it was trim but so was my knowledge of Vim. Once I learned how to disable my arrow keys, I started to configure more and more. It wasn’t until I fully understood the […]

React Draft Wysiwyg with MongoDB

We love open source software here at CrowdSync. Sometimes though, we run into issues with the software we’ve deemed as the “right” package for us. A recent incident has been with React Draft Wysiwyg which we decided to use as part of our action to compose and send emails to […]

reCAPTCHA is broken

In the words of the Security Level setting for CloudFlare’s Firewall: I’m Under Attack! As it turns out, I’m not a stranger to having bots on my social network, Ginpop.com. I’ve even documented my previous experience with a DDoS attack and how to mitigate a WordPress Pingback attack! This particular […]

How to calculate Mother’s Day in JavaScript

One of my favorite features of PHP is the strtotime function. It takes a string and gives you the equivalent time in return. Unfortunately, there’s not something similar for other languages. There are other ATTEMPTS to duplicate the function, but nothing I’ve ran into that works quite as well. With […]

Vertical alignment is a waste of time

As I’ve gotten older, code formatting has become less and less important to me. When I was younger, it was the world, but as of late, it’s a nice to have. What’s truly important to me is whether or not anybody is using the things I’ve built. I’m still fairly […]

Reading a specific line from a file with PHP

As I’ve been building a system that is driven primarily by CSV files (because it’s easier to use Google Sheets than it is to build out an admin section) I’ve had to get creative. Recently I found myself working with a CSV file that’s around of 3000 lines of data […]

Convert Mongo BSONDocument to an array in PHP

Ran into a scenario this weekend where I needed to take a sub-document from Mongo but I needed it in an array in PHP. Reading the data from Mongo with PHP was simple and won’t be discussed. What I’d like to talk about is taking the BSONDocument that Mongo returns […]

Programming the same thing in multiple programming languages

Recently I set out on an interesting journey. I wanted to build programming libraries for my API, HolidayAPI. Some of the languages I know like the back of my hand. Others, have never even touched them before. Before you start sending me hate comment, I am fully aware of Swagger. […]

Sourcing external files from your .gitconfig

If you’re like me, there’s a great chance that you have not only some public dotfiles but you also have some private stuff you don’t want the world to have open access to. I refer to these private dotfiles simple as dotprivate. I include my dotprivate files as a submodule […]

Set Vim tab spacing based on the type of file

Now that my buddy Justin is back to using vim, he’s been flooding me with questions. Loljk, but he did ask about setting the tab spacing based on the type of file he was working with. Incidentally, this was something I had just improved in my dotfiles. Back before I […]

Get the day of the week from a date in PHP

Typical of PHP, it’s very easy to get the day of the week from a date, but they also provide the data in multiple format. Three in fact. The first, and arguably the most straight forward is to get the textual name of the day of the week. <?php echo […]

Calculate time left in day in PHP

Before PHP 5.3, finding the difference between two dates was a bit of a pain. Convert the date strings to UNIX timestamps (if they weren’t already), subtract them, and then divide the result until you had each of the components (seconds, minutes, et cetera). As of PHP 5.3+ you can […]

Make open source contributions a priority

I get it, you got a metric shit ton of stuff going on at work and open source contributions aren’t necessarily one of them. Bet there’s a good chance you have at least one side project though. Also bet there’s a good chance that you don’t make open source contributions […]

How to calculate Easter Sunday in Javascript

Regardless of your religious beliefs, you are probably aware that Easter Sunday occurs on a sliding scale. This is because Easter is a moveable feast and the date is determined by a lunisolar calendar. Originally I was planning to talk about how to calculate the date of Easter in Javascript. […]

How to capitalize the first character of each word in a string in Javascript

The other day I had posted on capitalizing the first letter of a string in JavaScript. But what if you wanted to capitalize the first letter of every word? With PHP it’s just a simple call to ucwords and just as easy in Ruby and Python. To be able to […]

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 […]