Slow ipython in osx yosemite?

Seems AppNap puts ipython to sleep, try this to disable it:

defaults write org.python.python NSAppSleepDisabled -bool YES

Zero to One – Peter Thiel & Blake Masters




Brief chapter overviews:
















Book Notes

Error installing python module that uses pbr

If you get the following error when running python install:

error in setup command: Error parsing somemodule/setup.cfg: OSError: [Errno 2] No such file or directory

It is because git is not installed. On debian apt-get install git-core and you should be all set.

Finding Apache Average Memory Usage on Debian Wheezy

I wanted to find the average process memory usage on Debian wheezy to calculate MaxClients.

I used this script to do it:

sudo ps -ef | grep apache2 | grep -v ^$USER | awk '{ print $2 '} | xargs sudo pmap -d | grep ^mapped: | awk '{ print $4 }' | cut -dK -f1 | awk '{SUM += $1} END { print SUM/NR }'

Quick explanation, starts out with a process list, filters for apache2, removes the grep command from the list, prints the second column, uses pmap to display memory usage, then grep to filter out the mapped memory. Again printing the fourth column, then using cut to remove the K, and awk to sum up the records. NR in awk is the number of input records seen so far.

To get MaxClients divide your total memory (minus some margin for other system processes) by the average process memory usage to get the number for MaxClients.

Example, 50K process size, memory of 1.8G, 1.8G/50K = 36

Note you shouldn’t use the ps VSZ as it includes shared memory.

Install Postgresql 9.2 on Debian Squeeze

I was getting the following errors because the squeeze packages are too old for 9.2:

The following packages have unmet dependencies:
 postgresql-9.1 : Depends: libpq5 (>= 9.1~) but 8.4.13-0squeeze1 is to be installed
                  Depends: postgresql-client-9.1 but it is not going to be installed
                  Depends: postgresql-common (>= 115~) but 113+squeeze1 is to be installed

These are the steps I took to get postgresql 9.2 running on debian squeeze:

Add backports to /etc/apt/sources.list:

deb squeeze-backports main
sudo apt-get update
sudo apt-get -t squeeze-backports install libpq5 postgresql-common

Add the postgresql repo to /etc/apt/sources.list:

deb squeeze-pgdg main 9.0 9.2
sudo apt-get update
sudo apt-get install postgresql-9.2

Instructions have changed a bit, check out

Making Drupal 7 ViewsSlideshow Pager Clickable

While setting up a homepage slider, I used a modified version of the solutions found here. The solution provided worked great, except I needed a clickable version.

Create a new template called views-slideshow-slide-counter.tpl.php (notice that I changed it from above as I needed the ID to make the click work):

<?php $slide_count = count($view->result); for($i=1;$i<=$slide_count;++$i) { $n = $i - 1; $active = $i == 1 ? 'active' : ''; print '  '; } ?>

In application.js:

(function($) {
  $(document).ready(function() {

    Drupal.viewsSlideshowSlideCounter.transitionBegin = function (options) {
      $('#views_slideshow_slide_counter_' + options.slideshowID + ' span').removeClass('active');
      $('#views_slideshow_slide_counter_' + options.slideshowID + ' .num' + (options.slideNum + 1)).addClass('active');

    $('.slide-block').click(function() {
      var id = $(this).attr('id').split('-').pop();
      var options = {'action': 'goToSlide', 'slideshowID': 'homepage_slider-block', 'slideNum': parseInt(id)};


Hope this helps someone trying to figure out how to make the pager clickable.

Superbowl 0-9 Pool Last Digit Frequency

If you’re in a 0-9 pool, where the total of the game scores last digit determines if you win, you may be interested in the history of your number. Here is a plot showing the frequency of the last digit from superbowls between 1968-2011.

The Forgotten Man


See the whole article

Good advice from Daniel Kahneman

See the full article here.

Creating snapshots on AWS with ruby and awstools

Since the recent outage, I’ve been looking for simple scripts to take a snapshot of a volume and only keep a certain number of these snapshots around. I wanted something that I could run from cron in different intervals for different volumes. I found a few scripts lying around, none of which I really liked so I decided to put together one in ruby.

I created the awstools gem, submitted a patch to amazon-ec2 to allow filter requests on the snapshot api and now I have the tool I was looking for.

Check it out here and let me know what you think.

Until my patch is accepted you’ll have to use my fork of the amazon-ec2 gem. Which means you’ll have to clone it to your machine, build the gem with “gem build amazon-ec2.gemspec” then install that gem with “gem install amazon-ec2…”.

To install awstools

gem install awstools

Or to build it yourself, clone the repo to your machine, and then run:

cd awstools
gem build awstools.gemspec
gem install awstools-0.0.1.gem

Once installed you can run something like the following from cron:

0 0 * * * snapshots -v volume-id -d "Some Description" -k 2

That will take a snapshot once a day and only keep two snapshots on hand.

Note that there is an -s flag to simulate, so you can see what it will actually do without creating or deleting any snapshots.

If you see all the volumes at amazon fly by, its because you aren’t using my fork of amazon-ec2.