Skip to content

Instantly share code, notes, and snippets.

View sintaxi's full-sized avatar
🔥
GSD

Brock Whitten sintaxi

🔥
GSD
View GitHub Profile
@kristoferjoseph
kristoferjoseph / index.js
Last active August 29, 2015 13:57
Simplest livereload development server I could make
var express = require('express'),
instant = require('instant'),
colors = require('colors'),
app = express();
app.use(instant(__dirname));
app.listen(3000,
console.log('Navigate to ' + 'http://localhost:3000'.green + ' to view your page')
);
@sillygwailo
sillygwailo / Gruntfile.js
Created March 3, 2015 21:14
questions.justagwailo.com Grunt deployment and notification
module.exports = function(grunt) {
grunt.initConfig({
notify: {
surge: {
options: {
title: 'questions.justagwailo.com',
message: 'Deployment complete.',
}
},
},

NodeKO Tips on Joyent

Tip 1) Use process.env.PORT

Listen to process.env.PORT and fallback to port 8001 will make your life easier. By default process.env.PORT is set to port 80.

var http = require('http');

http.createServer(function (req, res) {

res.writeHead(200, {'Content-Type': 'text/plain'});

STEP 1) provision (you may have done this)

curl -k -u username:sekrit https://api.no.de/smartmachines/node -F "coupon=mycouponcode"

curl -k -u username:sekrit https://api.no.de/smartmachines/node/:id

ssh node@MY.IP.ADD.RESS

STEP 2) install/start redis

@alessioalex
alessioalex / app.js
Created March 29, 2011 19:56
From Pedro Teixeira's http://nodetuts.com/tutorials/12-file-uploads-using-nodejs-and-express.html but with connect-form instead of multipart-js
var express = require('express'),
form = require('connect-form'),
fs = require('fs'),
util = require('util');
var app = express.createServer(
form({keepExtensions: true})
);
// switch between development and production like this:
@sintaxi
sintaxi / upload.js
Created March 30, 2011 01:10
Uploads a file with Node.js. Nothing more.
// to test...
// curl -T path/to/file.tar.gz http://localhost:8000
var http = require('http')
var fs = require('fs')
http.createServer(function(req, rsp){
var file = fs.createWriteStream("mynewfile")
@sintaxi
sintaxi / application.js
Created April 8, 2011 04:32
a simple chat system
var q= function(s){ return document.getElementById(s) }
function send(){
var input = q('text');
socket.send(input.value);
input.value = '';
}
var socket = new io.Socket(null, {
port: 8001,
@silentrob
silentrob / stream_mp4
Created April 8, 2011 04:45
Connect Stream mp4 Example
require('connect').createServer(
connect.static(__dirname + '/videos', { maxAge: 0 }),
function(req, res) {
res.setHeader('Content-Type', 'text/html');
res.end('<video width="300px" src="/OLD_BOY.mp4" controls="controls" autoplay="autoplay"></video>');
}
).listen(process.env.PORT || 4000);
@sintaxi
sintaxi / server.js
Created April 20, 2011 18:46
example of how to make calls in parallel
var http = require("http")
// expensive call
// takes 2 sec
function name(cb){
setTimeout(function(){ cb("Brock") }, 2000)
}
// expensive call
// takes 2 sec
@guybrush
guybrush / nodeconf_2011.md
Created May 6, 2011 07:22
a list of slides from nodeconf 2011