Oct 16 2010
- 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments
In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].
HTMLTextAreaElement.prototype.getCaretPosition = function () { //return the caret position of the textarea | |
return this.selectionStart; | |
}; | |
HTMLTextAreaElement.prototype.setCaretPosition = function (position) { //change the caret position of the textarea | |
this.selectionStart = position; | |
this.selectionEnd = position; | |
this.focus(); | |
}; | |
HTMLTextAreaElement.prototype.hasSelection = function () { //if the textarea has selection then return true | |
if (this.selectionStart == this.selectionEnd) { |
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://npmjs.org/install.sh | sh |
#define HTTP_STATUS_100 "100 Continue" | |
#define HTTP_STATUS_101 "101 Switching Protocols" | |
#define HTTP_STATUS_102 "102 Processing" | |
#define HTTP_STATUS_200 "200 OK" | |
#define HTTP_STATUS_201 "201 Created" | |
#define HTTP_STATUS_202 "202 Accepted" | |
#define HTTP_STATUS_203 "203 Non-Authoritative Information" | |
#define HTTP_STATUS_204 "204 No Content" | |
#define HTTP_STATUS_205 "205 Reset Content" | |
#define HTTP_STATUS_206 "206 Partial Content" |
angular.module("app").directive("onRepeatFinish", ["$timeout", function($timeout){ | |
return { | |
restrict: "A", | |
link: function($scope, $element, $attrs) { | |
if ($scope.$last) { | |
$timeout(function(){ | |
if (angular.isFunction($scope[$attrs["onRepeatFinish"]])) | |
$scope[$attrs["onRepeatFinish"]]() | |
}); | |
} |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
var pubListener = 'tcp://127.0.0.1:5555'; | |
var subListener = 'tcp://127.0.0.1:5556'; | |
var hwm = 1000; | |
var verbose = 0; | |
// The xsub listener is where pubs connect to | |
var subSock = zmq.socket('xsub'); | |
subSock.identity = 'subscriber' + process.pid; | |
subSock.bindSync(subListener); |
var Hapi = require('hapi'); | |
var stream = require('stream'); | |
// Create a server | |
var server = Hapi.createServer('localhost', 8000); | |
// Add a route | |
server.route({ | |
method: 'GET', | |
path: '/hello', |
var zmq = require('zmq') | |
, xpub // xpub to redistribute messages over known port | |
, xsub; // xsub to recieve incomming messaes | |
var xpub_url = 'tcp://0.0.0.0:9999' | |
var xsub_url = 'tcp://0.0.0.0:9998'; | |
var noop = function(){"use strict";} | |
xpub = zmq.socket( "xpub" ); | |
xsub = zmq.socket( "xsub" ); |