Skip to content

Instantly share code, notes, and snippets.

View tomdyson's full-sized avatar

Tom Dyson tomdyson

View GitHub Profile
@tomdyson
tomdyson / extracted_favicons.py
Created September 27, 2013 14:55
favicons with extracted colours
from colorific import extract_colors
from django_rq import job
from PIL import Image as Im
from PIL import ImageChops, ImageDraw
@job
def populate_colours(photo_id):
from models import Colour, Photo
# remove any existing colours
photo = Photo.objects.get(id=photo_id)
@tomdyson
tomdyson / mp4-httplive-with-zencoder.py
Created July 17, 2013 16:19
Use Zencoder to convert mp4 files into HTTP Live segments and playlist, e.g. to meet Apple's requirements for iOS video streaming apps.
# Check an FTP directory for new files, send any to Zencoder for
# conversion to HTTPLive playlists, tell Zencoder to put converted files
# in FTP or S3
# Installation:
# pip install zencoder
# Usage:
# Add S3 credentials to Zencoder - https://app.zencoder.com/account/credentials
# Configure Zencoder, S3 and FTP details
@tomdyson
tomdyson / getting-started-with-redis.md
Created July 6, 2012 10:43
Getting started with Redis - Torchbox University talk

Getting started with Redis

1. What is Redis?

  • An in-memory database but persisted to disk
  • A key value store but the values can be complex
  • A "data structure server"
  • Very fast!

2. Why would I use it?

@tomdyson
tomdyson / video-tips.md
Created April 21, 2011 16:25
low budget video advice

From Pete Speller (http://petespeller.com/), on ECF

"This is a list I have used before for training, it is pretty basic but it is based on mistakes I have seen repeated again and again.

  1. Background noise - computers, air conditioners, phones, doors etc
  2. Busy backgrounds - people wandering around, milling about, having conversations. backgrounds should never hold your attention.
  3. Boring backgrounds - no one wants to look at a plain white wall. step 2-3 feet away from your background and if you are interviewing stand at an angle. Also be careful of windows as the light is a different colour so can mess up the white balance.
  4. Lighting. If it is too dark, find somewhere else.
  5. Interviewees should look at the interviewer, not into the camera. presenters look into the camera.
  6. Film b-roll. Extra footage that you can use to set the scene, hide edit points and illustrate comments made in interviews.
@tomdyson
tomdyson / spartan-rules.md
Created December 6, 2010 15:55
President Yoshida's 10 Spartan Rules
  1. Create work for yourself; don’t wait for work to be assigned to you.

  2. Take an active role in all your endeavours, not a passive one.

  3. Seek out large and complex jobs. Trivial tasks debase you.

  4. Welcome difficult assignments. Choose them. Progress lies in accomplishing difficult work.

  5. Once you begin a task, complete it. Never give up.

Why build a site? Why do your customers care?

The core purpose of a website is to help your customers answer the questions necessary to do business with you.

If your website is a series of answers to questions then the success of your site depends on what questions you answer--it's the questions and answers that show the customer you provide a service they're looking for, you're a good choice and that they should buy from you.

In general every customer has the following questions:

  1. Who are you?
  2. What do you offer?
SELECT
widget_provider_organisations.name AS "Placement provider organisation name",
COUNT(DISTINCT CASE WHEN rabbit_programmes.started_leaf_blowing_training THEN rabbit_programmes.id ELSE NULL END) AS "Started Ready to Go Actual",
COUNT(DISTINCT CASE WHEN rabbit_programmes.completed_leaf_blowing_training THEN rabbit_programmes.id ELSE NULL END) AS "Completed Ready to Go Actual",
COUNT(DISTINCT CASE WHEN rabbit_programmes.offered_work_widget THEN rabbit_programmes.id ELSE NULL END) AS "Offered widgets Actual",
COUNT(DISTINCT CASE WHEN widget_rabbits.started THEN rabbit_programmes.id ELSE NULL END) AS "Started widgets",
COUNT(DISTINCT CASE WHEN widget_rabbits.finished THEN rabbit_programmes.id ELSE NULL END) AS "Finished widgets",
COUNT(DISTINCT CASE WHEN rabbit_programmes.attended_action_day THEN rabbit_programmes.id ELSE NULL END) AS "Attended Action Day",
COUNT(DISTINCT CASE WHEN rabbit_extended_widgets.started THEN rabbit_programmes.id ELSE NULL END)
server {
listen 8000;
server_name localhost;
# access_log /var/log/nginx/lv.access.log;
location / {
root /usr/local/django/lv_core;
index index.html;
expires 7d;
gzip on;
# export DJANGO_SETTINGS_MODULE=api.settings
from pymongo import Connection, DESCENDING
import re
from datetime import datetime
from songdata.models import Song
connection = Connection()
db = connection['test']
songs = db.songs
db.songs.ensure_index('terms')
# work with Elastic Load Balancers in the EU region
from boto.ec2 import elb
AWS_ID = ''
AWS_SECRET = ''
HOST = 'eu-west-1.elasticloadbalancing.amazonaws.com'
conn = elb.ELBConnection(AWS_ID, AWS_SECRET,host=HOST)