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 / grabber.js
Created May 24, 2020 13:32
Grab screenshots of headless chrome browser window
const puppeteer = require('puppeteer');
let _browser;
let _page;
async function please_wait() {
console.log('you wait')
let you_wait = new Promise((resolve, reject) => {
setTimeout( function() {
console.log('time passes');
@worldofchris
worldofchris / goat_inspect.py
Created May 23, 2020 05:58
Python example decorator
"""
Quick reminder of how decorators work
"""
from functools import wraps
def goat_inspect(f):
"""
^^^ this is the name of our decorator - interface
"""
@wraps(f)
@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 / xmas
Created December 24, 2014 20:52
It's a C64 xmas
10 PRINT "HAPPY XMAS ";
20 POKE 53280, 0
30 POKE 54281, 0
40 FOR X = 1 TO 500
50 NEXT X
60 PRINT "HAPPY CHRISTMAS ";
70 POKE 53280, 2
80 POKE 53281, 2
90 FOR Y = 1 TO 500
100 NEXT Y
@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 / 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
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 / 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):
@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 / gist:7647926
Created November 25, 2013 20:07
Blow up when running noflo-graphviz against the example from http://noflojs.org/documentation/
# 1. Install GraphViz
chris@ubuntu:~/src$ sudo apt-get install graphviz
[sudo] password for chris:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libcdt4 libcgraph5 libgraph4 libgvc5 libgvpr1 libpathplan4 ttf-liberation
Suggested packages: