Skip to content

Instantly share code, notes, and snippets.

@porqz
porqz / gist:1549879
Created January 2, 2012 08:33
Event listeners
/*
* By @arestov
*/
var addEvent = window.addEventListener ?
function (elementent, eventType, fn) {
element.addEventListener(eventType, fn, false);
return fn;
}:
function (element, eventType, fn) {
var isTransitionSupported = function () {
var style = (document.body || document.documentElement).style,
property = "transition";
if (typeof style[property] === "string") return true;
var prefixes = ["Moz", "Webkit", "Khtml", "O", "ms"];
property = property.charAt(0).toUpperCase() + property.substr(1);
@porqz
porqz / 1.js
Last active December 14, 2015 03:49 — forked from padolsey/1.js
var x = "/x/";
/x/==x
//#import ;
JSContext *context = [[JSContext alloc] init];
JSValue *result = [context evaluateScript:@"2 + 8"];
NSLog(@"2 + 8 = %d", [result toInt32]);
@porqz
porqz / safari-bookmarks-as-xml.sh
Created December 27, 2013 22:14
Gets Safari bookmarks as XML
# Open the binary Safari bookmarks plist and convert it to XML
/usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist
@porqz
porqz / commands.sh
Last active February 13, 2020 12:10
Some useful shell commands (including macOS specialized)
# Current weather and forecast
curl http://wttr.in/
# ASCII Star Wars
nc towel.blinkenlights.nl 23
# or
telnet towel.blinkenlights.nl
# Turn off Mac’s startup sound
sudo nvram SystemAudioVolume=%80

Oops! I accidentally deleted a local git branch, and I haven't pushed it to a remote server yet. The branch has several important commits, and it hasn't been merged with any other branches yet. How do I find the missing branch?

1. Create a list of all dangling or unreachable commits.

$ git fsck --full --no-reflogs --unreachable --lost-found
unreachable tree 4a407b1b09e0d8a16be70aa1547332432a698e18
unreachable tree 5040d8cf08c78119e66b9a3f8c4b61a240229259
unreachable tree 60c0ce61b040f5e604850f747f525e88043dae12
unreachable tree f080522d06b9853a2f18eeeb898724da4af7aed9
var pathUtils = require('path');
/**
* Вычисляет относительный путь для `absolutepath`
*
* @param {string} absolutePath Абсолютный путь
* @param {string} relativeTo Путь (абсолютный), относительно которого вычисляется результат
*
* @returns {string} Относительный путь
*/
/**
* Chooses plural form of a word that corresponds to a number
*
* @param {number} number The number
* @param {string} zeroCaseForm Zero-ending form (ворон)
* @param {string} oneCaseForm One-ending form (ворона)
* @param {string} twoCaseForm Two-ending form (вороны)
*
* @returns {string} Plural form of the word
*/
ttyPath=$(tty); ttyName=${ttyPath:5}; tmux new -s $ttyName || tmux -2 attach-session -t $ttyName