Some exercises from the Falsy Values workshops.
The good parts:
- HTTP server and client in same script
- Express cookies example
- Express routing example
- Express error handling
- Express middlewares example
- Simple HTTP proxy
# | |
# Get development tools installed | |
# | |
sudo yum install -y git cvs zlib-devel | |
sudo yum groupinstall -y "Development Tools" | |
# | |
# Install RVM | |
# | |
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm) |
#!/usr/bin/env ruby | |
$: << File.dirname(__FILE__)+'/lib' | |
require 'goliath' | |
require 'em-synchrony/em-http' | |
# | |
# Here's an example of how to make an asynchronous request in the middleware, | |
# and only proceed with the response when both the endpoint and our middleware's | |
# responses have completed. |
#!/usr/bin/env ruby | |
# | |
# A quick script to dump an overview of all the open issues in all my github projects | |
# | |
require 'octokit' | |
require 'awesome_print' | |
require 'rainbow' |
Some exercises from the Falsy Values workshops.
The good parts:
/* use like | |
$ javac Go2.java | |
$ java -client Go2 | |
$ java -server Go2 | |
*/ | |
public class Go2 { |
// Copyright 2011 Google Inc. All rights reserved. | |
// Use of this source code is governed by the Apache 2.0 | |
// license that can be found in the LICENSE file. | |
package guestbook | |
import ( | |
"http" | |
"io" | |
"os" |
HTTP/1.1 200 OK | |
Server: Sun-Java-System-Web-Server/7.0 | |
Date: Mon, 07 Dec 2009 07:25:34 GMT | |
P3p: policyref="http://www.sun.com/p3p/Sun_P3P_Policy.xml", CP="CAO DSP COR CUR ADMa DEVa TAIa PSAa PSDa CONi TELi OUR SAMi PUBi IND PHY ONL PUR COM NAV INT DEM CNT STA POL PRE GOV" | |
Cache-control: public | |
Set-cookie: JROUTE=W2VMz2yu926eYGvP; Path=/ | |
X-powered-by: JSP/2.1 | |
Set-cookie: JSESSIONID=80765ae114eab08df95a11208c62; Path=/ | |
Content-type: text/html;charset=UTF-8 | |
Via: 1.1 https-www |
""" A script to attempt the compression of written english | |
to the chinese character set """ | |
import os | |
from collections import OrderedDict | |
from math import log | |
import itertools | |
from collections import Counter | |
# Set cache dir | |
proxy_cache_path /var/cache/nginx levels=1:2 | |
keys_zone=microcache:5m max_size=1000m; | |
# Virtualhost/server configuration | |
server { | |
listen 80; | |
server_name yourhost.domain.com; | |
# Define cached location (may not be whole site) |
require 'jruby' | |
module Serialize | |
def self.serialize(obj) | |
baos = java.io.ByteArrayOutputStream.new | |
oos = java.io.ObjectOutputStream.new(baos) | |
oos.write_object(JRuby.reference(obj)) | |
oos.close | |