Skip to content

Instantly share code, notes, and snippets.

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

Michał Kuklis mkuklis

🏃‍♂️
View GitHub Profile
@mkuklis
mkuklis / gist:4253970
Created December 10, 2012 22:36
zepto.swipe
(function ($) {
var startPos, curPos, endPos, dragTimer, dragEl, dragOffset;
var isTouchable = (function () { return !!('ontouchstart' in window); })();
var events = {
touchstart: "mousedown",
touchmove: "mousemove",
touchend: "mouseup"
};
@mkuklis
mkuklis / gist:4326271
Created December 18, 2012 08:52
requirejs CommonJS style
define(function (require, exports, module) {
var lib1 = require('lib1');
var lib2 = require('lib2');
// your code goes here
// exports = ...;
});
@mkuklis
mkuklis / gist:4576884
Last active December 11, 2015 08:58
playing with clojure
(def my-apply
(fn [function sequence]
(eval (cons function sequence))))
;; exercises
;; chapter 1
;; 3. add squares
(defn add-squares [& args]
(apply + (map * args args)))
@mkuklis
mkuklis / gist:4689023
Created February 1, 2013 03:43
requirejs + cordova
require.config({
dir: "../../release/js/",
optimize: "uglify",
paths: {
jquery: 'vendor/jquery/jquery-1.9.0',
underscore: 'vendor/underscore',
backbone: 'vendor/backbone/backbone',
text: 'vendor/require/plugins/text',
cordova: 'vendor/android/cordova-2.3.0'
@mkuklis
mkuklis / gist:4712839
Last active December 12, 2015 04:18
requirejs+flight
// requirejs config in main.js
require.config({
paths: {
jquery: 'components/jquery/jquery',
es5shim: 'components/es5-shim/es5-shim',
es5sham: 'components/es5-shim/es5-sham'
},
map: {
'*': {
'flight/component': 'components/flight/lib/component',
@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 {};
@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: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: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: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) ?