Skip to content

Instantly share code, notes, and snippets.

View cms's full-sized avatar

Christian C. Salvadó cms

View GitHub Profile
@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 / .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)]/"

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 / 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
}
@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 / CasecadeDelete.sql
Created April 19, 2018 15:04 — forked from lionofdezert/CasecadeDelete.sql
Casecade Delete in SQL Server
USE AdventureWorks
GO
--============== Supporting function dbo.udfGetFullQualName
IF OBJECT_ID('dbo.udfGetFullQualName') IS NOT NULL
DROP FUNCTION dbo.udfGetFullQualName
GO
CREATE FUNCTION dbo.udfGetFullQualName ( @ObjectId INTEGER )
@cms
cms / main.cs
Created December 6, 2018 17:35
360TRef
using System.Linq;
using System.Text.RegularExpressions;
using ServiceStack;
using ServiceStack.Text;
var mysisRef = "360T364827992x";
var _360tRef = Get360TReference(mysisRef);
_360tRef.PrintDump();
@cms
cms / devicons.html
Created February 26, 2019 02:57
DevIcons
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link rel="stylesheet" href="https://cdn.rawgit.com/konpa/devicon/df6431e323547add1b4cf45992913f15286456d3/devicon.min.css">
<link href='//cdn.jsdelivr.net/devicons/1.8.0/css/devicons.min.css' rel='stylesheet'>
<style>
body {
@cms
cms / array-chunks.js
Created March 22, 2019 18:59
array chunks
// Using Array.prototype.reduce:
const getChunks = (array, size) => {
return array.reduce((acc, curr, i) => {
const pos = Math.floor(i/size);
acc[pos] = [...(acc[pos]||[]), curr];
return acc
}, [])
}
// Using Array.from:
@cms
cms / capitalizeSentence.js
Last active May 10, 2019 22:14
capitalizeSentence
function capitalizeSentence(str) {
return str.replace(/^\w|(\s\w)/g, function(match, index) {
return match.toUpperCase()
});
}
capitalizeSentence('Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
// "Lorem Ipsum Dolor Sit Amet, Consectetur Adipiscing Elit."