Skip to content

Instantly share code, notes, and snippets.

@joemccann
joemccann / nginx + node setup.md
Created October 25, 2010 02:06
Set up nginx as a reverse proxy to node.js.

The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).

In a nutshell,

  1. nginx is used to serve static files (css, js, images, etc.)
  2. node serves all the "dynamic" stuff.

So for example, www.foo.com request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.

  1. nginx listens on port 80.
@mumoshu
mumoshu / Unity+WebSocket.cs
Created August 31, 2011 16:13
Unity+WebSocket.cs
using UnityEngine;
using System.Collections;
using SuperWebSocket.Client;
using System;
public class Net : MonoBehaviour {
private string lastMessage = string.Empty;
public static string serverURI = "ws://192.168.100.196:12345/channels/0?userId=1";
public static WebSocket webSocket = new WebSocket(serverURI, "basic");
@christopherdebeer
christopherdebeer / snippet.js
Created September 7, 2011 09:22
Node.js Express - Mobile detection
app.get('/', function(req, res){
var ua = req.header('user-agent');
if(/mobile/i.test(ua)) {
res.render('mobile.html');
} else {
res.render('desktop.html');
}
});
@bergie
bergie / .gitignore
Created September 19, 2011 15:50
Node.js email handling examples
config.json
reading-image.png
@spicycode
spicycode / tmux.conf
Created September 20, 2011 16:43
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@azeitler
azeitler / CodeUtil.Unity.cs
Created November 13, 2011 02:14
C# Method Generation for Deep-Copy of any Class
using UnityEngine;
using UnityEditor;
public static class CodeUtilUnity {
[MenuItem("Tools/Test: CreateCopyMethod (Transform)")]
public static void TestCreateCopyMethod () {
Debug.Log (CreateCopyMethod (typeof(Transform), true));
}
}
@saetia
saetia / gist:1623487
Last active April 20, 2025 23:05
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@hzlzh
hzlzh / GitHub-Shop-Group-Purchase.md
Created February 22, 2012 06:25
GitHub Shop Group Purchase

#GitHub Shop Group Purchase ###By:@[hzlzh] 活动地址:http://shop.github.com/
V2EX:[http://www.v2ex.com/t/27492][V2EX]

##活动经验提炼:(写给今后可能的,别的组织者)

  • 仅此一次,本人不会再组织GitHub团了,如果只买贴纸可以考虑。因为瓷器和玻璃制品易碎,在快递行业中和iPad属于一个级别的易损坏品。申通和圆通这类的会拒发,而且不能保价。 (来源于SF快递员)
  • 如果有人要买GitHub Shop中的东西,依然建议另寻组团购买,原因如下:
  1. 组团官方使用大箱子发送到中国,这期间会很安全,你想想,会有那个快递员疯了去扔大箱子?(快递的分发是空抛这种扔来扔去的这个是快递行业内部无法避免的),一个小盒子过来中国,八成会碎,先走UPSP然后是国内邮政平邮
  2. 美国->中国 邮费 $20或$30两个档次,差不多¥100多邮费,比有些东西还贵,如果几个朋友一起,何乐而不为?
@fernandoaleman
fernandoaleman / Linux Static IP
Created March 23, 2012 16:20
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@nijikokun
nijikokun / example-user.js
Created May 3, 2012 20:46
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);