This file contains 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
if | |
ps aux | grep "[g]nome-terminal" > /dev/null | |
then | |
xdotool windowactivate `xdotool search --onlyvisible --class gnome-terminal` | |
else | |
gnome-terminal & | |
fi |
This file contains 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
# https://github.com/lyze/posh-git-sh | |
# posh-git-sh (symbolic link from the posh-git-sh github repo is required first) | |
source ~/git-prompt.sh | |
# PROMPT_COMMAND='__posh_git_ps1 "\u@\h:\w" "\\\$ "' | |
PROMPT_COMMAND='__posh_git_ps1 "[\w]" "\\\$ "' |
This file contains 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
function createUUID() { | |
return uuid.v4(); | |
} | |
// version 4 | |
// createUUID.regex = '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$'; | |
createUUID.regex = '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'; | |
createUUID.is = function (str) { | |
return new RegExp(createUUID.regex).test(str); |
This file contains 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
module.exports = function chain() { | |
var steps = Array.apply(null, arguments); | |
return function middleware(req, res, next) { | |
(function dequeue() { | |
var step = steps.shift(), | |
callback = steps.length ? function (err) { | |
if (err) { | |
return next(err); | |
} |
This file contains 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
function requiredir(dir) { | |
var fullpath = path.resolve(__dirname, dir), | |
ret = {}, | |
filepath, | |
stat, | |
key; | |
fs.readdirSync(fullpath).forEach(function forEachFile(file) { | |
filepath = path.join(fullpath, file); | |
stat = fs.statSync(filepath); |
This file contains 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
function type(obj) { | |
var str = Object.prototype.toString.call(obj); | |
return str.substr(8, str.length - 9).toLowerCase(); | |
} | |
function isInteger(obj) { | |
return (obj | 0) === obj; // jshint ignore: line | |
} |
This file contains 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 alphabet = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"; | |
var base = alphabet.length; // base is the length of the alphabet (58 in this case) | |
// utility function to convert base 10 integer to base 58 string | |
function encode(num) { | |
var encoded = ''; | |
while (num){ | |
var remainder = num % base; | |
num = Math.floor(num / base); | |
encoded = alphabet[remainder].toString() + encoded; |
This file contains 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
// Source: http://stackoverflow.com/questions/2593637/how-to-escape-regular-expression-in-javascript | |
RegExp.quote = function(str) { | |
return (str+'').replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&"); | |
}; |
This file contains 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
if | |
ps aux | grep "[c]hrome" > /dev/null | |
then | |
xdotool windowactivate `xdotool search --onlyvisible --class google-chrome` | |
else | |
google-chrome & | |
fi |
This file contains 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
if | |
ps aux | grep "[s]ublime_text" > /dev/null | |
then | |
xdotool windowactivate `xdotool search --onlyvisible --class sublime_text` | |
else | |
subl & | |
fi |
OlderNewer