Skip to content

Instantly share code, notes, and snippets.

Nadeem nadeemelahi

Block or report user

Report or block nadeemelahi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nadeemelahi
nadeemelahi / gist:922fc3dc62405a59d341
Created May 12, 2014
socket.io peerjs clients list
View gist:922fc3dc62405a59d341
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
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
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
@nadeemelahi
nadeemelahi / gist:10367539
Last active Aug 29, 2015
count down timer
View gist:10367539
<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
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 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
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
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) {
You can’t perform that action at this time.