Skip to content

Instantly share code, notes, and snippets.

View judy2k's full-sized avatar

Mark Smith judy2k

View GitHub Profile
module ActsAsCsv
class Row < Array
def initialize(ary, headings)
super(ary)
@headings = headings
end
def method_missing(name, *args)
idx = @headings.index name.to_s
self[idx] if idx != nil
@judy2k
judy2k / day1_workout.txt
Created November 3, 2011 10:35
IO Exercises
Io Typing
=========
Io> 1 + 1
==> 2
Io> 1 + "one"
Exception: argument 0 to method '+' must be a Number, not a 'Sequence'
---------
@judy2k
judy2k / qwerty-en_GB.kcm
Created February 24, 2012 11:15
Keychar Map for Dvorak
type FULL
key GRAVE {
label, number: '`'
base: '`'
shift: '\u00ac'
alt: '\u00a6'
alt+shift: none
ctrl, meta: none
}
@judy2k
judy2k / leastsquares.py
Created March 6, 2012 12:15
Predict a value using least squares method.
import numpy as np
def get_line(points):
x = np.array([p[0] for p in points])
y = np.array([p[1] for p in points])
A = np.vstack([x, np.ones(len(x))]).T
m, c = np.linalg.lstsq(A, y)[0]
return m, c
def get_y(x, m, c):
@judy2k
judy2k / bookingdate.py
Created May 9, 2012 10:07
Using BookingDate
bdate = BookingDate(
booking_name=request.user,
date_available=datetime.datetime.now())
bdate.save()
# Theirs:
print map(lambda x: x * 2, range(1,11))
# Mine:
print [x*2 for x in range(1,11)]
@judy2k
judy2k / 01_before.py
Created July 7, 2012 13:05
modeltest refactoring
class ModelTest(TestCase):
def test_lookup(self):
# No articles are in the system yet.
self.assertQuerysetEqual(Article.objects.all(), [])
# Create an Article.
a = Article(
id=None,
headline='Area man programs in Python',
@judy2k
judy2k / coldesc.sql
Created September 18, 2012 15:39
Column Description
DROP FUNCTION IF EXISTS coldesc();
CREATE FUNCTION coldesc() RETURNS TABLE(COL text,VAL text) AS $$
DECLARE
COL text;
Q text;
BEGIN
Q := 'SELECT ''boundary'' as COL, boundary AS VAL FROM planet_osm_line GROUP BY boundary';
FOREACH COL IN ARRAY ARRAY['barrier', 'bicycle', 'bridge', 'boundary', 'building', 'construction']
LOOP
RAISE NOTICE '%', Q;

Python Developer

Twig World is looking to recruit a highly skilled and motivated Python developer to build and maintain our portfolio of award-winning educational online products.

The successful candidate will be joining a small, collaborative team in our Glasgow office which is responsible for the end-to-end development of Twig’s online platform. You will be expected not only to write code, but also to provide ideas and expertise to shape new and existing products.

About the Team

The Tech Team is a tight-knit, cross discipline team of people who are passionate about building great online products. Everyone gets involved in steering what we do, providing ideas for future development and opinions on which technologies we use. The ideal candidate will bring energy, expertise, creativity and innovation to the team, as well as a real pride in their work. A good sense of humour is essential.

Python Developer

Twig World is looking to recruit a highly skilled and motivated Python developer to build and maintain our portfolio of award-winning educational online products.

The successful candidate will be joining a small, collaborative team in our Glasgow office which is responsible for the end-to-end development of Twig’s online platform. You will be expected not only to write code, but also to provide ideas and expertise to shape new and existing products.

About the Team

The Tech Team is a tight-knit, cross discipline team of people who are passionate about building great online products. Everyone gets involved in steering what we do, providing ideas for future development and opinions on which technologies we use. The ideal candidate will bring energy, expertise, creativity and innovation to the team, as well as a real pride in their work. A good sense of humour is essential.