Skip to content

Instantly share code, notes, and snippets.

View aseemk's full-sized avatar

Aseem Kishore aseemk

View GitHub Profile
@aseemk
aseemk / gist:2939002
Created June 15, 2012 22:27
CoffeeScript's interesting line continuation behavior
# all on one long line works:
if not foo or not bar or not baz = Some.reallyLongMethodName foo, bar, _
error = true
# newline with matched three-space indentation level works:
if not foo or not bar or
not baz = Some.reallyLongMethodName foo, bar, _
error = true
# but newline with one regular indentation level *doesn't* work:
@aseemk
aseemk / migrate._coffee
Created May 10, 2012 22:34
Helper script to migrate Streamline files to the new ._js/._coffee extensions.
#!/usr/bin/env _coffee
#
# Migrates our Streamline v0.1 files to the new Streamline v0.3 extensions,
# i.e. git-moves all foo_.coffee files to foo._coffee.
{exec} = require 'child_process'
Path = require 'path'
# regex to recognize old-style streamline files:
STREAMLINE_REGEX = /_\.(js|coffee)$/
@aseemk
aseemk / github.com.js
Created May 9, 2012 23:34
dotjs script for GitHub: account for whitespace in commit diffs!
// if this is a commit page, properly account for whitespace in diffs!
// XXX this works by adding ?w=1 to the URL, which requires a page reload. =/
// to prevent this behavior, change the URL to ?w. (?w=0 and ?w= don't work!)
// TODO consider changing this behavior to add a link/button instead?
// TODO is the .page-commit-show class the right thing to base this on?
if ($(document.body).hasClass('page-commit-show')) {
// XXX this'll overwrite any other query params, but good enough for now?
// also note that setting location.search -- even to whatever it already
// is -- causes a page change, so only set it if to a different value!
// TODO use location.replace() instead to prevent new history entry, but
@aseemk
aseemk / url.coffee
Created April 27, 2012 05:51
Simplified wrapper around Node's native 'url' module
# url.coffee
# by Aseem Kishore ( https://github.com/aseemk ), under MIT license
#
# A simplified wrapper around the native 'url' module that returns "live"
# objects: updates to properties are reflected in related properties. E.g.
# updates to the `port` property will be reflected on the `host` property.
#
# The public API and behavior are pretty close to the native 'url' module's:
# http://nodejs.org/docs/latest/api/url.html Currently lacking / known issues:
#
@aseemk
aseemk / animal.js
Created April 23, 2012 23:11
Streamline 0.2.4 super/arguments/apply bugs
/*** Generated by streamline 0.2.2 - DO NOT EDIT ***/
var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=__rt.__func,__cb=__rt.__cb,__propagate=__rt.__propagate,__trap=__rt.__trap,__future=__rt.__future,__setEF=__rt.__setEF,__g=__rt.__g;
var Animal;
module.exports = Animal = (function() {
Animal.name = "Animal";
function Animal() {
};
Animal.prototype.greet = function Animal_prototype_greet__1(_) {
var __frame = {
@aseemk
aseemk / model_.coffee
Created April 23, 2012 15:38
Streamline error: To use 'arguments' inside streamlined function, read the doc and set the 'ninja' option
module.exports = class Model
toString: (raw) ->
return super if raw
'test 1 2 3'
@aseemk
aseemk / Cakefile
Created April 22, 2012 00:56
Trying to Streamline a Cakefile
return if not require('streamline/module')(module)
task 'greet', ->
console.log 'Hello...'
setTimeout _, 1000
console.log '...world'
@aseemk
aseemk / gist:2289135
Created April 3, 2012 03:45
A bookmarklet I whipped up to do something-or-another on Twitter. ;) I forget exactly what now; just didn't want to lose this code. =)
$('.tweet').each ->
$tweet = $(this)
# ignore tweets from ABC and DEF user IDs
return if $tweet.data('user-id') in [123, 456]
# also ignore tweets we've seen
return if $tweet.data('image-opened')
$openLink = $tweet.find '.open-tweet'
@aseemk
aseemk / .bash_profile
Created March 29, 2012 22:24
Bash prompt hotness: Git branch, full path, bold text, newline separators. Terminal readability FTW!
# You need to have bash-completion installed, e.g. `brew install bash-completion`.
# And you may need to have git installed this way too, e.g. `brew install git`.
# This is needed for bash completion:
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
# And here's the sexy prompt that shows the Git branch for git repos:
export PS1='\n\033[1m\w$(__git_ps1 " (%s)") $\033[0m '