Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
subtleGradient / mixin.js
Created June 14, 2011 18:39
Mixins as Mutators!
function Events(exports){
var events = {}
exports.fireEvent = function(){...}
exports.addEvent = function(){...}
// etc...
return exports
}
@subtleGradient
subtleGradient / refresh-Safari-CSS
Created June 8, 2011 00:08
Refreshes the CSS in every Safari document using reCSS
#!/usr/bin/env osascript
-- Refreshes the CSS in every Safari document
-- Using the bookmarklet found at http://dojotoolkit.org/~david/recss.html
--
-- Converted to Applescript by Thomas Aylott - http://subtleGradient.com
tell app "Safari"¬
to do JavaScript "!function(){ var links = document.getElementsByTagName('link'); for (var i=0, link; link = links[i++];){ if (link.href && String(link.rel).toLowerCase().indexOf('stylesheet') >= 0){ var href = link.href.replace(/[&?]reCSS=\\d+/, ''); link.href = href + (href.indexOf('?') >= 0 ? '&' : '?') + 'reCSS=' + (+new Date); } } }()"¬
in every document
@subtleGradient
subtleGradient / global1.js
Created March 5, 2011 06:42
Globalize JS
var Foo = 'bar';
@subtleGradient
subtleGradient / Behavior Sheets.markdown
Created January 5, 2011 00:39
What's the best syntax for creating behavior sheets?

And then with a separate behavior sheet.

<img src=Cheddar.png alt="Pungent Orange Cheddar Cheese" data-type=food-dairy-cheese-cheddar data-smell=pungent data-color=orange>

And the Behavior Sheet

<style type="text/behavior2.0">
[data-type|=food-dairy-cheese]{

@behavior Sing {

<form>
<input type="datetime" data-behavior="TimePicker" data-timepicker-pad="true" data-timepicker-labels-hours="HR" />
</form>
<a href="#my_modal" data-behavior="TargetModal">Open Modal</a>
<div id="my_modal" data-behavior="Modal" data-modal-style="color:#333; opacity:0.7">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
@subtleGradient
subtleGradient / Declarative Component Mapping Syntax Options.textile
Created December 30, 2010 01:36
What is the best syntax to use for declarative markup in HTML5?

Declarative Component Mapping Syntax Options

Language / Prior Art ‘Valid’ HTML HTML Mapping Example Example with Args
‘Valid’ CSS Selectable CSS Mapping CSS Select CSS Selector w Args
JavaScript MooTools Multiple instance Separate Args new Foo(element); new Bar(element) new Foo(element, {a:"a", bB:"b B", c:{c:1}}); new Bar(element, {d:"d"})
— — — — —
HTML attr Dojo <1.6 NO
1 Element per instance
@subtleGradient
subtleGradient / git-jira
Created December 17, 2010 00:16
Jira CLI with git config support! + stuff
#!/usr/bin/env bash
# Author: Thomas Aylott <thomas@subtlegradient.com>
# Usage:|
# git-jira getIssue
# git-jira getComments
# Notes:|
# This expects you to use branch names like "thomas/HUE-123-Make-Things-Awesomer" or "tom-HUE-321-code-stuff"
BRANCH_NAME="$(git symbolic-ref HEAD|sed 's/refs\/heads\///')"
TICKET_ID="$(echo "$BRANCH_NAME"|sed -E 's/^.*[/-]([A-Z]+-[0-9]+).*$/\1/')"
@subtleGradient
subtleGradient / sg_asyncEach.demo.js
Created November 19, 2010 18:45
sg_asyncEach is like each, but async!
// // // // // // // // // // // // // // // // // // // // //
// works as a generic!
Array.sg_asyncEach([1, 2, 3],
function(value, key, array) {
console.log(value, key, array)
return "eachFn result " + value
},
function(err, result) {
console.log('sg_asyncEach callback', err && "Error!" || "Success!", result)
@subtleGradient
subtleGradient / Create a New File
Created November 12, 2010 11:33
Create a New File in the Finder
#!/usr/bin/env osascript
-- name: Create a New File
-- description:
-- Create a new Untitled file in the current Finder window
-- Intended to be used as an appify app in the Finder toolbar
--
-- author: Thomas Aylott <oblivious@subtlegradient.com>
-- license: MIT
tell the application "Finder"
@subtleGradient
subtleGradient / appify
Created November 11, 2010 16:03
appify. Create the simplest possible mac app from a shell script
#!/usr/bin/env bash
#
# url : https://gist.github.com/672684
# version : 2.0.2
# name : appify
# description : Create the simplest possible mac app from a shell script.
# usage : cat my-script.sh | appify MyApp
# platform : Mac OS X
# author : Thomas Aylott <oblivious@subtlegradient.com>