Skip to content

Instantly share code, notes, and snippets.

View mkuklis's full-sized avatar
🏃‍♂️

Michał Kuklis mkuklis

🏃‍♂️
View GitHub Profile
@mkuklis
mkuklis / LICENSE.txt
Last active December 15, 2015 17:29 — forked from 140bytes/LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@mkuklis
mkuklis / gist:5329126
Last active December 15, 2015 21:58
playing with bind, call and apply
var foo = function () {
console.log(this);
console.log(arguments);
}
var context = {};
// shortcut with predefined context and arguments
var bar = Function.prototype.call.bind(foo, context, 'arg1', 'arg2');
bar('arg3'); // context, ["arg1", "arg2", "arg3"]
@mkuklis
mkuklis / gist:5437711
Created April 22, 2013 19:17
interval mixin
function intervalMixin() {
var intervals = [];
return {
addInterval: function (func, delay) {
intervals.push({ func: func.bind(this), delay: delay });
},
startIntervals: function () {
intervals.forEach(function (interval) {

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@mkuklis
mkuklis / gist:5835614
Last active June 12, 2016 07:44
run zepto.js animations in sequence
$.fn.queueAnim = function (steps, callback) {
var $selector = this;
function iterator(step) {
step.push(iterate);
$selector.animate.apply($selector, step);
}
function iterate() {
if (!steps.length) return callback && callback();
@mkuklis
mkuklis / gist:5942570
Created July 7, 2013 06:39
elo rating
function elo(oldRating, opponentRating, result) {
var kFactor;
var expected = 1.0 / (1.0 + Math.pow(10.0, ((opponentRating - oldRating) / 400)));
if (oldRating < 2100) {
kFactor = 32;
} else if (oldRating >= 2100 && oldRating <= 2400) {
kFactor = 24;
}
else if (oldRating > 2400) {
@mkuklis
mkuklis / LICENSE.txt
Last active February 5, 2023 03:20 — forked from 140bytes/LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# dump heroku db
heroku pgbackups:capture
# restore
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U postgres -d database_name DUMP_PATH
@mkuklis
mkuklis / gist:7587994
Created November 21, 2013 19:28
KitKat test for WebSocket
function hasWebSocket() {
var m = navigator.userAgent.match(/Android ([0-9]+)\.([0-9]+)/i);
if (m) {
var x = parseInt(m[1], 10);
var y = parseInt(m[2], 10);
return window.WebSocket && (x > 4 || (x == 4 && y >= 4));
}
@mkuklis
mkuklis / run.js
Last active January 4, 2016 07:59
simple run
function run(genfun) {
var gen = genfun();
function next(err, answer) {
if (err) {
return gen.throw(err);
}
var res = gen.next(answer);