Skip to content

Instantly share code, notes, and snippets.

View incik's full-sized avatar
🚀
Kerbal way forward!

Tomáš Vaisar incik

🚀
Kerbal way forward!
View GitHub Profile
@incik
incik / gameLogic.ts
Created January 13, 2021 15:18
Logic of 2048
export enum Direction {
Up = 'Up',
Right = 'Right',
Down = 'Down',
Left = 'Left',
}
export interface XY {
x: number;
y: number;
@incik
incik / .gitconfig
Last active October 16, 2017 20:05
Git aliases
[alias]
up = pull --rebase --autostash
br = branch
st = status
ci = commit
ciam = commit --amend --no-edit
co = checkout
pf = push --force-with-lease
pb = "!git push -u origin \"$(git rev-parse --abbrev-ref HEAD)\""
clean-local = "!git branch --merged | grep -v \"\\*\" | xargs -n 1 git branch -d"
@incik
incik / snakify.js
Created October 8, 2015 09:27
Transform camelCase keys of an object into snake_case
function snakifyKeys(fields) {
// because this function can receive map of ArrayNodes, we have to do this
let jsonFields = JSON.parse(JSON.stringify(fields));
for (let key in jsonFields) {
if (jsonFields[key] instanceof Object) {
// we need to go deeper!
jsonFields[key] = snakifyKeys(jsonFields[key]);
}
@incik
incik / wait_for_it.js
Last active December 24, 2015 07:39
'onChange' callback delayed until user stops changing value of input
/* Calls callback function if value of given element stops changing
elem - element which's value we're watching
callback - anonymous method or callback fuction name
(delay) - delay before callback
*/
wait_for_it = function(elem, callback, delay) {
var old_val;
if (delay == null) {
delay = 750;
@incik
incik / wait_for_it.coffee
Last active December 24, 2015 07:19
'onChange' callback delayed until user stops changing value of input
# Calls callback function if value of given element stops changing
#
# elem - element which's value we're watching
# callback - anonymous method or callback fuction name
# (delay) - delay before callback
wait_for_it = (elem, callback, delay = 750) ->
old_val = elem.val()
setTimeout ( ->
if elem.val() == old_val