Skip to content

Instantly share code, notes, and snippets.

View worldofchris's full-sized avatar
🏠
Working from home

Chris Young worldofchris

🏠
Working from home
View GitHub Profile
@worldofchris
worldofchris / test_gspread.py
Created March 13, 2014 14:44
Demonstrate how to test dealing with 500 Internal Server Errors by patching the object that raises them using mock.
"""
Demonstrate how to test dealing with 500 Internal Server Errors,
e.g. when raised by calling Google Spreadsheet API
via https://github.com/burnash/gspread,
by patching the object that raises them using mock.
"""
from mock import patch
import gspread
@worldofchris
worldofchris / sefton_filelist.py
Last active August 29, 2015 14:02
Grab the names of all the files on Graham's dodgy hard disc.
# Grab the names of all Graham's files
import os
import sys
path = '.'
for dir in os.listdir(path):
if dir[0] > sys.argv[1]:
for dirpath, dirnames, files in os.walk(dir):
import os
import subprocess
import sys
import shutil
f = open("music.txt", "r")
dest_root = os.path.normpath('c:/Users/graham/Desktop/music')
src_root = os.path.normpath("d:/users/graham/music/itunes/itunes media/music/")
@worldofchris
worldofchris / format_cfd.vba
Last active August 29, 2015 14:05
Format Excel CFD
Sub ColorMatchingCells(toMatch, color, topLeft, bottomRight)
'
' Colour in the different states in the Cumulative Flow Diagram
'
Range(topLeft, bottomRight).Select
'Cells.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlTextString, _
String:=toMatch, _
TextOperator:=xlContains
@worldofchris
worldofchris / join.py
Created August 29, 2014 20:44
Join two Pandas DataFrames together
"""
Join two DataFrames together
"""
import pandas as pd
hist_1 = [
{'bucket': '0-1', 'develop': 0},
{'bucket': '2-4', 'develop': 1}
]
@worldofchris
worldofchris / icanhazip.yml
Created June 3, 2015 10:13
Get my IP address from icanhazip.com
- hosts: localhost
gather_facts: False
sudo: no
tasks:
- name: Get my IP address
uri: url=http://icanhazip.com return_content=yes
register: ip_response
- name: Set my IP address
@worldofchris
worldofchris / build.gradle
Created January 2, 2013 14:40
Decided to start stashing my Gradle odds and ends somewhere for future reference...
// Create a tar file from a filtered tree of files
// e.g. a tree of Python Source files
project.ext {
pythonFiles = fileTree('src').include('**/*.py')
}
task tarPythonFiles (type: Tar) {
from pythonFiles // Source is our fileTree
includeEmptyDirs false // Otherwise we get ALL the dirs in the fileTree
from oauth2client.client import flow_from_clientsecrets
from oauth2client.file import Storage
from oauth2client.tools import run
import gdata.sites.client
import gdata.sites.data
# How to use the OAuth 2.0 client is described here:
# https://developers.google.com/api-client-library/python/guide/aaa_oauth
SCOPE = 'https://sites.google.com/feeds/'
@worldofchris
worldofchris / adder.py
Last active December 11, 2015 21:38
Adder 0.2 - Snake based language...for adding. Inspired by @MegaStoat
"""Adder 0.2 - Snake based language...for adding"""
class Snake:
"""The main body of the adder"""
skin = '>'
def __init__(self):
self.body = ''
@worldofchris
worldofchris / useRequest.js
Last active December 11, 2015 21:39
Having a problem using dojo/request under node.js arnosgrove:example chris$ node useRequest.js I can call dojo/date functions no problem: e.g. Time Zone is:GMT But when I try to use dojo/request it fails: module.js:236 var start = request.substring(0, 2); ^ TypeError: Object has no method 'substring' at Function.Module._resolveLookupPaths (modul…
// dojo-release-1.8.3-src is installed in the same directory as this script
dojoConfig = {
baseUrl: ".",
packages:[{name: 'dojo', location: 'dojo'}],
deps:['dojo/request', 'dojo/date']
};
require('./dojo/dojo.js');