Skip to content

Instantly share code, notes, and snippets.

@adarrra
adarrra / restart_coreaudiod.sh
Created January 19, 2018 10:33 — forked from rponte/restart_coreaudiod.sh
Restarting MacOSX coreaudiod process gracefully
sudo launchctl stop com.apple.audio.coreaudiod
@adarrra
adarrra / destructuring_examples.js
Last active May 4, 2017 10:10
Destructuring examples + spread
// ========== OBJECTS ==================
// the most used
const {x} = {x: 1}; // x === 1
getSuggestions (request) {
const { prefix, bufferPosition, editor } = request;
}
@adarrra
adarrra / random_color_generator.js
Last active May 4, 2017 09:42
Random color generator
function getColor(someString) {
// simple stupid hash func, beware of Number.MAX_VALUE => Infinity => Nan :) alsow its slow
const hash = parseInt(Array.from(someString, char => char.charCodeAt(0)).join(''));
const hue = hash%360;
const saturation = seededRand(hue, 13, 28);
const lightness = seededRand(hue, 65, 72);
return `hsla(${hue}, ${saturation}%, ${lightness}%, 1)`;
}
function seededRand(seed, min, max) {
@adarrra
adarrra / random_with_step.js
Created September 14, 2016 12:10
random number with step
function randomWithStep(min, max, step) {
let prev;
return function () {
let current;
function countFormula() {
current = min + (step * Math.floor(Math.random()*(max-min)/step));
}
do {
countFormula();
}
[user]
me
me@
[alias]
st = status -s -b
oneline = "!f () { git log --graph --color=always --abbrev-commit --date=relative --pretty=format:'%x00%h%x00%s%x00%cd%x00%an%x00%d' $@ | gawk -F '\\0' '{ printf \"%s\\033[31m%s\\033[0m %-80s \\033[32m%14s\\033[0m \\033[30;1m%s\\033[0m\\033[33m%s\\n\", $1, $2, gensub(/(.{79}).{2,}/, \"\\\\1…\",\"g\",$3), $4, $5, $6 }' | less -R; }; f"
lg = log --graph --pretty=tformat:'%C(red)%h - %C(blue)%an %C(reset)%s %C(green)(%ci) %C(bold green)%d'
logsvn = log --pretty=tformat:'%C(red)%h - %C(reset)%s %C(blue)%an %C(green)(%cr)%n%C(bold green)%b'
gg = grep -En --break --heading