This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vendor(prop, args) | |
-webkit-{prop} args | |
-moz-{prop} args | |
-ms-{prop} args | |
-o-{prop} args | |
{prop} args | |
border-radius() | |
vendor('border-radius', arguments) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('a#bookmark').click(function(e){ | |
e.preventDefault(); | |
var bookmarkURL = this.href; | |
var bookmarkTitle = this.title; | |
try { | |
if (window.sidebar) { // moz | |
window.sidebar.addPanel(bookmarkTitle, bookmarkURL, ""); | |
} else if (window.external || document.all) { // ie | |
window.external.AddFavorite(bookmarkURL, bookmarkTitle); | |
} else if (window.opera) { // duh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel | |
// MIT license | |
(function() { | |
var lastTime = 0; | |
var vendors = ['ms', 'moz', 'webkit', 'o']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
echo plural_form(42, array('арбуз', 'арбуза', 'арбузов')); | |
*/ | |
function plural_form($n, $forms) { | |
return $n%10==1&&$n%100!=11?$forms[0]:($n%10>=2&&$n%10<=4&&($n%100<10||$n%100>=20)?$forms[1]:$forms[2]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is from my comment here: http://wolfram.kriesing.de/blog/index.php/2008/javascript-remove-element-from-array/comment-page-2#comment-466561 | |
/* | |
* How to delete items from an Array in JavaScript, an exhaustive guide | |
*/ | |
// DON'T use the delete operator, it leaves a hole in the array: | |
var arr = [4, 5, 6]; | |
delete arr[1]; // arr now: [4, undefined, 6] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// An example on how to parse massive XML files with PHP by chunking it up to avoid running out of memory | |
// Open the XML | |
$handle = fopen('file.xml', 'r'); | |
// Get the nodestring incrementally from the xml file by defining a callback | |
// In this case using a anon function. | |
nodeStringFromXMLFile($handle, '<item>', '</item>', function($nodeText){ | |
// Transform the XMLString into an array and |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env coffee | |
q = require "q" | |
http = require "q-io/http" | |
# npm install q q-io | |
COINBASE_API_KEY = 'XXX' | |
coinbase = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTMLElement = typeof(HTMLElement) != 'undefiend' ? HTMLElement : Element; | |
HTMLElement.prototype.addClass = function(string) { | |
if (!(string instanceof Array)) { | |
string = string.split(' '); | |
} | |
for(var i = 0, len = string.length; i < len; ++i) { | |
if (string[i] && !new RegExp('(\\s+|^)' + string[i] + '(\\s+|$)').test(this.className)) { | |
this.className = this.className.trim() + ' ' + string[i]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Returns a bounding rect for _el_ with absolute coordinates corrected for | |
scroll positions. | |
The native `getBoundingClientRect()` returns coordinates for an element's | |
visual position relative to the top left of the viewport, so if the element | |
is part of a scrollable region that has been scrolled, its coordinates will | |
be different than if the region hadn't been scrolled. | |
This method corrects for scroll offsets all the way up the node tree, so the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function::property = (prop, desc) -> | |
Object.defineProperty @prototype, prop, desc | |
class Person | |
constructor: (@firstName, @lastName) -> | |
@property 'fullName', | |
get: -> "#{@firstName} #{@lastName}" | |
set: (name) -> [@firstName, @lastName] = name.split ' ' | |
p = new Person 'Leroy', 'Jenkins' |
OlderNewer