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 / 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');
@worldofchris
worldofchris / example.js
Created January 29, 2013 13:39
Having trouble getting the dojo/request node.js example to work: arnosgrove:example chris$ node example.js module.js:236 var start = request.substring(0, 2); ^ TypeError: Object require,dojo/request has no method 'substring' at Function.Module._resolveLookupPaths (module.js:236:23) at Function.Module._resolveFilename (module.js:328:31) at Functi…
// 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');
@worldofchris
worldofchris / columnz.py
Last active December 17, 2015 01:58
Column problem
input = [[1, 2, 3], [1, 3, 1], [1, 4, 2]]
total = [0, 0, 0]
for i in range(0, 3):
for row in input:
if row[i] != input[0][i]:
total[i] = total[i] + row[i]
else:
total[i] = row[i]
@worldofchris
worldofchris / columnz.clj
Created May 7, 2013 10:57
Column problem
(def input [[1,2,3],[1,3,4],[1,5,6]])
(defn is-list-unique [input]
"Takes a list and returns first element if they are all the same and sum of elements if not"
(if (every? #{(first input)} (rest input))
(first input)
(apply + input))
)
(defn are-lists-unique [input]
@worldofchris
worldofchris / apply-vs-map.clj
Last active November 22, 2016 21:59
Figuring out the difference between map and apply in Clojure...
; Define a vector of vectors
(def input [[1,2,3],[1,3,4],[1,5,6]])
; Calling the 'list' function on this:
user=> (list input)
; Gives us a single item list whose one and only member is this
; vector of vectors:
([[1 2 3] [1 3 4] [1 5 6]])
; Mapping the 'list' function to input _applies_
@worldofchris
worldofchris / .profile
Created July 25, 2013 10:15
C64 .profile for bash
clear
export PS1=$
free="$(( $(vm_stat | awk '/free/ {gsub(/\./, "", $3); print $3}') * 4096 / 1048576)) MiB free"
echo \*\*\*\* bash $BASH_VERSION \*\*\*\*
echo
echo $free
echo
echo READY.
@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: