View gist:922fc3dc62405a59d341
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var io = require('socket.io').listen(httpServer); | |
httpServer.listen(8080); | |
io.set('log level', 1); | |
var peerWebRTC = io.of('/peerWebRTC'); | |
var PeerServer = require('peer').PeerServer; | |
var idIncr = 0; | |
var clientpeerIds = []; | |
var clientData = {}; /* by clientpeerIds */ |
View gist:10967360
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var https = require('https') | |
var httpSSLserver = https.createServer() | |
httpSSLserver.listen(443); | |
var http = require('http') | |
var httpServer = http.createServer() | |
var io = require('socket.io').listen(httpServer); | |
httpServer.listen(80); |
View gist:10446070
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if you have button with a click handler, and you remove it from dom, does the handler remain? | |
if you call removeChild on its parent, then the handler is gone. if you instead append it to a document fragment, it will keep it | |
jQuery .revome() kills the handler. jquery "detach" will keep it |
View gist:10367539
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p id="whiteTimeLeft"></p> | |
<button id="start">start</button> | |
<button id="stop">stop</button> | |
var secs = 599; | |
function decrementTimer() { | |
var currentMinutes = "0" + Math.floor(secs / 60); | |
var currentSeconds = Math.floor((secs % 60)); | |
if(currentSeconds <= 9) currentSeconds = "0" + currentSeconds; | |
var timeLeft = currentMinutes + ":" + currentSeconds; |
View gist:10234719
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I copied this example http://chessboardjs.com/examples#5000 which integrates https://github.com/jhlywa/chess.js | |
Then I tweaked this script: <script src="js/chessboard.js"></script> | |
I changed the addEvents function to only register mouse event handler for desktops because when I tested it on old android browsers, touchstart and mousedown events were both firing: | |
if (isTouchDevice() === true) { | |
boardEl.on('touchstart', '.' + CSS.square, touchstartSquare); | |
containerEl.on('touchstart', '.' + CSS.sparePieces + ' .' + CSS.piece, | |
touchstartSparePiece); | |
//$(window).on('touchmove', touchmoveWindow); nad cutout | |
//$(window).on('touchend', touchendWindow); nad cutout | |
} else { // all the same mouse stuff that is in the default setup |
View gist:6530732
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//THIS WORKS FINE | |
var app = require('http').createServer(handler); | |
var io = require('socket.io').listen(app); | |
var static = require('node-static'); | |
// Make all the files in the current directory accessible | |
var fileServer = new static.Server('./public'); | |
app.listen(8000); |
View gist:6465774
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nano = require('nano'); | |
var couchdb = nano('http://127.0.0.1:5984'); | |
var redis = require('redis'); | |
var http = require('http'); | |
var connect = require('connect'); | |
var RedisStore1 = require('connect-redis')(connect); | |
var io = require('socket.io'); | |
var cookie = require('cookie'); | |
var sessionStore = new RedisStore1(); |
View gist:6401423
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SERVER | |
var fs = require('fs'), | |
url = require('url'), | |
http = require('http'), | |
path = require('path'); | |
var PORT = 8000, | |
SAVE_PATH = './receivedCaps'; | |
http.createServer(function(req, res) { |