View nginx + node setup.md

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.

3) nginx listens on port 80.

View web-servers.md

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
View nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
View gist:10198753
/*
* parse_link_header()
*
* Parse the Github Link HTTP header used for pageination
* http://developer.github.com/v3/#pagination
*/
function parse_link_header(header) {
if (header.length == 0) {
throw new Error("input must not be of zero length");
}
View cors-nginx.conf
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
View embed.css
.gist {
color: #000;
}
.gist div {
padding: 0;
margin: 0;
}
.gist .gist-file {
View Evolution of a Python programmer.py
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
View Hash.from_xml
# USAGE: Hash.from_xml(YOUR_XML_STRING)require 'rubygems'
require 'nokogiri'
# modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#123129
7
class Hash
class << self
def from_xml(xml_io)
begin
result = Nokogiri::XML(xml_io)
View go_live.html.erb
<!-- go_live.html.erb -->
<html>
<head>
<title>Go Live!</title>
<meta name="author" content="Luid M Ruiz">
<!--
http://codepen.io/luismruiz
http://codepen.io/luismruiz/pen/hvgey
http://cdpn.io/hvgey
ported to ERB by @SoAwesomeMan
View ox_parsing.rb
require "awesome_print"
module XmlParsing
require "ox"
class Reader < ::Ox::Sax
def initialize file_path, target, target_handler
@target_handler = target_handler
@target = target
@file_path = file_path