Monday, July 21, 2014

Tomorrowland - Practical Info

I've just gotten back from Tomorrowland 2014 (weekend 1) and just wanted to provide some practical info that was hard to obtain from the internet:
  • Transport:
    • When arriving in Boom by train you can get a free shuttle bus to either the main entrance or the Dreamville (campsite) entrance. These are on complete opposite ends of the festival area and are about an hour walk apart. It is also possible to enter Dreamville or Festival from a small road/path between the two, although this is not advertised and you can only get there by foot/bike.  
    • Although Belgian train operators SNCB advertizes how much they have tailored service to work with tomorrowland, effectively it is entirely useless if you want to go only one day or leave before Monday from the campground, unless you're going to antwerp. More concretely: There are no trains from Boom on Saturday/Sunday except three trains from midnight to around 2:30 am from Boom to Antwerp. But there are no trains from Antwerp to anywhere after midnight. So if you want to go to eg, Brussels, you're out of luck (you can wait in Antwerp until the first train around 6 am)
    • There are however trains from Mechelen until around 11:30pm. Although there is no real mention of this anywhere, there are free shuttle buses from near the main entrance to Mechelen on the weekend (other days I believe this shuttle only goes to Boom, because you can get the hourly train from there instead).
    • The other alternative if you want to go elsewhere in Belgium is to take a bus. If you're going for a single day, that's a good option. But you must reserve in advance online (22 euros with fees), and it sells out in advance. The problem if you're going multiple days is they won't let you go one day and return another, AND you cannot book one-way! What is possible though (at least if you're going to a big city) is to show up at the bus at Parking lot P8 near the main entrance and pay 25 euros for the one way return at night. It may be possible to book the day you leave and to just show up the day you want to return, with the bracelet they gave you, but I don't know if it will work.
    • There is no public transport between Dreamville and the Main entrance. You can walk from the dreamville exit nearest the festival to the main entrance in about a half hour via public roads in order to avoid carrying your bags through security at the Tomorrowland entrance gate.
    • I strongly suspect that you will find people/taxis willing to drive you from the Main entrance/exit of Dreamville to your destination of choice if leaving on sunday or monday. The same is true of the exit from Dreamville towards Tomorrowland, if you exit onto the roads.
  • It's really big and you'll be on your feet a lot. Bring comfortable shoes, which you don't mind getting dirty.
  • If you're wondering whether "Comfort"/VIP passes are worth it, then you should probably get them. The main advantage is shelter in case of rain/sun, seats for when you're tired, cleaner flush toilets, a little more space (in all cases, comfort areas are not the only alternatives, but often the best).  In some cases they can provide a good view, but usually similar views can be had for free. There are also some occasional perks like food or massages and hot tubs/pools but these are more rare and somewhat gimmicky and/or you probably won't want to use them because of who came before you. In my case it balanced out some fairly bare-bones camping.
  • Food
    • "Booze bags" provide no booze, but only tokens that are used to buy food and drinks at the festival; the exchange rate is the same as if you buy tokens at the festival (1 token = 2 euros; significant inflation from the reports I heard of past years). The only difference is you get a map/schedule and a bag (and the maps are freely available at the info/booths) with the "booze bag". It is somewhat convenient to get it at the entrance though, if you know you'll spend 50 euros.
    • When hearing people say how great the food is, keep in mind that it's a festival. It's half-decent, some of it is decent (if you pre-book the "gourmet" dinners which I didn't, it may even be "not bad"). But it's not great. And it's fairly expensive too. Frites which sell for 1.5-2 euros outside are 5 inside; a small slice of pizza is 6; decent burgers are 7 (crappy belgian plastic burgers are strangely 8); the best deal is the barbecue plate for 9 euros which comes with a chicken sandwich, salad and potato salad. Drinks run from 3 euros for a soda/small beer/water to around 10 for a cocktail, and hundreds for bottle service in VIP areas.
  • Housing/Camping
    • Unlike some major American festivals where nearly everyone is camping, only about 35,000 people camp here out of 180,000. This leads to a fairly major selection effect towards the young/low budget/low standards set. Nevertheless it can be fun if you are a heavy enough sleeper. There are also some pre-made/luxury (think african safari) campgrounds -- don't know anything about them.
    • As mentioned, Dreamville camping is a decent walk from the festival site; the exit of the normal Dreamville is about 15 minutes walk from the entrance to the festival (at stage 13, which is on the opposite end from the main entrance, near stage 1). Nonetheless, it's still the most convenient option for anybody staying all weekend, by a lot. Unless you can get a place in Boom, below.
    • If you're coming from out of town, the very best option would be to find somebody in Boom who is renting their apartment. It seems there are lots of these, maybe on airbnb. Alternatively if you really want the conveniences of home (ie, a hotel), look at Mechelen or Antwerp. Don't consider Brussels if you're staying for multiple festival days because transport stinks.
  • All the hard talk about how strict ticket/bracelet checks are is overblown. There is no time to check IDs for 180,000 people. Many people (eg, me) didn't even get their bracelet in time; we just brought our receipt and they gave us ours, no questions, no activation, no ID check. To be safe, bring a photocopy of the passport/belgian ID of the registered purchaser. At entrances you simply scan the bracelet by the sensors after passing security (it's probably RFID). That said, there are a lot of scam artists on the internet trying to sucker people into wiring them money for nothing ("tickets"); there was even a fake, scam Tomorrowland website last year. If you're in the area anyway and really want to go, it's probably worth showing up at the main gate to try to find a day pass to buy.
  • The stages are well decorated and have very impressive lighting and effects, this is one of the best things about this festival. Generally it is pretty creative for a very top-down festival and there are a few nice surprises. People are from really all over the world and very enthusiastic, which is fun.
  • For me, some electronic music is really great, but it often fails impress. Unfortunately I didn't know the artists well enough in advance to know what I really wanted to see and I found that many stages, a very heavy baseline substituted for what could be called "music". Later I realized, when I heard songs I recognized, that the bass was up so high that you simply couldn't hear the melody even when the songs were good and had interesting overtones beyond the bass. In other words, the sound balance was in general very poor, to the detriment of my and others I talked to's enjoyment.
  • Smaller stages both had better sound balance and often more interesting music, plus lots more space to dance. I found myself there more often and if I were to go back, I'd do more of that. Then again, I'm not into commercial electronic music in general so mostly the main stage is for the spectacle (although there may be some better artists there during the daytime).
Hope this helps somebody! Feel free to leave comments if you have more to add.

Wednesday, May 14, 2014

Tips for using an SSD under Linux

Solid state drives (SSDs) offer amazing performance, but do have one major limitation. There is a maximum limit to how many times it can be written to (or to think of it another way, that memory can be overwritten). Moreover, writes can be slowed when previously freed space has not been reclaimed by the SSD, because then this reclaiming needs to happen before the write can occur. TRIM commands from the operating system to the SSD allow the drive to do this in the background. Unfortunately this isn't as well integrated into the OS as under Windows.

To get all set up and optimize the life and performance of your SSD, I recommend the following steps:

1) Set your drive not to set access times on files (otherwise the inodes need to be written each time you do)
in /etc/fstab. Normally these are not needed and will save you from writing to the drive each and every time you read. To do this, add the noatime and nodiratime parameters to your SSD drive, eg:

UUID=xxxx-xxx-xxx-xxxx / ext4 noatime,nodiratime,errors=remount-ro  0  1

Note: DO NOT use the discard option, which is the original method of enabling TRIM support and which does not perform well, especially when deleting large numbers of large files (instead, use the userspace command fstrim, as below).
Finally, if you think you really need the access times, you can use the relatime setting instead of noatime -- it doesn't save as many writes, but still saves a lot (in fact this is usually now the default option).

2) To send TRIM commands to the HD, run the fstrim utility regularly to notify the SSD of newly freed space. Make a new file called fstrim in /etc/cron.daily, with the following contents:

#!/bin/sh
echo Running fstrim on SSD.
fstrim /

where the / should be the mount point of the SSD. Run chmod +x /etc/cron.daily/fstrim to make it executable. It will run automatically each day.

3) Don't use swap space on the SSD unless you need to. Using the SSD for swap space is way faster than a HDD, but swap is normally a heavy disk user, and we need to avoid unnecessary writes on an SSD. So what to do? Well, one, you might not need a swap if you have a lot of RAM and not so much demand. In my case I do need that extra memory occasionally, and it kind of does need to be SSD-fast. So what I ended up doing is telling Linux to only use the swap when absolutely necessary (eg, when it's running out of memory) -- by setting swappiness to a setting well-below the default; I chose 5, but something in the 0-10 range is probably good (0 tells linux to only use the swap when it is completely out of physical memory when it tries to allocate; higher may allow some degree of caching in swap space). To set swappiness, add this line in /etc/sysctl.conf and reboot:

# Change default swappiness (60) to reduce unnecessary writes to SSD swap
vm.swappiness = 5

4) Use ram disks for common temporary files to avoid unnecessary writes to disk. tmpfs will allocate space for ramdisks as-needed. I did this for 3 directories: /var, /var/tmp, and /var/spool, by emptying out those directories and placing the following lines in /etc/fstab:

# Use ramdisks for temp files to avoid excessive writes to SSD
tmpfs /tmp    tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/spool tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/tmp   tmpfs defaults,noatime,mode=1777 0 0

5) Change the I/O scheduler to DEADLINE for your SDD. The default is CFQ which is great for HDDs but overkill and slower for SDDs. For SDD, you don't really even need a scheduler, and could instead choose NOOP which is a simple first in first out scheduler, but DEADLINE is a little better, since for example it prioritizes reads over writes in the queue, ensuring decent read responsiveness even under heavy writes. Put the following lines (after modifying to match your drive locations sda/sdb/etc) in your /etc/rc.login so they run every bootup.

# use deadline scheduler for SDDs (and CFQ for HDDs)
echo deadline > /sys/block/sda/queue/scheduler


5) Finally, you can move caches for your commonly used programs (especially the web browser) off of the SSD. These write a lot to disk, and are already well optimized to work with a hard drive (HDD). If you also have an HDD, you can redirect the .cache directory under your home onto that HDD. Since cache is already optimized for hard drives, it shouldn't negatively impact performance unduly. (Alternatively you could do something similar for just the browser cache(s) using tmpfs, although the cache will be lost each reboot). First, close any programs that may be using the cache (or better, login at the terminal) Then run these commands to create a symbolic link:

cd /myHDDmountpt
mkdir .cache
cp -R ~/.cache .cache
cd
rm -Rf .cache
ln -s /myHDDmountpt/.cache .

Hopefully these tips will help your SSD live long and perform well. Let me know in the comments if you know any other good tricks!

Thursday, April 17, 2014

ICPSR Congressional Member IDs in Python

Keith Poole and Howard Rosenthal have put together the authoritative list of Congressmen's member IDs, which they make available here at voteview.com.

To make using it from python a bit easier, I wrote a simple file to read in the files, as well as to map parties and state IDs to names. I provide it below in case it proves useful to others!


Note that the script includes python-usable versions of: mappings from ICPSR state IDs to state abbreviations and state names, AND mappings from Political Party IDs to Party Names, which may be useful in their own right.

Edit: Updated link to a new host.

Wednesday, April 16, 2014

Fox stop words list

In the process of doing some NLP work, I needed a specific english-language stop-word list, that developed in Fox, Christopher. "A stop list for general text." ACM SIGIR Forum. Vol. 24. No. 1-2. ACM, 1989.

Unfortunately I couldn't find it on the web in usable form. So I created it based upon a PDF of the paper. And here it is:

This is a stop list including 421 "words" (including all the letters and a couple other non-words).

You may also be interested that there is a more basic stop list with 127 words provided in python's nltk:
from nltk.corpus import stopwords
stopwords.words('english')

Finally, there is a project providing more extensive stop word lists in 29 languages. In case google code goes down, the latest collection is here.

P.S. Stop words are "insignificant" words that are typically removed before certain types of textual processing.

Edit: Updated the links to point to a new host as the last host deleted them.

Sunday, March 16, 2014

Cyanogenmod 11.0 (KitKat 4.4) on Samsung S3 Mini

Maclaw & Marcin have done a lot of good, hard work to port cyanogenmod (CM) to the ARM processor used by my phone, the Samsung SIII Mini (GT-8190N). I'm not deep into the whole android scene, but from what I gather, cyanogenmod is basically a modified and enhanced version of the core open source android software which is released by Google. It keeps up to date (meaning I was able to install the latest version -- Kit Kat), and replaces some proprietary software provided by Samsung that was less than optimal (in particular the Radio Interface Layer [RIL] which was been shown to have a pretty major backdoor).  The main downside on my phone is that there is no Near Field Communication (NFC) support, something my version of the S3 Mini does have; however I don't currently anticipate using it so no biggie.

CM also adds "privacy guard" which allows the user to control permissions on a per-app basis (ie, one can choose to not allow Facebook to access ones contacts or location, while still allowing google maps to). I find it very troubling that Google did not include this in the first place (in fact, the software exists and was removed by Google when kit kat was released). I understand that Google's value-add is to piece together many bits of information about users and the world as possible. But users should have a say in this as well, not to mention that even if users trust google with this information, it doesn't mean they trust all app developers, even if they still want to use their apps!

Anyway, I found it worth using, and so this post is about how to install CM on the GT-8190(n).

0) Backup your apps using Titanium Backup, and other things (contacts, SMS, call logs, etc.) using Super Backup. Titanium backup will need developer options/USB debugging enabled: Go to Settings->About phone. Tap on Build settings 7 times. Then return to settings, go to the new Developer options menu and select to allow debugging. The non-obvious trick with Titanium is that you can do "batch actions" by using the menu button on bottom left, this allows you to backup all apps+data, eg. These should be on your external SD card and, to be safe, also your PC. Also enable Google storage of app settings from within your phone's Settings->Backup & Reset. Save any photos on internal storage to your computer. Finally, save the Launcher's layout (in Nova, use Nova Settings to save to SD card), and backup app settings to SD card (in my case, K9, DoggCatcher and iNotes definitely need backup if not using Titanium, and they may need to be moved to the SD card).
1) Make sure you have samsung's USB drivers installed
2) Get Odin_golden from Novafusion.pl's downloads; unzip it.
3) Go to Maclaw's download page and get the latest nightly build of CM [Select the ODIN link next to the download -- you should get a .ODIN_TWRP.zip file!], after verifying that it appears to be stable by reading the comments. The release notes always say it is stable, which is something of a running joke. It is changing constantly, and mostly getting better, but sometimes things break that you need, so it's best to check first. Then unzip the file to a temporary directory. Get the latest Google apps .zip from here, choosing the package you want (I use "full"), and copy that zip to the SD card on the phone. You may want to de-select some of the apps in the package you selected, by creating a gapps-config.txt file in the same directory as the .zip on the SD card, listing the apps you don't want (with no spaces in the names) one per line. To be sure of their names, you can install it once and have a look at the pa_gapps_log.txt file that is created (then rinse and repeat). Disconnect the phone from the PC.
4) Run Odin from the directory you unzipped it to; click PDA and find the .tar.md5 file you just created. It should verify the hash code. Now power off your phone. At this point, press and hold the HOME, VOLUME DOWN, and POWER buttons until you get a warning screen.  Plug it into your computer and press volume up to continue. At this point ODIN should recognize the phone and you can begin the flash process by pressing Start.
5) Once complete, the phone will reboot. When you see the samsung logo, Press and hold the HOME, VOLUME UP, and POWER buttons. The Samsung welcome screen will flash twice and you finally come to the blue teamwin TWRP recovery screen
6) If this is the first time you've installed this version of CM (eg, 11.0), then do a complete wipe of the phone; it is worth changing the file system for cache and data to f2fs when you do this, by selecting advanced wipe->change filesystem. Otherwise, you shouldn't need to wipe unless something strange has changed between versions; however to be safe you could wipe "Dalvik cache" and "cache" after the next step (7).
7) Next, still in TWRP recovery, install app, and select the google apps zip you put on the SD card. Finally, reboot.
8) Now you should be back to your phone. It's time to get it working again. First, enable your google account in Settings->Backup & Reset; in order for it to have an effect, it must be enabled before you install apps (if you did a complete wipe, you can instead do this during the setup process at first startup). Next, use Google Play to install Titanium backup and set the backup location to point to your ext. SD card. Batch action to restore apps with data (then all the configurations you had before for those apps will be magically restored). Don't forget to restore Super Backup and restore contacts/SMS/call logs.
8b) If not using titanium,or if you didn't do a complete wipe, you may also need to restore many apps' settings - at least Nova desktop, K9, DoggCatcher, iNotes in my case.
9) To use the FM radio, install the app Spirit FM (download the free version from here) if you haven't previously, as the samsung radio app will be missing.
10) It may be advisable to update the baseband from samsung as well; for GT-8190N they are available here and can be installed using TWRP- copy the zip to the phone, and select install from TWRP, then reboot twice; this may improve radio performance and possibly also battery life. At one point my phone was rebooting during phone calls, and this fixed it.

You should be up and running. Enjoy your faster, safer, cleaner phone!


Edit: Revised to use titanium backup and the latest google apps package as of Feb, 2015.