Skip to content

Instantly share code, notes, and snippets.

// The `quickEach` method will pass a non-unique jQuery instance
// to the callback meaning that there will be no need to instantiate
// a fresh jQuery instance on each iteration. Most of the slow-down
// inherent in jQuery's native iterator method (`each`) is the constant
// need to have access to jQuery's methods, and so most developers
// see constructing multiple instances as no issue... E.g.
// $(...).each(function(){ $(this)... $(this)... $(this)... });
// A better approach would be `quickEach`.
jQuery.fn.quickEach = (function(){
var xmpp = require('../lib/node-xmpp');
var sys = require("sys");
var redis = require("redis-node");
var redispub = redis.createClient();
var redissub = redis.createClient();
var port = parseInt(process.argv[process.argv.length - 1]);
if(isNaN(port)) {
console.log("You need to supply a port!")
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@mweibel
mweibel / mod_msg_filter.erl
Created April 26, 2012 05:55 — forked from mardambey/mod_msg_filter.erl
mod_msg_filter allows the filtering of "message" stanzas across an HTTP service.
%% mod_msg_filter allows the filtering of "message"
%% stanzas across an HTTP service. The URL of the
%% service must be passed as part of the module's
%% configuration. Both JIDs and their resources are
%% passed as part of the query string and the result
%% is expected to be one of:
%%
%% <status value="denied">
%% <stanza1><error/></stanza1>
%% <stanza2><error/></stanza2>
@michaelcox
michaelcox / xdr.js
Created May 10, 2012 18:56
Adds XDomainRequest IE CORS support to jQuery
// Based on https://github.com/jaubourg/ajaxHooks/blob/master/src/ajax/xdr.js
(function( jQuery ) {
if ( window.XDomainRequest && !jQuery.support.cors ) {
jQuery.ajaxTransport(function( s ) {
if ( s.crossDomain && s.async ) {
if ( s.timeout ) {
s.xdrTimeout = s.timeout;
delete s.timeout;
@pstadler
pstadler / ej.sh
Created October 19, 2012 13:03
ejabberd control script
function ej {
EJABBERD_HOME=/usr/local/ejabberd-commercial
EJABBERD_CTL=$EJABBERD_HOME/sbin/ejabberdctl
case "$1" in
restart)
$EJABBERD_CTL stop && $EJABBERD_CTL stopped; $EJABBERD_CTL start
;;
reload)
$EJABBERD_CTL update $2
@lloydwatkin
lloydwatkin / init.properties
Created February 5, 2013 17:00
Tigase for buddycloud
--cluster-mode = false
config-type = --gen-config-all
--cluster-nodes = ip-10-66-2-93
--debug=server,xmpp.impl,db
--user-db = derby
--admins = admin@ip-10-66-2-93
--user-db-uri = jdbc:derby:/opt/tigase/tigasedb
--virt-hosts=ip-10-66-2-93,localhost
--comp-name-1=ext
--comp-class-1 = tigase.server.ext.ComponentProtocol
ENC="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8"
DRV="-Djdbc.drivers=com.mysql.jdbc.Driver:org.postgresql.Driver:org.apache.derby.jdbc.EmbeddedDriver"
#GC="-XX:+UseBiasedLocking -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:ParallelCMSThreads=2"
JAVA_HOME="/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64"
CLASSPATH=""
#JAVA_OPTIONS="${GC} ${ENC} ${DRV} -server -Xms100M -Xmx200M -XX:PermSize=32m -XX:MaxPermSize=256m -XX:MaxDirectMemorySize=128m "
JAVA_OPTIONS="${GC} ${ENC} ${DRV} -server -Xms200M -Xmx400M -XX:PermSize=64m -XX:MaxPermSize=512m -XX:MaxDirectMemorySize=256m "
TIGASE_CONFIG="etc/tigase.xml"
TIGASE_OPTIONS=" --property-file etc/init.properties"
@bgrins
bgrins / Log-.md
Last active July 11, 2024 13:40
Prevent errors on console methods when no console present and expose a global 'log' function.

Javascript log Function

Every time I start a new project, I want to pull in a log function that allows the same functionality as the console.log, including the full functionality of the Console API.

There are a lot of ways to do this, but many are lacking. A common problem with wrapper functions is that the line number that shows up next to the log is the line number of the log function itself, not where log was invoked. There are also times where the arguments get logged in a way that isn't quite the same as the native function.

This is an attempt to once and for all document the function that I pull in to new projects. There are two different options:

  • The full version: Inspired by the plugin in HTML5 Boilerplate. Use this if you are writing an application and want to create a window.log function. Additionally,
@mweibel
mweibel / passport-mock.js
Last active May 14, 2024 09:32
Mock passport.js with an own strategy
/**
* Author: Michael Weibel <michael.weibel@gmail.com>
* License: MIT
*/
var passport = require('passport')
, StrategyMock = require('./strategy-mock');
module.exports = function(app, options) {
// create your verify function on your own -- should do similar things as