This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isTouch = (function() { | |
try { return document.createEvent("TouchEvent") && ('ontouchstart' in window) } | |
catch(e) { return false } | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git log --pretty=oneline --author=Marcus --since=yesterday | wc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var originalAppend = $.fn.append | |
$.fn.append = function() { | |
if (arguments.length == 1) { | |
var arg = arguments[0] | |
if ($.isArray(arg)) { | |
for (var i=0; i<arg.length; i++) { this.append(arg[i]) } | |
} else { | |
originalAppend.call(this, arg) | |
} | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
# First, install node and: | |
sudo npm install jsdom | |
sudo npm install aws2js | |
sudo npm install request | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sudo npm install request && sudo npm install jsdom | |
var request = require('request') | |
var jsdom = require('jsdom') | |
var pages = process.argv.slice(2) | |
if (!pages.length) { pages = [0] } | |
console.error('Scrape Crunchbase funding rounds. Pages:', pages) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See https://github.com/marcuswestin/git-star for new version of this script | |
#!/bin/bash | |
set -e # die on error | |
cd $(git rev-parse --show-toplevel) | |
REMOTE="origin" | |
BRANCH=`git branch --no-color | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
;(function colorizeNode(){ | |
var colors = { | |
white:1, black:30, blue:34, pink:35, cyan:36, | |
red:31, redLight:91, | |
green:32, greenLight:92, | |
yellow:33, yellowLight:93, | |
gray:90, grayLight:37, | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// std | |
////// | |
function isArray(obj) { return Object.prototype.toString.call(obj) == '[object Array]' } | |
function isArguments(obj) { return Object.prototype.toString.call(obj) == '[object Arguments]' } | |
function slice(arr, i) { return Array.prototype.slice.call(arr, i || 0) } | |
function curry(fn /*, args ...*/) { | |
var args = slice(arguments, 1) | |
return function() { return fn.apply(this, args.concat(slice(arguments))) } | |
} | |
function each(obj, fn) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSURL* url = [NSURL URLWithString:@"http://www.google.com/path/to/foo?aParam=value"]; | |
url.absoluteString; | |
url.host; | |
url.scheme; | |
url.path; | |
NSArray* arr = [NSArray arrayWithObjects:url, [NSURL URLWithString:@"https://marcuswest.in/teachers"], nil]; | |
NSLog(@"scheme %@", [arr filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"scheme MATCHES 'http'"]]); | |
NSLog(@"host %@", [arr filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"host MATCHES 'www.google.com'"]]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)startLoading { | |
self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self]; | |
if (!self.connection) { | |
[self.client URLProtocol:self didFailWithError:nil]; | |
} | |
} | |
- (void)stopLoading { | |
[self.connection cancel]; | |
self.connection = nil; |