Skip to content

Instantly share code, notes, and snippets.

@ksykulev
ksykulev / gist:2920501
Created June 12, 2012 22:24
Date Beginning and end of month
function beginningOfMonth(date){
if(typeof date === 'undefined'){
date = new Date();
}
date.setMilliseconds(0);
date.setSeconds(0);
date.setMinutes(0);
date.setHours(0);
date.setDate(1);
return new Date(date);
@ksykulev
ksykulev / imagesLoaded.js
Created August 25, 2011 05:33 — forked from paulirish/README.md
imagesLoaded() jquery plugin - adding unbind for load event
// $('img.photo',this).imagesLoaded(myFunction)
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images
// mit license. paul irish. 2010.
// webkit fix from Oren Solomianik. thx!
// callback function is passed the last image to load
// as an argument, and the collection as `this`
@ksykulev
ksykulev / nodes_by_depth.rb
Created May 14, 2011 20:55
Directory of files by level
# The goal is to traverse a tree and return an array A[0...h], where h is the height
# of the tree and A[i] is an array of items at height i.
# example:
# tree ->
# 0
# 1 2
# 3 4 5 6
# 7 8 9 10 11 12 13 14
#
# should give you: