About Georgie Casey

student. Google+

Android chown recursively

Stock Android chown in /system/bin/chown doesn’t support the recursive switch which I discovered when I was trying to manually change owners and groups on an app folder.
chown -R u0_a160:u0_a160 databases/
resulted in the error message No such user '-R'.

So you need to use Android Busybox chown:
busybox chown -R 10160:10160 databases/

Install Busybox first if you don’t have it, obviously. Note you need to use numeric UID/GIDs with busybox chown or you’ll get an unknown user error message. Find numeric owners and groups with the -n switch: busybox ls -l -n /data/data

Ross Ulbricht, alleged Silk Road founder, StoryCorps Interview with René Pinnell

Just got a copyright strike on my Youtube account from the ‘Ross Ulbricht Legal Defense Fund LLC’ for an interview he did with a friend that I reuploaded to my account.


Now I’ve a copyright strike and all my videos are limited to 15 minutes. Pretty fucking pissed because if they just sent me a message on Youtube I would have gladly taken it down. So out of spite, I’m reuploading here:

Download link, save link as: http://www.georgiecasey.com/wp-content/uploads/2014/02/Rene_Pinnell_-_StoryCorps_Interview_with_Rene_Pinnell_and_Ross_Ulbricht_H264_1080p.mp4

Forbes announce Ireland as best country for business – But it didn’t make the print magazine

There’s nothing Irish people like more than being told how great they are by outsiders and sure aren’t we the greatest little country on Earth to be sure. So the press release yesterday that Ireland topped the Forbes list of best countries to do business with was reprinted by nearly all of the national media and tweeted by so much of the Irish Twitterati that some had to filter it.

But Forbes must not have thought much of the list as it didn’t make their print edition! Maybe I’m mistaken but I downloaded the Dec 16th PDF and couldn’t find a reference to it anywhere. Download here yourself and have a look. Forbes seem to have a website with a combination of editorial pulled from their magazine and then random articles from contributors. Here’s an article that is in the Dec 16th issue. Note the ‘This story appears in the December 16, 2013 issue of Forbes.’ header at the top.

The Irish article doesn’t have this header. The quality of contributions that make the website but not the magazine is questionable. Here’s a website article claiming that the Third Space cafe in Smithfield is going to take down Starbucks.

So Forbes seems to be turning itself into a Buzzfeed style content farm. And one of the random stories that a writer might have made to hit his quota for the week has a whole nation patting itself on the back.

How to serve files with a simple and quick PHP BitTorrent tracker

I needed to share some raw video files with a friend lately so I uploaded 17GB of data to my webserver and sent them the HTTP link. Problem was the video files were scattered over several directories and the directory structure was important so the end user would have had to download each one individually if they didn’t have some sort of download manager to download all. I could have given them anonymous FTP access but the end user isn’t that technical so I had to keep it as simple as possible. I could have zipped up the files on the server but that was taking ages for 17GB and would be a disaster if somehow the big ZIP file corrupted.

So I decided to make a torrent of the data. The great thing about torrents is nearly everybody knows how to use them no matter how technophobic they are as they all want to download Game of Thrones every Monday morning. I already have rtorrent and mktorrent on my Linux server so I already had a way to seed and a way to create the actual torrent files. I was just missing a tracker. I wanted the quickest and simplest option, and I found it in Bitstorm via an article on TorrentFreak.

You can download BitStorm’s one file of PHP source here.

1) Save as ui.php and upload to your web server to a publicly accessible folder. So your URL should be something like http://www.georgiecasey.com:80/ui.php
Notice the port number of 80, the standard HTTP port. You need to specify this in your torrent files as a BitTorrent tracker can be on any port and won’t default to 80.
2) Change permissions so script has write access to /dev/shm/ to track peers. So chmod 0755 ui.php or something like that.
3) Create the torrent file of the folders you want to transfer with mktorrent and the announce URL of your ui.php file. eg mktorrent --announce=http://www.georgiecasey.com:80/ui.php folder_of_files/
4) Start a rtorrent instance where your folder_of_files is and add your new torrent. It should do a hash check and start seeding. It’s best to open rtorrent in a screen so you can leave it running.
5) Send the torrent to whoever you want to download the files.

Damn, it feels weird using BitTorrent in legal ways!

How to disable Clickberry appearing on your Youtube videos

Like me, have you suddenly started seeing a ‘tag’ feature on your Youtube videos, that when clicked show a ‘Share moment’ and ‘Share object’ option and a little icon of a berry appears on your Youtube play bar? And when you click this berry icon, it brings you to clickberry.tv? Looks like this:



When Clicked

When Clicked

I thought the tag thing was a new feature of Youtube along with the Google+ comments but it’s actually added by a Chrome extension gone rogue called ‘FVD Video Downloader‘. You might remember that extension asking for more permissions in the last few days. Just uninstall and Clickberry will be gone from your Youtube.

How to use Overplay and other VPNs as a cURL proxy

Proxies are like hard drive space, you can never have enough. Or enough IPs to be more accurate as Facebook, Google and other services are getting better at flagging the IPs of popular HTTP/SOCKS5 proxies. So we need to find fresh proxies to use in our PHP/Python scripts. A great source is the proliferation of VPN services that are popping up as consumers worry more about their Internet privacy. Problem is these are intended for use by endusers on their desktops and not in serverside PHP scripts. So it’s a bit tricky to get these working with cURL, but fear not, I explain all in this post.

The magic of being able to use a VPN in cURL is the CURLOPT_INTERFACE option. This lets you set the network interface that cURL uses. You can’t use a VPN directly in cURL as cURL/PHP operates on a higher network level than the VPN protocol.

So we need to setup the VPN on a new interface. Note that you absolutely need root access to your server to create interfaces so this guide is only useful for people with their own dedicated servers. People on shared $2/month servers are shit out of luck. You might get it working on a VPS, I’ve no idea. So to create an interface, you need to download and install OpenVPN if you haven’t it installed already. There’s loads of info online to help you do this, so figure it out and come back.

Next we need to get the configuration files we need from our VPN provider of choice. I use Overplay.net. You need an account with them and it cost something like $5 a month. Download the ZIP file of connection files and unzip on your server in a new directory. Also download the Overplay public key certificate and make sure it’s in the same directory:
curl --insecure -o connections.zip https://patch.oppatch.com/connections.zip
unzip -u connections.zip
curl --insecure -o OverplayCert.crt https://patch.oppatch.com/OverplayCert.crt

Now we have the connection files which work fine if you run Linux as your desktop OS and just want to browse the web as described in this Overplay guide. But we DO NOT want to just start the VPNs as is as it will take over the main Internet connection and make your server inaccesible. I did this a few times and had to get my host to reboot my server.

So we need to edit the configuration files and add one command, route-nopull. This prevents Overplay from taking over the routing information. If you take one thing away from this blogpost, it’s the addition of the route-nopull option as it’s what lets you use these config files on your server.

I also want to add my login as a file so I don’t have type it everytime. So create a new file in the same directory and name it ‘auth_overplay’ or whatever you want. Enter your username and password, seperated by a newline. So if we’re taking the ‘Overplay – Ireland-1.conf’ file as our example, our config would now look like this. Our additions are in bold at the bottom:
dev tun
proto udp
remote 1443

resolv-retry infinite
ca OverplayCert.crt
verb 5
route-method exe
route-delay 2

tun-mtu 1500
tun-mtu-extra 32
mssfix 1450

auth-user-pass auth_overplay

Note we also added daemon at the end, but commented it out. You can uncomment this when you’ve got everything working and want to start the VPN as a daemon so you can use it without having to have the SSH window open.

Now start up the VPN with OpenVPN:
openvpn "Overplay - Ireland-1.conf"

If everything works, you should see output like this:
Fri Jul 26 21:05:13 2013 us=31236 OpenVPN 2.1.3 x86_64-pc-linux-gnu [SSL] [LZO2] [EPOLL] [PKCS11] [MH] [PF_INET6] [eurephia] built on Feb 21 2012
Fri Jul 26 21:05:13 2013 us=31325 WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info.
Fri Jul 26 21:05:13 2013 us=31331 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
Fri Jul 26 21:05:13 2013 us=31678 LZO compression initialized
Fri Jul 26 21:05:13 2013 us=31725 Control Channel MTU parms [ L:1574 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Jul 26 21:05:13 2013 us=31748 Socket Buffers: R=[124928->131072] S=[124928->131072]
Fri Jul 26 21:05:13 2013 us=31766 Data Channel MTU parms [ L:1574 D:1450 EF:42 EB:135 ET:32 EL:0 AF:3/1 ]
Fri Jul 26 21:05:13 2013 us=31777 Local Options String: 'V4,dev-type tun,link-mtu 1574,tun-mtu 1532,proto UDPv4,comp-lzo,cipher BF-CBC,auth SHA1,keysize 128,key-method 2,tls-client'
Fri Jul 26 21:05:13 2013 us=31781 Expected Remote Options String: 'V4,dev-type tun,link-mtu 1574,tun-mtu 1532,proto UDPv4,comp-lzo,cipher BF-CBC,auth SHA1,keysize 128,key-method 2,tls-server'
Fri Jul 26 21:05:13 2013 us=31794 Local Options hash (VER=V4): 'd3a7571a'
Fri Jul 26 21:05:13 2013 us=31802 Expected Remote Options hash (VER=V4): '5b1533a2'
Fri Jul 26 21:05:13 2013 us=31811 UDPv4 link local: [undef]
Fri Jul 26 21:05:13 2013 us=31816 UDPv4 link remote: [AF_INET]
WRFri Jul 26 21:05:13 2013 us=37221 TLS: Initial packet from [AF_INET], sid=a552afa0 928c908a
WFri Jul 26 21:05:13 2013 us=37266 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
Fri Jul 26 21:05:13 2013 us=72206 VERIFY OK: depth=0, /C=US/ST=IL/L=Chicago/O=OVERPLAY.NET_LLP/OU=SERVERS/CN=vpn1-us/emailAddress=ca@overplay.net
WRWRWRWRWWRRWWWWRRRRWRWRFri Jul 26 21:05:13 2013 us=472472 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Fri Jul 26 21:05:13 2013 us=472487 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Fri Jul 26 21:05:13 2013 us=472528 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Fri Jul 26 21:05:13 2013 us=472534 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
WFri Jul 26 21:05:13 2013 us=472560 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 1024 bit RSA
Fri Jul 26 21:05:13 2013 us=472576 [vpn1-us] Peer Connection Initiated with [AF_INET]
Fri Jul 26 21:05:15 2013 us=598837 SENT CONTROL [vpn1-us]: 'PUSH_REQUEST' (status=1)
WRRWRWRFri Jul 26 21:05:15 2013 us=604235 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1,dhcp-option DNS,route,topology net30,ping 10,ping-restart 120,ifconfig'
Fri Jul 26 21:05:15 2013 us=604257 Options error: option 'redirect-gateway' cannot be used in this context
Fri Jul 26 21:05:15 2013 us=604275 Options error: option 'route' cannot be used in this context
Fri Jul 26 21:05:15 2013 us=604293 OPTIONS IMPORT: timers and/or timeouts modified
Fri Jul 26 21:05:15 2013 us=604297 OPTIONS IMPORT: --ifconfig/up options modified
Fri Jul 26 21:05:15 2013 us=604301 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Fri Jul 26 21:05:15 2013 us=604472 TUN/TAP device tun0 opened
Fri Jul 26 21:05:15 2013 us=604485 TUN/TAP TX queue length set to 100
Fri Jul 26 21:05:15 2013 us=604507 /sbin/ifconfig tun0 pointopoint mtu 1500
WFri Jul 26 21:05:17 2013 us=671302 Initialization Sequence Completed

Now open a new SSH session as root and enter ifconfig to see the list of network interfaces. You should see your proxy listed with the interface name tun0 or something like that.

Some OverPlay servers don’t complete the TLS handshake for me but I’m thinking that was because they were old IPs. Overplay seems to change actual proxy servers a lot.

If you see the tun0 interface in ifconfig, then it worked, probably. Test it with cURL on the command line:
curl --interface tun0 http://icanhazip.com

Replace tun0 with whatever your interface is called. icanhazip.com is a simple site that outputs your IP and nothing else and has been online for 3 years so hopefully it stays online. If everything works, the site should output the IP of Overplays proxy and not your server IP.

To use the interface in your PHP scripts, you’d set it with something like this:
curl_setopt($curlh, CURLOPT_INTERFACE, "tun0");

I found from experience that PHP/cURL defaults to using the standard network interface if something doesn’t work, so it grabs pages using your real IP! This can be a disaster if you’re doing dodgy stuff and don’t want to get banned from FB or Google. For this reason, I always grab icanhazip.com in my scripts and check to make sure it’s not my server IP.

Well that’s about it. I also wrote a few PHP scripts that automatically download the Overplay config files, edit them, check what country the IP is and add them to a MySQL table. Then I’ve other PHP code that just queries the table grabbing a random proxy from the country I need. I’ll do a blogpost and share that code if anyone actually reads this one and comments. And also comment if you run into any trouble, I’m usually quick to answer.

iMessage is a handy way to show people you’ve the money for an iPhone

Tulsi Ennis & Golden Mill Ennis Menus

Right, bit of a random post but there’s two good takeaways in Ennis, County Clare that don’t have their menu anywhere on the Intertubes. I tried uploading a photo of the takeaway menus to Yelp but the image size was downsized so much the text was illegible. So I’m posting here. This is a personal blog, I can do what I like!

Click the images for the readable, full resolution versions.

Golden Mill Chinese

Tulsi Indian

MediaMonkey Setlist.fm Playlist Creator Script

I’m going to the Forbidden Fruit music festival this weekend and for all gigs I like to do ‘homework’ on the bands and what sets they’re likely to play. That sounds like working to have fun but concerts are always better when you know the songs!

MediaMonkey is my music player of choice; one of the reasons being its powerful scripting functionality. So creating playlists from setlist.fm got boring enough that I decided to hack together a MediaMonkey script, extension, addon, plugin or whatever you want to call it to do it for me. Luckily most of the work was done for me and I just had to adapt the Last.fm Loved Tracks Playlist Creator from psykar so 99% of the code is thanks to him.

Install the MMIP below and go to Tools -> Scripts -> Setlist FM Playlist Creator and enter a setlist URL like this one: http://www.setlist.fm/setlist/cut-copy/2011/the-button-factory-dublin-ireland-13d1b5a1.html. A playlist should be created in this format: [Setlist] ArtistName – CityName (EventDate). A message will pop up if some songs weren’t found. Future upgrades of the script might tell you what album these missing songs are on. Download the MMIP below:

Download MediaMonkey Setlist.fm Playlist Creator 1.0 MMIP

Make sure to have MediaMonkey running in administrator mode or you’ll get a “Product installation error”. For any other errors or feature requests, post as a comment below. If you like this script and it saves you time, please post a comment below telling me you use it. It’s disheartening to bother with something when you think nobody uses it!

Automatically generate Android boilerplate code from Layout XML

Java has a bit of a reputation for being too verbose which is a common stick for haters to beat it with. But as Bjarne Stroustrup says “There are only two kinds of languages: the ones people complain about and the ones nobody uses”.

But it’s a valid criticism so you want your IDE to generate the boring code for you which is where the Lazy Android Eclipse plugin from Ryan Mattison comes in. After you install it you right click on any Android Layout and select Fast Layout -> Generate Activity. It’s then supposed to write code into your class in focus but it only pastes to the clipboard for me where I can easily use in my activites of course.

So here’s my original layout XML:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      <RadioButton android:id="@+id/radio_car"
          android:text="Car" />
      <RadioButton android:id="@+id/radio_motorcycle"
          android:text="Motorcycle" />
      <RadioButton android:id="@+id/radio_truck"
          android:text="Truck" />
      <RadioButton android:id="@+id/radio_bus"
          android:text="Bus/Coach" />

And here’s the code it generated:

      private RadioGroup radio_type;
      private RadioButton radio_car;
      private RadioButton radio_motorcycle;
      private RadioButton radio_truck;
      private RadioButton radio_bus;
      radio_type = (RadioGroup) findViewById(R.id.radio_type);
      radio_car = (RadioButton) findViewById(R.id.radio_car);
      radio_motorcycle = (RadioButton) findViewById(R.id.radio_motorcycle);
      radio_truck = (RadioButton) findViewById(R.id.radio_truck);
      radio_bus = (RadioButton) findViewById(R.id.radio_bus);
      /* Please visit http://www.ryangmattison.com for updates */

Very handy. Get the plugin here.