Skip to content

Instantly share code, notes, and snippets.

@JumpLink
JumpLink / sails-php-client
Created November 6, 2013 18:11
socket-io client in php for sails.js. NOT WORKING!
<?php
require_once('HTTP/Request2.php'); // sudo pear install HTTP_Request2
require( __DIR__ . '/vendor/wisembly/elephant.io/lib/ElephantIO/Client.php');
use ElephantIO\Client as ElephantIOClient; // sudo apt-get install php5-curl
function get_cookie($request) {
$request->setMethod( HTTP_Request2::METHOD_GET);
$request->setCookieJar(true);
try {
$response = $request->send();
@epadillas
epadillas / client.js
Created July 14, 2013 10:26
Send cookies for the socket.io handshake (sails.js)
// Send cookies for the socket.io handshake (sails.js)
// Based on https://gist.github.com/jfromaniello/4087861
// Socket.io open ticket (started by jfromaniello):
// https://github.com/LearnBoost/socket.io-client/pull/512
var io = require('socket.io-client');
var request = require('request');
var xhr = require('socket.io-client/node_modules/xmlhttprequest');
var xhrOriginal = require('xmlhttprequest');
const Application = ((d) => {
const privateVariable = 'Private content'
const __private = {
cache: () => {
this.link = d.querySelector('.link')
},
bind: () => {
this.link.addEventListener('click', this.showContent, false)
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"

These instructions work for the Raspberry Pi running Raspbian (hard float) and create a hardware optimized version of NodeJS for the Raspberry PI, (and include a working install and NPM!!!):

  1. Install Raspbian - http://www.raspberrypi.org/downloads

  2. Install the necessary dependecies:

sudo apt-get install git-core build-essential

(If you just installed git then you need to administer your git identity first, else adding the patches below will fail!!!)

@ahx
ahx / app.js
Created October 23, 2010 20:26
small demo for handlebars.js, jQuery 1.4.3 data events and require.js
/* small demo for handlebars.js, jQuery, require.js */
/*global Handlebars */
var cart = {
products: [
],
total: function() {
var sum = 0;
for(var i in this.products) {
sum += this.products[i].price;