How to scrape a photo from a Twitter Photo URL using PHP
After explaining how to scrape a photo from a Twitter Photo URL using C# (ASP.Net) I decided to port the script PHP so I could use it on WordPress. I ended up using CURL and a regular expression to do the trick.
A (slightly) better WebClient class supporting cookies and headers
Sometimes you’ll need a (slightly) better C# WebClient that’s able to store/retrieve cookies, prevent redirects or retrieve the HttpStatusCode of a request. I’ve created a small class that facilitates these features.
How to scrape a photo from a Twitter Photo URL with C#
Twitter uses its url shortener to place photo’s in Tweets. I’ve tried processing these URLs in the browser, but cross site scripting measures prevented me from processing the result with jQuery.
I decided to resolve it in C# (as I’m using ASP.Net). The following script leverages a WebClient and a regular expression to extract the photo URL from the shortened URL. This code could be added to a handler or a webservice that can be called from script.
Usually a browser restricts the number of simultaneous connections to a single domain (depending on the browser 2-8 connections). That’s why Yahoo recommends to use a Content Delivery Network (CDN) to decrease the number of connections to the same domain. Lately I’ve been experimenting with…
Using Chrome’s XPath with jQuery
While working with the Chrome Developer Tool, I’ve discovered that you can retrieve the XPath of a selected node. But… it only works in Chrome. So what about other browsers? What about jQuery? What about querying documents that resulted from an AJAX request?
Create mp3 playlist with PowerShell
Playlist are a dandy way of organizing the files into one list (easy to find on your device). The m3u playlist format is a no-hassle straight forward format, that’s why I love it. It is basically a list of relative file paths. Well… if it is that simple, it should be easy to write into a PowerShell statement.
Comparing files with PowerShell
Sometimes you want to test if two files are the same. You could run MD5 or SHA hashes of the files, but it might take some time to compute them. A byte by byte comparison might be the faster instead. I’ve wrote a script doing it in PowerShell.