Skip to content

Instantly share code, notes, and snippets.

View panta82's full-sized avatar

Ivan Pantic panta82

View GitHub Profile
@panta82
panta82 / gist:9261325
Last active August 29, 2015 13:56
[Bash] Go To Project alias function
# Alias command to quickly jump to any project on your machine.
# Advantage is given to recently altered projects and directories that hold .git repositories.
#
# Examples:
# gd # cd ~/dev/[most recently active project]
# gd project1 # cd ~/dev/c/project1
# gd pr1 # cd ~/dev/c/project1 (fuzzy search)
# gd node # cd ~/dev/node/[most recently active node project]
# gd gdfgd # nothing (no candidate found)
#
@panta82
panta82 / gist:9855254
Created March 29, 2014 14:15
Test which characters in javascript are OK in variable names
// Easier than looking up in documentation... :-)
function test(chars) {
for (var i = 0; i < chars.length; i++) {
testSole(chars[i]);
testStart(chars[i]);
testMiddle(chars[i]);
}
function testSole(c) {
@panta82
panta82 / gist:65a351b75faafc32a1e8
Created September 19, 2014 17:28
decimalToCustom, useful to shorten database ID-s into strings
function decimalToCustom(decimal, alphabet) {
var alphabetSize = alphabet.length,
remainder,
result = [];
while (decimal > 0) {
remainder = decimal % alphabetSize,
decimal = Math.floor(decimal / alphabetSize);
result.unshift(alphabet[remainder]);
}
return result.join('');
@panta82
panta82 / gist:855b7f7d6e6b27e75a30
Created October 1, 2014 15:17
Ember item controller usage
http://emberjs.jsbin.com/qacatorixali/1/edit

Kinsome Collector

Click collector, a part of kinsome project

API

Collector is designed to work in concert with the central Kinsome app.

Kinsome collector API:

var str = "A";
mutate(str);
str += "C";
console.log(str);
function mutate(str) {
str += "B";
}
@panta82
panta82 / gist:cb066d96d1cb8bca1199
Created March 13, 2015 13:02
Git alias: killbranch
killbranch = "!f(){ dialog --keep-tite --yesno \"Are you sure you want to delete branch $1?\" 6 60 && git branch -d \"$1\" && git push origin :\"$1\"; };f"
@panta82
panta82 / gist:b26dc656b6b4f5170f54
Created February 22, 2016 12:48
Bash color prompt
##############################
# Colorized bash prompt
echo_git_branch() {
local branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
if [[ ! -z "$branch" ]]; then
printf "(%s) " $branch
fi
}
PROMPT_DIRTRIM=3
@panta82
panta82 / lsof.js
Last active March 8, 2016 10:51
Get lsof information about a file (list of processes that are accessing that file)
var exec = require('child_process').exec,
util = require('util');
var target = process.argv[2];
if (!target) {
return usage(1);
}
var FIELDS = ['pid', 'command', 'uid', 'lock'];
var FIELD_OPTIONS = {
@panta82
panta82 / slow_copy.js
Created March 8, 2016 10:00
Copy file sloooooowly, so that we can test network related stuff
#!/usr/bin/env node
var fs = require('fs');
var util = require('util');
var DEFAULT_BPS = 10 * 1000; // 10 kb / sec
var source = process.argv[2];
if (!source) {
return usage(1);