Skip to content

Instantly share code, notes, and snippets.

View leecade's full-sized avatar
🎯
Focusing

斯人 leecade

🎯
Focusing
View GitHub Profile
@leecade
leecade / gist:2473845
Created April 23, 2012 21:04 — forked from tanob/gist:945821
AppleScript to open a new tab in iTerm2 from Finder
-- Stefan van den Oord, 2010-12-29
-- The "cd to" command for iTerm2
-- Original from: http://code.google.com/p/iterm2/wiki/AppleScript
-- Modified to open a new tab instead of a new window
tell application "Finder"
set _cwd to POSIX path of ((folder of (front window)) as alias)
end tell
tell application "iTerm"
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
@leecade
leecade / is-this-partial-application.js
Created May 8, 2012 17:19 — forked from cowboy/is-this-partial-application.js
Is this partial application? Currying? Something else? Vindaloo maybe?
// See my blog post:
// http://benalman.com/news/2010/09/partial-application-in-javascript/
// In the following code sample, invoking the curried function will always
// return a function until all arguments are satisfied, at which point the
// original function is invoked, returning its result. This means that all
// function arguments are required, which also allows the function to be
// called either like foo( 1, 2, 3 ) or foo( 1 )( 2 )( 3 ). This also means
// that if any argument is omitted, the original function is never invoked.
@leecade
leecade / gist:2851981
Created June 1, 2012 13:02 — forked from zythum/gist:2848881
google收录的敏感词
@leecade
leecade / safari-get-html.js
Created June 5, 2012 17:21 — forked from subtleGradient/safari-get-html.js
Node.js JavaScript for Mac OS X. Uses osascript AppleScript to control Safari. Remote control Safari from the terminal!
#!/usr/bin/env node #// -*- Mode: Node.js JavaScript; tab-width: 4; -*-
/*
---
url: http://gist.github.com/441101
name : safari-get-html
description : safari-get-html will rock your socks!
authors : Thomas Aylott
copyright : © 2010 Thomas Aylott
license : MIT
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
//
// the regular expression composed & commented
// could be easily tweaked for RFC compliance,
// it was expressly modified to fit & satisfy
// these test for an URL shortener:
@leecade
leecade / hack.sh
Created June 19, 2012 04:43 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@leecade
leecade / filterify.js
Created July 3, 2012 01:32 — forked from cowboy/filterify.js
JavaScript: partial application in a useful way, like creating a function that can be passed to filter / forEach / map, etc.
/*
* filterify
*
* Copyright (c) 2012 "Cowboy" Ben Alman
* Licensed under the MIT license.
* http://benalman.com/about/license/
*/
Function.prototype.filterify = function filterify() {
var args = arguments.length > 0 ? [].slice.call(arguments) : [filterify];
(function (exports) {
var supportsGCS = "defaultView" in exports.document && "getComputedStyle" in exports.document.defaultView;
function getStyle(element, property) {
// `element.ownerDocument` returns the used style values relative to the
// element's parent document (which may be another frame). `defaultView`
// is required for Safari 2 support and when retrieving framed styles in
// Firefox 3.6 (https://github.com/jquery/jquery/pull/524#issuecomment-2241183).
var style = supportsGCS ? element.ownerDocument.defaultView.getComputedStyle(element, null) : element.currentStyle;
return (style || element.style)[property];
@leecade
leecade / mountain-lion-brew-setup.markdown
Created August 3, 2012 09:19 — forked from myobie/mountain-lion-brew-setup.markdown
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from the App Store.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.