Skip to content

Instantly share code, notes, and snippets.

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

Michał Kuklis mkuklis

🏃‍♂️
View GitHub Profile
@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();

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: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) {
@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 / 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:5294248
Last active September 7, 2021 21:39
auto curry in JavaScript
function toArray(args) {
return [].slice.call(args);
}
function autocurry(fn) {
var len = fn.length;
var args = [];
return function next() {
args = args.concat(toArray(arguments));
return (args.length >= len) ?
@mkuklis
mkuklis / gist:5249966
Last active December 15, 2015 10:59
array splice
var splice = Array.prototype.splice;
function arraySplice(array1, array2) {
return splice.apply(array1, [0, array2.length].concat(array2));
}
@mkuklis
mkuklis / gist:5007219
Last active December 14, 2015 01:38
backbone.record.js
// backbone.record
(function (Backbone) {
"use strict";
var api = {
initialize: function () {},
removeAll: function () {
@mkuklis
mkuklis / gist:5002179
Last active December 14, 2015 00:49
flight asCollection mixin
'use strict';
define(
['./provider'],
function (provider) {
function AsCollection() {
@mkuklis
mkuklis / gist:4742173
Created February 8, 2013 21:43
commonjs, amd, global
(function (root, factory) {
if (typeof exports === 'object') {
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {
define(factory);
} else {
root.returnExports = factory();
}
}(this, function () {
return {};