Skip to content

Instantly share code, notes, and snippets.

@cayasso
cayasso / index.html
Created March 12, 2014 16:32
Primus Quick Example
<!Doctype html>
<html>
<head>
<script src="/primus/primus.js"></script>
</head>
<body>
<script>
var primus = new Primus('ws://localhost:5000', { transformer: 'engine.io' });
@cayasso
cayasso / custom-adapter-test.js
Created April 28, 2014 17:46
Custom primus-rooms-adapter
'use strict';
/**
* Module dependencies.
*/
var PilotAdapter('./custom-adapter')
, pilotsAdapter = new PilotsAdapter();
// primus-rooms call the set method
# References:
# http://blog.mixu.net/2011/08/13/nginx-websockets-ssl-and-socket-io-deployment/
# http://blog.exceliance.fr/2012/09/10/how-to-get-ssl-with-haproxy-getting-rid-of-stunnel-stud-nginx-or-pound/
#
global
nbproc 2
maxconn 16384
defaults

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@cayasso
cayasso / index.html
Created August 6, 2014 23:50
Node JS API test
<!DOCTYPE>
<html>
<head>
</head>
<body>
<a id="eushell">EUSHELL</a>
<a id="cayasso">CAYASSO</a>
@cayasso
cayasso / index.html
Created September 4, 2014 03:48
Socket.IO Simple Test
<!doctype>
<html>
<head>
<title>Chat</title>
</head>
<body>
<form id="formDatos">
<input type="text" id="dato" placeholder="Escriba el texto" required>
<input type="submit" value="enviar">
</form>
(function($){
this.itemList = {
options: {
spaceID: null,
spaceType: null,
displayCount: null,
totalItemsCount: null
},
special[ str_hashchange ] = $.extend( special[ str_hashchange ], {
// Called only when the first 'hashchange' event is bound to window.
setup: function() {
// If window.onhashchange is supported natively, there's nothing to do..
if ( supports_onhashchange ) { return false; }
// Otherwise, we need to create our own. And we don't want to call this
// until the user binds to the event, just in case they never do, since it
// will create a polling loop and possibly even a hidden Iframe.
{ "dependencies" : {
"express" : "https://github.com/cayasso/express/tarball/master",
"express-resource" : "~0.2.3",
"jade" : ">= 0.0.1",
"mongoose" : "~2.4.1",
"passport" : "~0.1.3"
},
"engines" : { "node" : ">=0.4.7 <0.7.0" },
"name" : "ObituariosCR",
"version" : "0.0.1"
jbrumle-441b97:obituarioscr jebrumle$ git push heroku master
Counting objects: 646, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (580/580), done.
Writing objects: 100% (646/646), 495.76 KiB, done.
Total 646 (delta 44), reused 0 (delta 0)
-----> Heroku receiving push
-----> Removing .DS_Store files
-----> Fetching custom build pack... done