Skip to content

Instantly share code, notes, and snippets.

View jashkenas's full-sized avatar

Jeremy Ashkenas jashkenas

View GitHub Profile
# Apart from the basic niceties of being able to leave off
# parens in clear calls...
print 10
alert "Hello #{name}"
# ... the reason why they're important to have in CoffeeScript
# is because it allows our "block" syntax (single function body
For those folks not already hanging out in #documentcloud... here's the log of this afternoon's Ember/Backbone politics discussion.
12:21 PM <wycats> jashkenas: hey
12:21 PM <wycats> jashkenas: I'm sorry
12:21 PM <wycats> how would you like me to describe backbone?
12:21 PM <wycats> let's work this out for once and for all :)
12:21 PM <wycats> I'm definitely not intentionally saying incorrect things about backbone
12:22 PM • knowtheory gets out popcorn
12:24 PM <jashkenas> don't worry about it too much -- I'm just not terribly pleased with backbone being continued to be used as the strawman...
12:24 PM <wycats> jashkenas: I am worried about it a lot
// Format a number into a dollar string.
Card.prototype.formatDollars = function(num) {
var chars = (Math.round(num) + '').split('').reverse();
var result = [];
while (chars.length > 3) {
result = result.concat(chars.slice(0, 3));
result.push(',');
chars = chars.slice(3);
}
result = result.concat(chars);
wycats> soooo
1:15 PM <wycats> back-of-the-envelope
1:16 PM <wycats> what frustrates me about election night coverage is this:
1:16 PM <wycats> we have awesome data
1:16 PM <wycats> but I have to watch TV to let Chuck Todd tell me that some county leans Republican and it's not all in yet
1:16 PM <wycats> and draw statewide projections
1:16 PM <wycats> humans are actually not even very good at that
1:17 PM <wycats> what I want is an election scoreboard that shows clearly how states are trending, based on county-level results from the last N elections
1:17 PM <wycats> I know newsrooms are leery about making projections, but this wouldn't be calling anything
1:17 PM <wycats> it would just be showing visually what people are trying to cram into 30s here and there on TV
foo
(
function( ) {
return bar(
'foo' ) ;
},
function
()
{
return 'bar'
# Final Iowa vote counts.
results =
romney: 30015
santorum: 30007
paul: 26219
gingrich: 16251
perry: 12604
bachmann: 6073
huntsman: 745
nopref: 135
* html img,
* html .png{
position:relative;
behavior: expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none",
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')",
this.src = "transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''),
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')",
this.runtimeStyle.backgroundImage = "none")),this.pngSet=true)
);
}
switch filter.type
when 'is'
return no unless value is filter.value
when 'isnt'
return no unless value isnt filter.value
when 'matches'
return no unless value.match filter.value
javascript:(function(){function%20f(b){b=b||window;for(var%20g=b.document.getElementsByTagName("link"),a=0,d=g.length;a<d;a++){var%20e=g[a],c=e.href;if(c&&/stylesheet/i.test(e.rel)){c=c.replace(/(&|%5C?)forceReload=\d+/,"");var%20h="forceReload="+(new%20Date).valueOf();e.href=c+(c.indexOf("?")>=0?"&":"?")+h}}a=0;for(d=b.frames.length;a<d;a++)f(b.frames[a])}f()})();
(function() {
one(1);
}).call(this);
all(this);