Skip to content

Instantly share code, notes, and snippets.

View robertjd's full-sized avatar

robertjd

View GitHub Profile
@robertjd
robertjd / gist:1573310
Created January 7, 2012 00:59
Websocket Handshake without Upgrade header
hybi-07-12, headers: { host: 'example.com',
'sec-websocket-key': 'jjtFcDA0FonXscXj25UuaQ==',
'sec-websocket-origin': 'ws://example.com/socket.io/1/websocket/1105054216814116754',
'sec-websocket-version': '8',
'sec-websocket-protocol': '8',
'cache-control': 'max-stale=0',
connection: 'Keep-Alive',
'x-bluecoat-via': 'DDBD0991AB5F8902' }
@robertjd
robertjd / gist:1573314
Created January 7, 2012 01:00
Websocket Handshake with Upgrade header
hybi-07-12, headers: { host: 'example.com',
connection: 'Upgrade',
upgrade: 'websocket',
'sec-websocket-key': 'FnOFCFGZqujppfHXyivZGA==',
'sec-websocket-origin': 'ws://example.com/socket.io/1/websocket/18363555292121194917',
'sec-websocket-version': '8',
'sec-websocket-protocol': '8' }
@robertjd
robertjd / gist:2974075
Created June 22, 2012 17:23
socket.io service as controller
;
(function(exports, undefined) {
angular.module('module.Socket', [], function($provide) {
$provide.factory('Socket', ['$rootScope', function socketController($rootScope) {
var scope = $rootScope.$new()
scope.socket = io.connect('/')
scope.send = function(message) {
try {
var m = JSON.stringify(message)
@robertjd
robertjd / gist:5105445
Created March 7, 2013 03:45
simple project manager with server
can use jade
can use less / sass
watches jade files one level deep
watches less / sass files one level deep
can start watching new files
@robertjd
robertjd / keen-collector.js
Created April 3, 2013 16:42
Node.JS code for sending events to Keen.IO
/*
--------------------------------------------------------------------------------
Copyright (c) 2013 Colingo, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
@robertjd
robertjd / gist:5465341
Last active December 16, 2015 16:48
visual javascript
@robertjd
robertjd / faq-en.md
Last active December 16, 2015 17:09 — forked from juemura/faq-en.md

General

  • How can I improve my English?

    Sign up at colingo.com and join our daily classes.

  • How do I get started?

    Follow the instructions step-by-step available at http://www.colingo.com/gettingstarted

@robertjd
robertjd / gist:6691388
Created September 24, 2013 21:17
javascript compute months passed
function monthsPassed(fromDate,toDate){
return toDate.getMonth() - fromDate.getMonth() + (12 * ( toDate.getFullYear() - fromDate.getFullYear() ))
}
@robertjd
robertjd / profile.js
Last active August 29, 2015 14:07
Profile route handler for Stormpath
var express = require('express');
var forms = require('forms');
var csurf = require('csurf');
var collectFormErrors = require('express-stormpath/lib/helpers').collectFormErrors;
var stormpath = require('express-stormpath');
var extend = require('xtend');
// Declare the schema of our form:
var profileForm = forms.create({
@robertjd
robertjd / profile.jade
Created October 21, 2014 21:57
profile.jade
html
head
title=title
link(href='//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css', rel='stylesheet')
body
div.container
div.page-header
h1 My Profile