Skip to content

Instantly share code, notes, and snippets.

extern mod extra;
use extra::arc::Arc;
fn main() {
let x = ~5;
let y = Arc::new(x); // x is no longer pointer to ~5, and y points to the pointer x was that is not to the value but the
// but the pointer x held.
let z = y.clone(); // same semantics, the clone produces a pointer to the pointer x was.
println!("{}", **(y.get())); // see we have that double reference we have to deref twice.
@matthewphilyaw
matthewphilyaw / user.json
Created February 25, 2014 04:47
api-handlers builder
{
"filterBy": [
{ "property": "id", "type": "num" },
{ "property": "name", "type": "string"}
],
"data": [
{
"id": 1,
"name": "tphilyaw",
"firstName": "tommy",
@matthewphilyaw
matthewphilyaw / reverseProxy.js
Created January 12, 2014 16:55
Simple reverse proxy. forwards /api to a different server. Keeps path after api/ in that if you have api/somecall?test=blah it will forward has /somecall?test=blah.
var express = require('express'),
request = require('request'),
url = require('url');
var port = 8080;
var app = express();
app.use(function(req, res, next) {
var proxyUrl = req.path.match(/^\/api(.*)$/);
if (proxyUrl) {