Skip to content

Instantly share code, notes, and snippets.

@addyosmani
addyosmani / pubsub.md
Created October 28, 2011 06:49
Four ways to do Pub/Sub with jQuery 1.7 and jQuery UI (in the future)

#Four Ways To Do Pub/Sub With jQuery and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

@xeoncross
xeoncross / f.php
Created December 20, 2011 22:30
1kB Forum with added IP logging
<?checkdnsrr(join('.',array_reverse(explode('.',$p=getenv('REMOTE_ADDR')))).".opm.tornevall.org","A")&&die('Bad Bot');mysql_connect(0,'root','');mysql_select_db('d');extract($_REQUEST);$v=(int)@$v;$i=0;$q='mysql_query';$f='mysql_fetch_row';$n='mysql_num_rows';$x='<input type="';$s="SELECT*FROM";$t='CREATE TABLE IF NOT EXISTS t(i INT AUTO_INCREMENT,a INT,b TEXT,KEY(i))';$h='htmlspecialchars';$q($t);$q(strtr($t,'t','p'));$l=' ORDER BY';$o='';$u='INSERT INTO';$c="b)VALUES(";if(@$b){if(!$v)$q("$u t(a,$c INET_ATON('$p'),'$e')");$v=max($v,mysql_insert_id());$q("$u p(a,$c'$v','$b')");}if($v){$t=$q("$s p WHERE a=$v$l i");echo'<a href="f.php">Back</a>';for(;$i<$n($t);++$i){$r=$f($t);echo'<hr/>'.nl2br($h($r[2]));}}else{$t=$q("$s t$l-i");for(;$i<$n($t);++$i){$r=$f($t);echo'<a href="f.php?v='.$r[0].'">'.$h($r[2]).'</a><br/>';}$o='Title:'.$x.'text"name="e"/><br/>';}echo'<hr/>Post:<form method="post">'.$x.'hidden"name="v"value="'."$v\"/>$o<textarea name=\"b\"></textarea>$x";?>submit"name="w"value="Post"/></form>
anonymous
anonymous / bootstrap-notifications.js
Created January 6, 2012 09:43
Javascript for notifications (alerts) for Twitter Bootstrap
/*
I created the following javascript to use bootstrapt's notifications through Javascript.
If you like it you may consider adding it to bootstrapt. Feel free to modify if necessary.
Be sure you define a div #notification-area, where the notifications are going to be displayed by default.
I use it with jQuery 1.7.1 but it should work with older versions. Is also use jquery.hotkeys.js ( https://github.com/jeresig/jquery.hotkeys ) for block messages hotkeys
*/
(function( $ ){
var pub = {
@farnoy
farnoy / main.go
Created February 12, 2012 10:38
golang websockets
package main
import (
"websocket"
"http"
"fmt"
"io"
)
func EchoServer(ws *websocket.Conn) {
@chrissharkey
chrissharkey / impartialoutsider.coffee
Created March 11, 2012 20:03
Pizza voting IRC bot in Node.js
#!/usr/bin/env node
CHANNEL = '#bozler'
MINIMUM_HUMAN_REACTION = 2
DIALOGUE =
ACTIONS_IN_REPLY: [
"I vote for pizza",
"Disregard that, I vote for pizza",
"Another vote for pizza!"
@nemf
nemf / gist:3109649
Created July 14, 2012 06:09
Minimal Kickstart for CentOS 6.3
install
url --url http://ftp.iij.ad.jp/pub/linux/centos/6.3/os/x86_64/
# if you use proxy
# url --url http://ftp.iij.ad.jp/pub/linux/centos/6.3/os/x86_64/ --proxy http://proxy-ip:8080/
lang en_US.UTF-8
keyboard us
network --bootproto=dhcp
rootpw password
firewall --disabled
authconfig --enableshadow --passalgo=sha512
anonymous
anonymous / mysql wrapper class
Created July 19, 2012 02:24
MySql Connection pool & Auto reconnection
/*
use ver 2
provide:
connection pool
auto reconnect
Usage:
MySql = require 'lib/mysql' This one
mysql = new MySql(Config)
@thomasbhatia
thomasbhatia / qos-opendpi.sh
Created July 22, 2012 20:45 — forked from nacx/qos-opendpi.sh
Basic QoS with iproute2 and OpenDPI Netfilter wrapper
#!/bin/bash
# Basic QoS script that uses OpenDPI (http://www.opendpi.org/)
# Netfilter wrapper to identify packets by the protocol.
#
# This script enqueues packets in three queues, each one
# with a different priority:
#
# The first queue has the higher priority and gets the TCP SYN
# packets, ACKs, ICMPs and packets with Minimize-Delay TOS.
@yorkxin
yorkxin / KeyBindings.json
Last active November 29, 2018 20:40
My Sublime Text 2 Config
/* Default (OS X).sublime-keymap */
/* Key Bindings - User */
[
{ "keys": ["ctrl+shift+."], "command": "erb", "context":
[
{
"key": "selector",
"operator": "equal",
"operand": "text.html.ruby, text.haml, source.yaml, source.css, source.scss, source.js, source.coffee"
}
@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007