Posts Categorized: Programming

Regular Expression to Match Credit Card Expiration Date

I needed to validate a credit card expiration date and this is the regular expression I cobbled together by looking at various sources. /^(0[1-9]|1[0-2])\/|\-?([0-9]{4}|[0-9]{2})$/ It’s nearly identical to a regex in this Stack Overflow discussion. All I did was make it work for 01-2020, as well as, 01/2020.

Customize Symfony Form Builder Error Message in Twig Template

I’m building a form to gather credit card information and I want to customize the error messages displayed on the form. I’m sure I can do this with form theming, and that’s great, but I just wanted a down and dirty, in the template, spitting out custom error messages solution. Of course, normally, I would… Read more »

PHP Soap Server Repeat the Same Element

In a SOAP service I work on, I needed to generate a response that repeated the same element. Something like this. <SOAP-ENV:Envelope xmlns:SOAP-ENV=”” xmlns:ns1=””> <SOAP-ENV:Body> <ns1:getPhoneNumbersResponse> <numbers> <number>123341344</number> <number>329822938</number> </numbers> </ns1:getPhoneNumbersResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Getting this to work in the PHP code took a bit of fussing around. You can’t just create a hash, because the… Read more »

How to Configure Redis to Automatically Start when Mac OSX Boots

I don’t like to remember to do stuff, because I invariably forget. I’ve recently started using Redis for a couple of projects and so I had to install it on my Mac for development. Here’s what I did to make Redis start on boot. I didn’t use homebrew to install Redis, I compiled version 3.2.0… Read more »

How to Make a SOAP Request with Node.js using raw XML

There are libraries out there that you can use to make SOAP requests from Node.js. But I really just wanted to throw raw XML at my SOAP service. None of the libraries seemed to be able to do that, so I’m using the Node.js http implementation. var http = require(‘http’); var http_options = { hostname:… Read more »

Debugging SOAP Service and WSDL with SOAP UI

If you’re like me and you spend a lot of time noodling around with SOAP web services, here’s tip for newbies. Veteran SOAP service developers already know this, but if you don’t, here’s a tip for debugging your SOAP calls and corresponding wsdl. Download SOAP UI and install it. Load your SOAP service and wsdl… Read more »

Symfony Doctrine Event Listener Silently Fails on instanceof

If you’ve ever done this in a Symfony doctrine event listener if ($entity instanceof User) { // Do something for this particular entity } you might have run across this annoyance. If you forgot to add a “use” statement for your “User” entity in your event listener class, this check will silently fail. I think… Read more »

How to Install Redis on Ubuntu

If you’re running Ubuntu, there’s a good chance the version of Redis available in the repo is pretty old. Here’s how you can install the latest version of Redis on your Ubuntu or Debian box – these instructions should work on any Linux server. On Debian or Ubuntu, make sure you have the ability to… Read more »

Get Rid of “Other” Data on Your Iphone Every Time You Backup

If you’re like me and you have a iPhone 5 with 8 gigs of data, you know what I’m talking about, fucking thing fills up with data quickly. What a lot of the “data” is, is something calling “other” data. Here’s how you can avoid never having to say, “My shit’s fully, I can’t take… Read more »