Skip to content

Instantly share code, notes, and snippets.

View cms's full-sized avatar

Christian C. Salvadó cms

View GitHub Profile
@cms
cms / .gitconfig
Last active April 11, 2017 15:21
config
[core]
editor = vim
filemode = false
trustctime = false
[color]
ui = true
[credential]
helper = cache --timeout=3600
[merge]
tool = vimdiff
@cms
cms / git-stash-grep
Last active August 29, 2015 14:19 — forked from hartym/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
}

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 November 1, 2011 06:59 — forked from henrik/.bashrc
Git branch and dirty state in Bash prompt.
# 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)]/"
@cms
cms / wrap.js
Created September 7, 2011 02:58
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 August 19, 2011 07:20
V8 Engine internals using built-ins
/* 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 August 15, 2011 17:08
Function.prototype.bind shim
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));
@cms
cms / isStrictFunction.js
Created March 2, 2011 06:35
isStrictFunction
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 October 27, 2010 18:55
List of ES3 Incompatibilities introduced by ES5
/*
* List of ES3 Incompatibilities introduced by ES5.
*
*/
/*
* From Annex E:
*/
@cms
cms / proto-array-sandbox.js
Created October 27, 2010 15:36
Simple `__proto__` based Array sandbox
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]; };