Skip to content

Instantly share code, notes, and snippets.

View sintaxi's full-sized avatar
🔥
GSD

Brock Whitten sintaxi

🔥
GSD
View GitHub Profile
@gavinheavyside
gavinheavyside / trivial_file_upload_service.rb
Created November 3, 2009 20:09
Trivial file upload service using Sinatra
require 'rubygems'
require 'sinatra'
require 'fileutils'
# upload with:
# curl -v -F "data=@/path/to/filename" http://localhost:4567/user/filename
post '/:name/:filename' do
userdir = File.join("files", params[:name])
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Cross-browser kerning-pairs & ligatures</title>
<style>
body { font-family: sans-serif; background: #f4f3f3; color: rgba(40, 30, 0, 1); width: 500px; margin: 80px auto; padding: 0px; }
a { color: rgba(15, 10, 0, 0.8); text-decoration: none; border-bottom: 1px solid; padding: 1px 1px 0px; -webkit-transition: background 1s ease; }
a:hover { background: rgba(0, 220, 220, 0.2); }
p, li { line-height: 1.5; padding: 0em 1em 0em 0em; margin: 0em 0em 0.5em; }

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

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'});

(a gist based on the old toolmantim article on setting up remote repos)

To collaborate in a distributed development process you’ll need to push code to remotely accessible repositories.

This is somewhat of a follow-up to the previous article setting up a new rails app with git.

For the impatient

Set up the new bare repo on the server:

#!/bin/bash
SERVER=https://api.no.de
SCRIPT="$0"
if [ ${SCRIPT:0:1} == "/" ]; then
SCRIPT="$(basename -- "$SCRIPT")"
fi
main () {
cmd=${1-help}
@isaacs
isaacs / http-example-client.js
Created December 1, 2010 08:35
a simple example of a nodejs http client making a POST request
var http = require("http")
, util = require("sys") // 0.3.x: require("util")
, fs = require("fs")
, client = http.createClient(80, "example.com")
, request = client.request("POST", "/", {"host":"example.com"})
// send body chunks
request.write("hello, world")
// pump a file through
@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,