Skip to content

Instantly share code, notes, and snippets.

@RubaXa
RubaXa / 0example.js
Created April 24, 2012 06:13 — forked from Raynos/0example.js
IndexedDB API made better
// jsfiddle: http://jsfiddle.net/Pj7G4/1/
var store = indexeddbStore("user")
store.put({ name: "bob" }, "bob", function (err, result) {
store.get("bob", function (err, user) {
console.log(user.name === "bob")
})
})
@RubaXa
RubaXa / jquery.event.fix.js
Created June 19, 2012 14:13 — forked from justinbmeyer/fastfix.js
Makes jQuery.event.fix fast
// http://bitovi.com/blog/2012/04/faster-jquery-event-fix.html
// https://gist.github.com/2954434 (original: https://gist.github.com/2377196)
// http://jsperf.com/jquery-event-fix/6
// IE 8 has Object.defineProperty but it only defines DOM Nodes. According to
// http://kangax.github.com/es5-compat-table/#define-property-ie-note
// All browser that have Object.defineProperties also support Object.defineProperty properly
Object.defineProperties && (function (document, $){
var
@RubaXa
RubaXa / gist:4084463
Created November 16, 2012 05:33
xtpl vs. fest

Fest

<?xml version="1.0"?>
<fest:template xmlns:fest="http://fest.mail.ru" context_name="json">
	<div class="elm">
		<fest:attributes>
			<fest:attribute name="id">box</fest:attribute>
			<fest:attribute name="style">color: red;</fest:attribute>
			<fest:attribute name="class"><fest:space/>js-elm</fest:attribute>
/**
* Watcher leaks for jQuery
* RubaXa <trash@rubaxa.org>
* MIT Licensed.
*
* API:
* $.leaks.get();
* $.leaks.watch();
* $.leaks.unwatch();
* $.leaks.remove();
<fest:template>
&bem b-datalist {
ctx.head ? &__head ctx.head
for item in ctx.items {
&__item item
}
ctx.foot ? &__foot ctx.foot
}
@RubaXa
RubaXa / jquery.event.scroll.js
Last active December 17, 2015 06:58
jQuery extension, add support `scrollstart` and `scrollend` events.
/**
* jQuery extension, add support `scrollstart` and `scrollend` events.
*
* @author RubaXa <trash@rubaxa.org>
* @github https://gist.github.com/RubaXa/5568964
* @license MIT
*
*
* @settings
* $.special.scrollend.delay = 300; // default ms
@RubaXa
RubaXa / jquery.classList.js
Last active December 17, 2015 07:48
jQuery extension, add support `classList`.
/**
* jQuery extension, add support `classList`.
*
* @author RubaXa <trash@rubaxa.org>
* @license MIT
*/
(function ($){
var
_rspace = /\s+/
@RubaXa
RubaXa / jquery.fn.find.js
Last active April 14, 2016 15:47
Fastest jQuery.fn.find
/**
* Fastest jQuery.fn.find
* @jsperf http://jsperf.com/jquery-find-vs-jquery-fastestfind
* @author RubaXa <ibnRubaXa@gmail.com>
* @license MIT
*/
/* global document, jQuery */
document.createElement('div').querySelectorAll && (function ($, originalFind){
var el = document.getElementById('choose');
FileAPI.event.on(el, 'change', function (evt){
var files = FileAPI.getFiles(evt);
FileAPI.filterFiles(files, function (file, info){
return /^image/.test(file.type);
}, function (files, ignor){
if( files.length ){
// ...
}
@RubaXa
RubaXa / PickMeUp
Last active December 28, 2015 18:59
PickMeUp в 30 строк
/*! PickMeUp - jQuery datepicker plugin | Nazar Mokrynskyi <nazar@mokrynskyi.com> | Stefan Petre <www.eyecon.ro> MIT */
(function(d){function getMaxDays(){var tmpDate=new Date(this.toString()),d=28,m=tmpDate.getMonth();while(tmpDate.getMonth()==m){++d;tmpDate.setDate(d);}return d-1;}d.addDays=function(n){this.setDate(this.getDate()+n);};d.addMonths=function(n){
var day=this.getDate();this.setDate(1);this.setMonth(this.getMonth()+n);this.setDate(Math.min(day,getMaxDays.apply(this)));};d.addYears=function(n){var day=this.getDate();this.setDate(1);this.setFullYear(this.getFullYear()+n);this.setDate(Math.min(day,getMaxDays.apply(this)));};d.getDayOfYear=function(){var now=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0);var then=new Date(this.getFullYear(),0,0,0,0,0);var time=now-then;return Math.floor(time/24*60*60*1000);};})(Date.prototype);(function($){
$.pickmeup=$.extend($.pickmeup||{},{date:new Date,flat:false,first_day:1,prev:"&#9664;",next:"&#9654;",mode:"single",view:"days",calendars:1,f