Skip to content

Instantly share code, notes, and snippets.

* html .shimmed {
_azimuth: expression(
this.shimmed = this.shimmed || 'shimmed:'+this.insertAdjacentHTML('beforeBegin','<IFRAME style="filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0);position:absolute;top:0px;left:0px;width:100%;height:100%" frameBorder=0 scrolling=no src="javascript:'+"''"+'"></IFRAME>'),
'inherit'
);
}
Array.implement('batch', function(callback, loopsPerBatch, delay, bind) {
if(!loopsPerBatch) loopsPerBatch = 10;
if(!delay) delay = 50;
if(callback) {
var loops = 0,
index = 0,
that = this;
function doLoops() {
loops = 0;
for (var length = that.length; (index < length) && loops < loopsPerBatch; index++) {
@alxrocha
alxrocha / git-transmit
Created January 4, 2012 14:40 — forked from subtleGradient/git-transmit
git-transmit opens your recently modified files using Panic's Transmit.app DockSend
#!/usr/bin/env bash
# author: Thomas Aylott SubtleGradient.com
echo "Transmitting"
for i in `git log -${1:-1} $2 --name-only|grep -E '^[^ ]+$'|sort|uniq`; do
if [[ -e $i ]]; then
echo " $i"
open -a Transmit $i
fi
done
@alxrocha
alxrocha / gist:2846429
Created May 31, 2012 21:28 — forked from mataspetrikas/gist:2300296
Check if the DOM node is visible in the viewport
function elementInViewport(el) {
var rect = el.getBoundingClientRect()
return rect.top < (window.innerHeight || document.body.clientHeight) && rect.left < (window.innerWidth || document.body.clientWidth);
}
// and then you can use it:
alert(elementInViewport(document.getElementById('inner')));
// or
alert(elementInViewport($('#inner')[0]));​
`
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
//
// the regular expression composed & commented
// could be easily tweaked for RFC compliance,
// it was expressly modified to fit & satisfy
// these test for an URL shortener:
@alxrocha
alxrocha / gist:2999119
Created June 26, 2012 21:17 — forked from abozhilov/gist:2997730
Wildcard to RegExp
/**
* Convert wildcard pattern to RegExp
* Pattern:
* * - Zero or more characters
* ? - Exactly one character
*
* @param {String} pattern Wildcard pattern
* @returns {RegExp} regular expression for wildcard matching
*/
function wc2reg(pattern) {
@alxrocha
alxrocha / senderror.js
Created June 30, 2012 19:34 — forked from pamelafox/senderror.js
Sending JS errors to server
function sendError(message, url, lineNum) {
var i;
// First check the URL and line number of the error
url = url || window.location.href;
lineNum = lineNum || 'None';
// If the error is from these 3rd party script URLs, we ignore
// We could also just ignore errors from all scripts that aren't our own
var scriptURLs = [
(function (exports) {
var supportsGCS = "defaultView" in exports.document && "getComputedStyle" in exports.document.defaultView;
function getStyle(element, property) {
// `element.ownerDocument` returns the used style values relative to the
// element's parent document (which may be another frame). `defaultView`
// is required for Safari 2 support and when retrieving framed styles in
// Firefox 3.6 (https://github.com/jquery/jquery/pull/524#issuecomment-2241183).
var style = supportsGCS ? element.ownerDocument.defaultView.getComputedStyle(element, null) : element.currentStyle;
return (style || element.style)[property];
/**
*
* Here's a thing that will look through all the text nodes of a document, and
* upon encountering an emoji codepoint, will replace it with an image.
* For now, those images are pulled from GitHub, which isn't very nice, so I
* need to find a more suitable host.
*
* Much of this code was gleaned from staring at the minified GitHub JS.
*
* Copyright (c) 2013 Mark Wunsch. Licensed under the MIT License.
var get = Ember.get;
/**
* @extends Ember.Mixin
*
* Implements common filter / sort / pagination behavior for array controllers
* */
Ember.FilterSortSliceMixin = Ember.Mixin.create({
filterBy: '',