Skip to content

Instantly share code, notes, and snippets.

View dsingleton's full-sized avatar

David Singleton dsingleton

View GitHub Profile
(function(src) {
document.body.appendChild(document.createElement('script')).setAttribute('src', src);
})(prompt("Script URL to load", "http://example.com/script.js"));
// You could drop the self executing function now src is at the end of the line, it's just as easy to edit.
// javascript:(function(src){document.body.appendChild(document.createElement('script')).setAttribute('src', src);})("https://gist.github.com/raw/924488/twttr.media.types.Lastfm.js");
// Simulate self-executed scope in phoenix.js, Replicate A (ajax/xdm var in compressed version)
(function(A) {
twttr.mediaType("twttr.media.types.Lastfm", {
icon: "song",
domain: "http://www.last.fm",
matchers: {
track: /^#{optional_protocol}?www\.last\.fm\/music\/([^/]+\/[^/]+\/[^/]+)/i,
album: /^#{optional_protocol}?www\.last\.fm\/music\/([^/]+\/[^/]+)/i,
@dsingleton
dsingleton / lfm-responsive-hack.css
Created June 13, 2011 13:08
Responsive design hack for Last.fm
@media screen and (max-width: 480px) {
body #page {
min-width: 320px;
max-width: 480px;
}
/** Header */
#primaryNav {
@dsingleton
dsingleton / function-bind.js
Created October 25, 2011 11:10
Polyfill for Function.prototype.bind
Function.prototype.bind=Function.prototype.bind||function(b){if(typeof this!=="function"){throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");}var a=Array.prototype.slice,f=a.call(arguments,1),e=this,c=function(){},d=function(){return e.apply(this instanceof c?this:b||window,f.concat(a.call(arguments)));};c.prototype=this.prototype;d.prototype=new c();return d;};
@dsingleton
dsingleton / gist:1476378
Created December 14, 2011 12:22
Bookmarklet to insert a JS file, with config query params added to the script call
(function (url, params) {
var body = document.body,
script = document.createElement('script');
try {
pairs = [];
for(var key in params) pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
script.setAttribute('src', url + '?' + pairs.join('&'));
script.setAttribute('id', params.id || 'bookmarklet');
} catch (c) {
alert('Please wait until the page has loaded');
@dsingleton
dsingleton / custom.css
Last active August 29, 2015 14:01 — forked from norm/custom.css
Fourth Wall config
#pulls li.age-aging,
#pulls li.age-old {
/*background: #9Fa098;*/
}
Bundler could not find compatible versions for gem "nokogiri":
In Gemfile:
govspeak (= 1.5.4) ruby depends on
nokogiri (~> 1.5.10) ruby
slimmer (= 4.1.0) ruby depends on
nokogiri (1.5.9)
@dsingleton
dsingleton / agile-planner-styles
Last active August 29, 2015 14:06
Custom CSS to display agile planner on a TV/radiator
{"www.agileplannerapp.com":{"_enabled":true,"_rules":{".masthead":{"display":"none"},"#page > p.update":{"display":"none"},".kanban-board > header":{"display":"none"},".column[data-collection=Blocked] .cards > li > article":{"border":"4px solid red"},".column .bar":{"display":"none"}}}}
@dsingleton
dsingleton / smartdown-spl-outcome-generator.rake
Last active August 29, 2015 14:06
Generate all outcomes based on next-node rules for SPL
namespace :smartdown do
def smartdown_coversheet_path(flow_name, coversheet_name= flow_name)
File.join(smartdown_flow_path(flow_name), "#{coversheet_name}.txt")
end
def smartdown_flow_path(flow_name)
Rails.root.join('lib', 'smartdown_flows', flow_name)
end
[
{
"userName": "alphagov",
"repo": "calculators"
},
{
"userName": "alphagov",
"repo": "calendars"
},
{