Skip to content

Instantly share code, notes, and snippets.

@adrianshort
adrianshort / gist:2920635
Created June 12, 2012 22:54
Learning to program
Computer literacy is a very misleading term. Generally it means learning to use a computer, that is, learning to use programs that other people have written for computers. But if we take the analogy with literacy seriously, computer literacy is learning to read but not learning to write. Real computer literacy means learning to write our own programs as well as to use other people's. Programmability is the definition of a computer, a device that can be taught to do different things, one that's malleable rather than rigid.
Yet we have millions of people, intelligent people, skilful people, ambitious people, spending hundreds of hours a year sitting in front of these immensely powerful machines whether at home or at work, and all they can do with them is use them to run software that other people have created. Software that reflects the values and imperatives of the people who made that software which don't necessarily coincide with the desires of the people who use it. That's a waste of the equipment in front
@adrianshort
adrianshort / search.rb
Created March 19, 2012 15:46
Download Twitter searches to TSV
#!/usr/bin/ruby
require 'rubygems'
require 'json'
require 'httpclient'
require 'uri'
require 'time'
def backup(query, since_id = nil)
- @last_date = ''
- @results.each do |row|
- if row.election_d != @last_date
- @last_date = row.election_d
%h2= row.election_d
%table
%tr
@adrianshort
adrianshort / 500isbn13s.csv
Created September 30, 2011 13:18
500 ISBN-13s - sample data
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
9780006281436
9780006281443
9780006499152
9780006499480
9780006532286
9780006547747
9780006547754
9780007117536
9780007134724
9780007139842
$ sudo gem install mysql
Password:
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
extconf.rb:4: warning: Insecure world writable dir /usr/local/git in PATH, mode 040777
extconf.rb:4: warning: Insecure world writable dir /usr/local/git in PATH, mode 040777
extconf.rb:7: warning: Insecure world writable dir /usr/local/git in PATH, mode 040777
<?php
/*
SutMobLib API server-side example
by Adrian Short [email protected]
6 March 2010
There are four possible outcomes of the API call:
1. The library is not running today due to an "exception", eg. a bank holiday. The API returns the reason for this exception in $result->exception.
2. The library is visiting various housebound readers at home. This is on the schedule so the times of this activity are specified but the location is not.
==> dyno-1482316-crashlog.log <==
BigDecimal is deprecated, use Decimal instead at /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- postgres_adapter (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /home/slugs/204849_09fa171_a1c7/mnt/.gems/gems/dm-core-1.0.0/lib/dm-core/adapters.rb:165:in `load_adapter'
from /home/slugs/204849_09fa171_a1c7/mnt/.gems/gems/dm-core-1.0.0/lib/dm-core/adapters.rb:133:in `adapter_class'
from /home/slugs/204849_09fa171_a1c7/mnt/.gems/gems/dm-core-1.0.0/lib/dm-core/adapters.rb:13:in `new'
from /home/slugs/204849_09fa171_a1c7/mnt/.gems/gems/dm-core-1.0.0/lib/dm-core.rb:257:in `setup'
from ./lib/models.rb:90
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
@adrianshort
adrianshort / uk-postcodes.rb
Created April 12, 2010 13:18
Geocode a postcode & find councils/wards via uk-postcodes.com API
# Geocode a postcode & find councils/wards via uk-postcodes.com API
require 'rubygems'
require 'json'
require 'rest_client'
require 'pp'
postcode = "SW1A 0AA"
endpoint = "http://www.uk-postcodes.com/postcode/"