Skip to content

Instantly share code, notes, and snippets.

View lpinca's full-sized avatar

Luigi Pinca lpinca

  • Foligno (PG), Italy
View GitHub Profile
@lpinca
lpinca / client.js
Created September 22, 2014 14:22
Engine.IO data loss (҂⌣̀_⌣́)
var eio = require('engine.io-client');
var socket = new eio('http://localhost:3000/');
socket.on('open', function () {
setTimeout(function () {
socket.send('0');
}, 0);
});
socket.on('message', function (message) {
@lpinca
lpinca / client.js
Last active August 29, 2015 14:04
`primus-rooms` GH-44
var primus = new Primus({ strategy: false });
@lpinca
lpinca / client.js
Created July 24, 2014 16:52
GH-268
var primus = new Primus({ strategy: false });
@lpinca
lpinca / README.md
Last active January 20, 2017 00:43
Primus `express-session` example

Upgrade requests should not save the session. If the session is saved when the WebSocket is closed, all the changes made by normal requests in the time span that goes from the opening of the WebSocket to the close of the same WebSocket are lost.

This is evident when this example page is refreshed in Chrome. For some odd reason the WebSocket request is closed after that the new request has been answered and the session is overriden by the old session that is retained in the old upgrade request.

@lpinca
lpinca / Procfile
Created April 13, 2014 10:49
Heroku Primus wss test
web: node server.js
@lpinca
lpinca / client.js
Last active January 16, 2016 21:36
Engine.IO client `xhr.status = 0` issue
(function () {
var socket = new eio.Socket({
rememberUpgrade: false,
transports: ['polling']
});
socket.on('open', function () {
console.log('open');
socket.on('message', function (data) {
console.log(data);
@lpinca
lpinca / time.diff
Created March 26, 2014 08:57
Required time for a connection to be established (IE8 + SockJS + jsonp-polling)
--- sockjs-0.3.4.js 2014-03-26 09:49:46.000000000 +0100
+++ sockjs-0.3.4-m.js 2014-03-26 09:55:07.000000000 +0100
@@ -933,6 +933,8 @@
* ***** END LICENSE BLOCK *****
*/
+var timestamp;
+
var SockJS = function(url, dep_protocols_whitelist, options) {
if (this === _window) {
@lpinca
lpinca / client.js
Created March 25, 2014 11:47
Test case for SockJS retransmission timeout issue
var sock = new SockJS('/test', null, {
protocols_whitelist: ['jsonp-polling']
});
sock.onopen = function () {
console.log('open');
};
sock.onerror = function (err) {
console.log(err);
};
sock.onmessage = function (e) {
@lpinca
lpinca / cert.pem
Last active August 29, 2015 13:56
Primus secure WebSocket
-----BEGIN CERTIFICATE-----
MIICATCCAWoCCQDuPBBeAphl0zANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
cyBQdHkgTHRkMB4XDTE0MDIyNjE5MTg0OVoXDTE0MDMyODE5MTg0OVowRTELMAkG
A1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0
IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA68hH
8JNVn7mGxtSRl+GI+jw12t5kX7+ML42pHteynBki1FmNnYAgUekQ8EnGCwXyUOaD
YxglhAv6Yu0tggE1hcJNbDh4a6N2B02fUcIwEHPGWJNVEB8L92mfDc0tS00a5Drp
yv3T965R0HF7GNlF1MU3Y3V6rk0WNWv1sECVCQkCAwEAATANBgkqhkiG9w0BAQUF
AAOBgQDOUWndwR84vPQKgyYEjK/wspVQ7Rp7qV6VYezTLGJJYhdOgH6xqoGzcj/5
@lpinca
lpinca / destruction.js
Last active August 29, 2015 13:56
Chaos and destruction
var chars = '̴̴̛̮̫̞͚͉̮̙͕̳̲͉̤̗̹̮̦̪̖̱͍͙̖̟͕̹͕̙̦̣̲̠̪̯̳͖̝̩̝̦͇̥̠̟͚̳̤̹̗̻̭͍͖͕͓̻̥̹̮̙͔̗͍͚͓̗̦̹͈͙͕̘̮͖̝̗̲̤̗̮͈̙͈̹̼̣̹̖̱̤̼̺̤̻͙̗̥̠̱͇̱̝̟̺͍̺̼̜̖͈͇͎͙̲̙̗͇̫̘̖̹͖͓͔̺̱̹͓̮͇̯̜̤̗͍̯̰̫̫̖̰͚̪͚̭͚̥̰̤̟͎̝̲̯̭̹̭̙̼̤͖̞̙̹͈͚̥̦͚͉͖̼̬͓͚̳͉͙͎͚̱̮̗͍̩̻̰̣̫͉͈̞̲͉̫̞͔͆̅̓̓̇ͬ͌ͬͫͩͦ̃͌̿̐ͪͩ̌̇͂̆̑͐ͣ҉̶̲͉͔͎̤̼̘͇̮̥̻̜̹̥͚̲̻̖̗̻̫̼̠̳̗̺̤̗̳͈̪̮̗̝͇͈̙͇͕̺̱̼̤̗̰̬̣͌ͬͧ͊́ͧͩ͌͌̐̓̃ͥ̄ͤ͑̈ͬ͆ͬ͂̇̿̅҉̨̙̼̳̭̙͍̻̱̠͈̮̺̣̝̱̙̺͉̳͎̻͔̯̪̝͕͚̣̜̼̞͇̠̘̠̪̫͙͙̬̰̰̫͚̗͕̝̤̗͕̲̮̝̼̺͙͚̟͓̣̥͍͙̘̩̖͇͎̬̠̝͈̺̙̮̬̗̪̤͕͇͕̰̮͖͉̬̙̪̤̝̹͖͖̻̬̹͙̞̗͓̞̭̜̠̟̐͋͊͑̌̾̉͆̆̍̿̾ͤ̔̉̈̂̾̈ͭ'
, len = chars.length
, str = 'foo and bar'
, result = '';
str.split('').forEach(function char(chr) {
for (var i = 0; i < 20; i++) {
var r = Math.floor(Math.random() * len);
chr += chars.charAt(r);
}