Skip to content

Instantly share code, notes, and snippets.

@soulwire
soulwire / example.js
Created October 3, 2012 05:55
Sketch demo
var COLOURS = [ '#60F0C0', '#FF360E', '#F0D442' ];
var radius = 0;
var demo = Sketch.create({
container: document.getElementById( 'container' ),
autoclear: false,
setup: function() {
@soulwire
soulwire / example.js
Created July 17, 2012 20:54
Selects a property from an object based on a prioritised list and with an optional fallback.
var themeA = { name: 'Theme A', caption: { color: 'red' } };
var themeB = { name: 'Theme B', caption: { color: 'green' } };
var themeC = { name: 'Theme C', color: 'blue', caption: {} };
var themeD = { name: 'Theme D' };
// Test
var a = select( themeA, ['caption.color', 'color'], 'default' );
var b = select( themeB, ['caption.color', 'color'], 'default' );
var c = select( themeC, ['caption.color', 'color'], 'default' );
var d = select( themeD, ['caption.color', 'color'], 'default' );
@soulwire
soulwire / python_alias
Created October 21, 2011 10:16
Can I access the bash shell that's executing a Python script from within the script?
# myscript.py
import subprocess
subprocess.call(['alias', 'my_ls=ls'])
# In the bash shell
$ python myscript.py
# Can I use the my_ls alias here?
$ my_ls