Skip to content

Instantly share code, notes, and snippets.

View leeoniya's full-sized avatar
😕
shaving bytes and milliseconds. dependencies: {}

Leon Sorokin leeoniya

😕
shaving bytes and milliseconds. dependencies: {}
View GitHub Profile
@rkatic
rkatic / README.md
Created February 16, 2010 02:19
type() - a better typeof

type.js - offers an more consistent type checking of native values. It relays on the [[Class]] of objects instead on typeof results.

type2.js - variation that returns "object" for wrapped natives. This one is probably more noob-immune, avoiding some possible strange situations.

Consider something like this:

// Defined by third...

var foo = new String("foo");

@cowboy
cowboy / queue-explain.js
Created March 2, 2010 15:12
Serial asynchronous actions...
// Comments for http://bjam.in/jquery-queue
// Say you want to execute first_async_action() followed by
// second_async_action(), followed by third_async_action().
// You could do this:
first_async_action(function(){
second_async_action(function(){
third_async_action(function(){
alert( 'done!' );
/**
* modified from http://gist.github.com/527683
* only improve slightly to get small
*/
var ie = function(v, p, needle, undef) {
needle = p.getElementsByTagName('br');
while(
p.innerHTML = '<!--[if gt IE ' + (++v) + ']><br><![endif]-->',
@jbrumwell
jbrumwell / oo.php
Created September 23, 2010 18:56 — forked from dhotson/oo.php
<?php
// Define the 'class' class
$class = Obj()
->fn('new', function ($class) {
$newClass = Obj($class->methods)
->fn('new', function($class) {
$obj = Obj($class->imethods);
$args = func_get_args();
array_shift($args);
@jeremeamia
jeremeamia / gist:633632
Created October 19, 2010 04:51
PHP is so weird
<?php // Some lovely, valid php code that prints "foofoo"
echo${${($f='f').(${$o='o'}).${$o}}=${$f}.$${$$o}.$$${$$$o}};
echo$$$$$$$$$$$$$$$$$$$$${(${(${(${(${(${($$$foo)})})})})})};
@cowboy
cowboy / ba-curry.js
Created November 30, 2010 01:59
JavaScript Curry
/*!
* JavaScript Curry - v0.1pre - 11/29/2010
* http://benalman.com/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
function curry(/* n,*/ fn /*, args...*/) {
@jakelodwick
jakelodwick / neat_r.php
Created January 8, 2011 17:27
neat_r, a tidy alternative to print_r (PHP)
<?PHP
/*
neat_r works like print_r but with much less visual clutter.
By Jake Lodwick. Copy freely.
Example with an array:
$data = array(
"mode" => "sets",
@kof
kof / defer 1
Created January 21, 2011 14:48
deffered function execution
(function(global){
var $ = global.jQuery || global,
D = Date,
now = D.now || function() {
return (new D).getTime();
};
// if once is true, fn will be executed only once if called more then one times during the time in delay.
// if once is not defined or false, fn will be executed periodically, period is delay.
jQuery._Deferred = function() {
var // callbacks list
callbacks = [],
// stored [ context , args ]
fired,
// to avoid firing when already doing so (or it is halted)
firing,
// flag to know if the deferred has been cancelled
cancelled,
// the deferred itself
@cowboy
cowboy / javascript-type-stuff.js
Created February 16, 2011 16:13
JavaScript Type Stuff
// ============================================================
// Objects vs Primitives
// To make a long story short, use primitives wherever you can.
// ============================================================
// Primitive types: Null, Undefined, Number, Boolean, String.
var num1 = 9000,
num2 = new Number( 9000 ),
str1 = "hello world",