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
public class Main { | |
public static void main(String[] args) { | |
String inputString = "test input string for first non repeating char z"; | |
String uniqueCharInInputStringString; | |
int len = inputString.length(); | |
char testChar; | |
boolean foundDuplicate; |
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 */ |
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); |
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 |
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; |
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 |
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); |
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(); |
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) { |