Skip to content

Instantly share code, notes, and snippets.

@willrstern
willrstern / node-ubuntu-upstart-service.md
Last active August 17, 2023 10:15
Run Node.js App as Ubuntu Upstart Service

###The Issue With Forever Forever is great for running node services, with a minor setback: the word "forever" doesn't apply to system reboots.

###The solution, run node apps as a system service logged in as root

vim /etc/init/node-app.conf

Contents for node-app.conf

@rcy
rcy / using settings in meteor
Created March 20, 2014 20:27
simple example of using settings in meteor
settings.json:
```
{"foo": 99}
```
app.js
```
if (Meteor.isServer)
console.log(Meteor.settings.foo);
```
@digilord
digilord / formGetter.coffee
Last active August 29, 2015 13:57
Simple form getter.
_data = {}
_inputElements = ['input', 'select', 'textarea']
# Find this templates 'form'
form = template.find('form');
for type in _inputElements
# Get all the fields as an array of jQuery objects
elements = $(form).find(type)
for element in elements
console.log element
if element.type == 'checkbox'
#!/bin/bash
sudo apt-get install build-essential -y
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update -y
sudo apt-get install nodejs -y
sudo apt-get install mongodb -y
sudo apt-get install git -y
sudo apt-get install nginx -y
sudo apt-get install htop -y
Meteor.startup () ->
# Countries collection initialization.
countries_csv = Assets.getText('country.csv')
csv = Meteor.require('csv')
countries_count = Countries.find().count()
if countries_count is 0
Future = Npm.require('fibers/future')
future = new Future()
csv()
.from.string(countries_csv, {comment: '#'})
@davemo
davemo / api.proxy.server.js
Created November 6, 2012 21:56
A simple express.js server with a proxy that intercepts all requests with /api/ and proxies them to localhost:3000
var express = require('express'),
httpProxy = require('http-proxy'),
app = express();
var proxy = new httpProxy.RoutingProxy();
function apiProxy(host, port) {
return function(req, res, next) {
if(req.url.match(new RegExp('^\/api\/'))) {
proxy.proxyRequest(req, res, {host: host, port: port});
@mattsahr
mattsahr / native.scroll.html
Created November 17, 2011 02:47
IOS Webkit - native internal scroll - a fix for the document page-top-bounce
<!DOCTYPE html>
<html>
<!-- NOTES
Demo - uses IOS native scroll available in IOS5, but sidestep the document-bounce behavior. Tested on iPad 1, using IOS 5.1.
This approach uses a set of 3 nested divs.
OuterDiv -- fixed height, width, overflow-scrolling: touch;
MiddleDiv -- fixed height width, overflow-scrolling: touch; fits inside OuterDiv
InnerDiv -- fixed height width, bigger than MiddleDiv, so it kicks in the overflow behavior