Skip to content

Instantly share code, notes, and snippets.

View scottgonzalez's full-sized avatar

Scott González scottgonzalez

View GitHub Profile
@scottgonzalez
scottgonzalez / jquery-element.js
Created November 13, 2009 02:32
jQuery object normalization
function element(value, context) {
var ret = $([]); // $(context) ?
if (value.jquery) {
ret = value;
} else if (value == 'parent') {
ret = $(context).parent();
} else if (value == 'clone') {
ret = $(context).clone().removeAttr('id');
} else if (value == 'window') {
var http = require("http"),
querystring = require("querystring"),
sys = require("sys");
var channel = "http://chat.nodejitsu.com/chat",
speed = 5000,
spammers = 10;
for (var i = 0; i < spammers; i++ ) {
setTimeout(startSpamming, (speed / spammers) * i);
#!/usr/bin/env node
var sys = require("sys"),
fs = require("fs"),
chat = require('../lib/server'),
router = require("../lib/router");
// create chat server
var chatServer = chat.createServer();
chatServer.listen(8001);
var crypto = require('crypto');
["sha1", "md5", "sha256", "sha512", "ripemd160"].forEach(function(algo) {
exports[algo] = function(data, salt) {
return (typeof salt != 'undefined' ?
crypto.createHmac(algo, salt) :
crypto.createHash(algo)
).update(data).digest("hex");
};
});
var initSource = $.ui.autocomplete.prototype._initSource;
$.ui.autocomplete.prototype._initSource = function() {
if ( typeof this.options.source === "string" && this.options.cache ) {
var self = this,
cache = {};
this.source = function( request, response ) {
var term = request.term;
if ( cache[ term ] ) {
response( cache[ term ] );
$.widget( "ui.autocomplete", $.ui.autocomplete, {
_suggest: function( items ) {
var menu = this.menu.element,
width = menu.width(),
height = menu.height();
this._super( "_suggest", items );
var newWidth = menu.width(),
newHeight = menu.height();
menu.css({
width: width,
$.event.special.hijax = {
setup: function() {
$.event.add( this, "click.specialHijax", function( event, data ) {
if ( event.which !== 1 || event.metaKey || event.ctrlKey ) {
return;
}
event.type = "hijax";
event.liveFired = undefined;
return jQuery.event.trigger( event, data, event.target );
/[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0525\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0621-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971\u0972\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-
(function( $ ) {
$( "a[data-replace]" ).live( "click", function( event ) {
var anchor = $( this ),
replace = $( "#" + anchor.attr( "data-replace" ) ),
href = anchor.attr( "href" );
replace
.trigger( "replaceSend", [ {
anchor: anchor,
amplify.request.ajaxPollErrors = {
404: true
};
amplify.request.types[ "ajax-poll" ] = function( resource ) {
var baseResourceId = "ajax-poll-" + resource.resourceId;
amplify.request.define( baseResourceId, "ajax", resource );
return function( settings, request ) {