The more innovative – the more breaking-the-mold – the innovation is, the less likely we are to figure out what it is really going to be used for.
Here’s a typical regex scenario: You’ve got a string in which you need to find/capture the HTML tags from. Let’s say our string is:
This is a <em>first</em> test
Typically, you’d write a regular expression to capture the tag by writing this:
var re = new RegExp("<(.+)>", "");
Unexpectedly, however, the result you’re going to get matched back is:
The reason for this is explained on the Regex Tutorial website:
The first token in the regex is . You should see the problem by now. The dot matches the >, and the engine continues repeating the dot. The dot will match all remaining characters in the string. The dot fails when the engine has reached the void after the end of the string. Only at this point does the regex engine continue with the next token: >.
What we need to do instead is force the dot character to be lazy by adding a question mark after the plus sign (or a star, or numbers in curly braces):
var re = new RegExp("<(.+?)>", "");
This time, we’ll get back:
The Budweiser Red Light is one of the best pieces of marketing I’ve ever seen. And while I’m enough of a hockey fan to want to pick up one of these anyways, the real prize is in figuring out how to make the thing go off whenever I choose.
Where to get started? While I’ve seen an attempt to use/modify the Electric Imp card inside the light to accept requests, I thought my approach might be simpler: Sniff the network traffic to and from the light, replicate it to sound the alarm.
The instruments used to sniff the traffic were as follows:
I kept careful notes in case someone else wanted to replicate this experiment; those instructions are:
So we’ve got an example of the data used to set off the Red Light, but we don’t really know what’s contained in that data.
Deep packet inspection isn’t really my thing, so at this point I’ve started asking around for possibilities. Here are the early contenders:
If you’d like to help out, you certainly can! I’ve uploaded a zipfile of a PCAP file containing the packet I’ve displayed above. Feel free to try and dicipher or replay sending of that packet on your own! Please leave a comment if you do so; it’d be great to solve this for everyone.
We’ve got some pretty large CSS files to work with on a few projects I work on, and use SCSS plus the Compass tool to make management of the styles a bit easier. Recently, though, Compass has been throwing us this error:
error scss/sportsnet.scss (Line 969 of scss/_inc-controls.scss: Invalid UTF-8 character "\xCA")
The root cause appears to be non-ASCII characters in a SCSS file. That’s easy enough to root out by hand if the file is a manageable size, but if you need an automated filter instead, try the following:
iconv -t ASCII//IGNORE -f UTF8 < _inc-controls.scss > _inc-controls.ascii
This pipes the offending SCSS file through iconv, and spits out the file _inc-controls.ascii which should contain differing lines where non-ASCII lines are found.
If you’ve ever tried to do a git pull to get a branch up to date and have run into conflicts that you just want to bypass and go with the contents of the remote branch, do the following:
# Fetch from the default remote of origin. git fetch origin # Check out the branch you want to override the conflicts upon. git checkout master # Reset your current branch of master to origin's master. git reset --hard origin/master
It’s sometimes useful to know exactly what files you’ve made changes to in your feature branch as you’re getting ready to merge back into your trunk code. Git’s diff option allows for this to be done quick easily:
git diff --name-status master..newfeature
The output looks like the following:
M .gitmodules A plugins/backplane.php A plugins/multiple-post-thumbnails M themes/sportsnet/css/scss/_inc-controls.scss M themes/sportsnet/functions.php M themes/sportsnet/header.php M themes/sportsnet/single-sn-article.php M themes/sportsnet/single-sn-blog-entry.php M themes/sportsnet/single-sn-signing.php M themes/sportsnet/single-sn-trade.php A themes/sportsnet/zones/articles-comment-form.php A themes/sportsnet/zones/global/user-account-links.php (END)
I’ve been increasing the amount of click tracking I do via Google Analytics, but getting the data back out of that system can be a bit of a time when you’re talking large amounts of data.
Enter Download Analytics, which will ask for input of a URL to the report page you’re viewing, and will automatically prompt to e-mail you (when ready) a link that will allow you to download the entire list of rows in your report. Simple, fast, effective.
Like many others, my employer makes heavy use of Microsoft’s Exchange system to run its corporate e-mail infrastructure. And for the most part I think highly of that collection of software and services: Microsoft Outlook and the Exchange system that runs behind it are full-featured and generally terrific. Unfortunately, its Web-based offering is pretty lame in comparison, and is generally set up on hardware that strains to keep up with the amount of use that it faces.
I’ve always liked Mozilla’s free Thunderbird e-mail client, and have tried in various ways to get it to pull down e-mail from Outlook Web Access (OWA) without success. Having finally sat down and considered the problem carefully, I’ve hit on success. The key is an amazing little piece of free software called DavMail Gateway, which installs on your local system and acts as a translator between your e-mail client and the remote OWA server. For posterity, I thought I’d capture how my setup works.
This involves sending some custom headers along with your HTTP GET request, so utilize either the wget command line tool:
wget -S -O /dev/null --header="Pragma: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-extracted-values, akamai-x-get-nonces, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-serial-no" http://www.sportsnet.ca/
Or the curl command line tool:
curl -H "Pragma: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-extracted-values, akamai-x-get-nonces, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-serial-no" -IXGET http://www.sportsnet.ca/
The X-Cache-Key setting will contain the amount of time the URL is cached for; in this example, the time is 1 minute (“1m”):
Running Windows? No problem – grab a compiled version of wget for Windows.