Skip to content

Instantly share code, notes, and snippets.

@ericz
ericz / test.js
Created April 4, 2011 17:13
example for socket.io issue `Double connections with blocking `alert` or `prompt` during io.connect()`
var http = require('http'),
io = require('socket.io'),
fs = require('fs'),
server = http.createServer(function(req, res){
// your normal server code
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(fs.readFileSync('test.html'));
});
server.listen(80);
@ericz
ericz / test.html
Created April 4, 2011 17:13
example for socket.io issue `Double connections with blocking `alert` or `prompt` during io.connect()`
<script src="http://localhost/socket.io/socket.io.js"></script>
<script>
var socket = new io.Socket('localhost');
socket.connect();
socket.on('connect', function(){
alert("connected");
})
socket.on('message', function(){ })
@ericz
ericz / test.html
Created May 3, 2011 20:30
Test for read122
<!DOCTYPE html>
<html lang="en">
<head>
<title>nowjs test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="/nowjs/now.js"></script>
<script>
$(function(){
now.receiveMessage = function(name, message){
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect();
socket.on('a', function(){
//alert(1);
});
socket.on('b', function (data) {
<script src="/socket.io/socket.io.js"></script>
<script>
var i = 0;
var socket = io.connect();
socket.on('connect', function(){
setInterval(function(){
@ericz
ericz / index.html
Created July 25, 2011 19:33
jsonp client -> server message issue
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect();
socket.on('connect', function(){
socket.emit('print', 'a');
socket.emit('print', 'b');
});
@ericz
ericz / gist:1571608
Created January 6, 2012 17:39 — forked from lezhangxyz/gist:1571589
client.js
require(['libs/now/0.7.4/now'], function(Now) {
Now.pong = function(){
alert('pong!');
}
Now.ready(function(){
Now.ping();
});
}
@ericz
ericz / gist:5079988
Created March 4, 2013 04:37
Proper for each loops for JS dicts.
// BAD
for (var key in this._workingPeers) {
var peer = this._workingPeers[key];
}
// GOOD
var indices = Object.keys(this._workingPeers);
for (var i = 0; i < indices.length; i++) {
var peer = this._workingPeers[indices[i]];
}
@ericz
ericz / everything but the thumb
Last active January 3, 2016 12:29
Just the thumbs
{#each :card.fields as :card_field}
{#if not(equal(:card_field.type, 'score-system'))}
<derby:view ns="lui" view=cardFields:{{:card_field.type}}:showCard>
{/}
{/}
#
# as
#
# When added as attribute to custom directive, exposes the isolate scope of the directive to parent scope
#
# Attributes:
# as: Name to save isolate scope as on parent scope
##
# Example:
###