Skip to content

Instantly share code, notes, and snippets.

Avatar

Tamás Halasi trustedtomato

View GitHub Profile
@trustedtomato
trustedtomato / alacritty.sh
Created Dec 28, 2019
Open alacritty in current directory.
View alacritty.sh
alacritty --working-directory $(DIR=$(xprop -id $(xprop -root '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) 8t '\t$0' _NET_WM_NAME | cut -f 2 | grep -Po '(?<=:).*(?=")' | sed "s|^~|$HOME|"); if [ -d "$DIR" ]; then echo $DIR; else echo $HOME; fi)
@trustedtomato
trustedtomato / .bash_aliases
Last active May 6, 2019
Debian post-install script.
View .bash_aliases
alias clipboard='xclip -selection c'
View system-font-stack.css
/* System Fonts as used by GitHub */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
/* System Fonts as used by Medium and WordPress */
body {
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
}
@trustedtomato
trustedtomato / cursor.ts
Last active Oct 22, 2017
Tracking cursor position & improved mousemove event
View cursor.ts
const cursor = (() => {
const cursorEventTarget = Object.assign(document.createDocumentFragment(), {x: 0, y: 0});
let changed = false;
const onmove = (e:MouseEvent) => {
if(cursorEventTarget.x !== e.x || cursorEventTarget.y !== e.y){
cursorEventTarget.x = e.x;
cursorEventTarget.y = e.y;
changed = true;
}
};
@trustedtomato
trustedtomato / all-mp3-to-opus
Last active Dec 10, 2017
Covert all mp3 to opus
View all-mp3-to-opus
find . -exec ffmpeg -i {} -acodec libopus -b:a 64k -n -vbr on -compression_level 10 ~/Documents/opus/{}.opus \;
@trustedtomato
trustedtomato / wait-frame.js
Created Aug 31, 2017
requestAnimationFrame Promise
View wait-frame.js
const waitFrame = () => new Promise(requestAnimationFrame);
@trustedtomato
trustedtomato / twoExp.js
Created Aug 30, 2017
2^n in an other way
View twoExp.js
twoExp = n => eval('0b1' + Array(n - 1).fill(0).join(''));
@trustedtomato
trustedtomato / wait-for-key.js
Last active Aug 25, 2017
Wait for a key in JS
View wait-for-key.js
/** Wait for the given key; if key is omitted, any key will trigger. It resolves the event. */
function waitForKey(key){
return new Promise(resolve => {
var onkeydown = e => {
if(typeof key === 'undefined' || e.key === key){
document.removeEventListener('keydown', onkeydown);
resolve(e);
}
};
document.addEventListener('keydown', onkeydown);
@trustedtomato
trustedtomato / curry.js
Last active Aug 25, 2017
Javascript ES6 currying
View curry.js
function curry(fn){
const len = fn.length;
const next = oldArgs => (...newArgs) => {
const args = oldArgs.concat(newArgs);
return (args.length >= len)
? fn.apply(this, args)
: next(args);
};
return next([]);
};