Canadian Postal Codes Database
I needed some data on Canadian Postal Codes for a project I'm working on. In context, I will have an user's postal code, but no way to validate it or use it as an index to get more location data. I started looking for free lists of Canadian postal codes I could merge in my application to achieve what I wanted. The first place I looked was obviously Canada Post, but it seems they're still in the mindset that selling public data is okay and only offer to license validation data... for 5,500$ a year. Mind you, it does seem include every Canadian addresses, not only postal code/city association.
Next in line was PopularData.com who offers a free database of 765,345 postal codes and their geographic data (city, province, latitude, longitude). Such data seems to be something recurring in various projects, so I figured I'd post here once and for all to tell you (and make sure I remember) how to get that data and inject it into a MySQL database on a remote server. Here goes.
Big Commerce API PHP Wrapper
Big Commerce is a hosted e-commerce platform. You are given FTP credentials to access the few static files you are allowed to manipulate... and you have an API. For various reasons, I had to interact with the Big Commerce API and since there was a serious lack of code (and decent documentation), I figured I'd put together my own little wrapper. Should be pretty self-explanatory if you're here. Needless to say, this code comes as-is with no support from me whatsoever.
Grey Hat Programming on Big Commerce
One of my clients has a website constituting of two platforms: WordPress and Big Commerce. I was mandated to, among other things, create a symbiosis between the two platforms so that users didn't have to register twice. The only problem with that is being a commercial platform, Big Commerce doesn't want you messing around in their proprietary database - their API really is only for read stuff, you never write anywhere. Understandable... but my client still wants user synchronicity, and to be honest I don't think he's exaggerating.
So... how do we remotely create users on a platform that doesn't let you create users with their API? After a bit of looking around for solution, I stumbled upon my client's store registration form (which is hosted, like everything related to Big Commerce, on a server you don't control). Different domains, different servers, no API methods... but I have a form. Have you ever heard of XSS? In the world of developers, it's a real annoyance. Essentially, if you fail to secure your forms properly, anyone can grab your form, put it somewhere else on the internet and submit bogus data (because the form still sends to you, get it?). Anyway, it's usually really only a security concern, but for this particular project, it became a feature.
OAuth, Timestamps and VPSes
During yesterday's #HackEmail, I was hacking away on a little Context.IO/Dropbox application to allow users to send files to their Dropbox by email. I only had a few hours to come up with a working prototype to have a shot at taking first place and the glorious iPad that came with it... however, I ran into a problem.
See, the OAuth protocol uses timestamps and nonces to validate requests. Should the timestamp of the requestee be negative or inferior to the timestamp of the requested, the request will fail and the whole OAuth workflow will fail, and chances are you'll have no goddamn clue why. Fear not! I experienced it, so I had to understand it.
Dynamic DNS Updater: dynDNS.Namecheap
I found out earlier this week that my favourite registrar, Namecheap, has a nifty little tool you can use to dynamically update the Namecheap-hosted domain A records. There's very little documentation available, despite the awesomeness and usefulness of such a tool, Namecheap doesn't really advertise it. The only piece of information related specifically to the dynamic DNS update manually is buried in Namecheap's knowledge base under "How to use the browser to dynamically update host's IP" and, after some Googling, a 5 years old non-exhaustive list of returned XML values on some obscure forum.
In order to ensure this works, however, there are a few dependencies:
- You need to have a domain registered with Namecheap;
- That domain needs to use Namecheap's nameservers (https://manage.www.namecheap.com/myaccount/modsingle.asp?domain=domain&type=backtous&rkey=NC);
- You must've enabled "Dynamic DNS" in your domain settings (https://manage.www.namecheap.com/myaccount/modsingle.asp?domain=domain&type=ddns&rkey=NC)
- This script is CLI-oriented, meaning it's meant to be executed via the command line. Regardless of your OS, you will need:
- php5-cli php5-curl;
- A working Internet connection;
That being said, it's relatively simple to understand. Most of the job is done server-side, so all you really need to do is hit a specific URL and let Namecheap do the rest:
https://dynamicdns.park-your-domain.com/update?host=&domain=&password=
Once you know that URL, it's pretty easy to implement something around it. Here's my little facilitator built in PHP:
Twitter Direct Messages Bulk Deleter
If you're a Twitter user and a organisation freak, you're certainly aware that Twitter doesn't give you the ability to bulk-delete direct messages. Back in the days, Damon Cortesi had built a nifty bookmarklet that allowed you to stick it to the man. Problem is, that bookmarklet is now deprecated, due to Twitter's change of layout - most of the stuff just doesn't work the way it used to, so the infamous DM Whacker was laid to rest.
Until I got really fucking tired of all the direct messages. Here's a reboot of Damon Cortesi's DM Whacker: DMDelete-v2.0. It's fast, uses Twitter-specific resources (such as their jQuery and dialogs), and is merciless. Give it a try, all you have to do is drag the link blow to your bookmark toolbar (or wherever you want really), go to your Twitter inbox and click it!
This is beta software! Feel free to relay any feedback you might have after using - it's rather challenging to thoroughly test this piece of code on my own, so there may be random hiccups.
