Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian C. Salvadó cms

View GitHub Profile
View .gitconfig
[core]
editor = vim
filemode = false
trustctime = false
[color]
ui = true
[credential]
helper = cache --timeout=3600
[merge]
tool = vimdiff
View git-stash-grep
stashgrep() {
for i in `git stash list | awk -F ':' '{print $1}'`; do
git stash show -p $i | grep -H --label="$i" "$1"
done
}
View OSXScreen.md

Installing GNU Screen on OS X in Homebrew

I want to edit in one tab, run what I edit in the other. Typical multi-view stuff. I've used Terminal.app for the last few years. Lately, however, after not long enough, Terminal gets laggy when I switch between tabs.

The stutter between edit and run is annoying, an unnacceptable. One of the major reason I've chosen to work with character based UI is because it is snappy. There shouldn't be a lag while a screen of UTF-8 is rendered in a monospace font.

The lag gets progressively longer, chipping at my productivity with irritation. The only solution is to kill all my Terminals, which essentially kills my flow. Terminal.app won't remember where I was for me. I have to initialize ever tab.

GNU Screen

@cms
cms / .bashrc
Created Nov 1, 2011 — forked from henrik/.bashrc
Git branch and dirty state in Bash prompt.
View .bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
View wrap.js
var wrap = function (fn, wrapper) {
var params = [], len = fn.length;
while (len--) {
params[len] = 'a'+len;
}
return Function('fn,wrapper',
'return function ('+params+') {' +
' return wrapper.call(this, fn, [].slice.call(arguments));'+
'}')(fn, wrapper);
@cms
cms / v8-array#push-used-internally.js
Created Aug 19, 2011
V8 Engine internals using built-ins
View v8-array#push-used-internally.js
/* V8 Engine internals using built-ins
*
* Bug report:
* http://code.google.com/p/v8/issues/detail?id=1625
* Bug on code:
* http://code.google.com/p/v8/source/browse/trunk/src/v8natives.js?r=8733#1026
* http://www.google.com/codesearch#W9JxUuHYyMg/trunk/src/v8natives.js&l=1026,1029
*/
var _push = Array.prototype.push;
@cms
cms / Function.prototype.bind.js
Created Aug 15, 2011
Function.prototype.bind shim
View Function.prototype.bind.js
if (typeof Function.prototype.bind != 'function') {
Function.prototype.bind = (function () {
var slice = Array.prototype.slice;
return function (thisArg) {
var target = this, boundArgs = slice.call(arguments, 1);
if (typeof target != 'function') throw new TypeError();
function bound() {
var args = boundArgs.concat(slice.call(arguments));
View isStrictFunction.js
function isStrictFunction(fn) {
if (typeof fn != 'function') throw "Not a function";
try {
fn.caller, fn.arguments;
return false;
} catch (e) {
return e instanceof TypeError;
}
}
@cms
cms / es3-es5-incompatibilities.js
Created Oct 27, 2010
List of ES3 Incompatibilities introduced by ES5
View es3-es5-incompatibilities.js
/*
* List of ES3 Incompatibilities introduced by ES5.
*
*/
/*
* From Annex E:
*/
@cms
cms / proto-array-sandbox.js
Created Oct 27, 2010
Simple `__proto__` based Array sandbox
View proto-array-sandbox.js
var sb = {
Array: function() {
var result = Array.apply(null, arguments);
result.__proto__ = sb.Array.prototype;
return result;
}
};
sb.Array.prototype = [];
sb.Array.prototype.last = function () { return this[this.length -1]; };