Skip to content

Instantly share code, notes, and snippets.

@jeffwhelpley
jeffwhelpley / gist:5417758
Last active July 21, 2022 12:07
Getting node.js http-proxy to play nice with restify. This will also work for http-proxy with express or another node.js server. Note that I took various snippets of my code for this gist in order to try and convey the general idea. It won't work to just run this file.
/*
I have an existing node.js API server that runs on top of restify. I wanted to add http-proxy to forward
some calls to another API server. From the http-proxy examples out there, it seemed simply enough:
*/
var httpProxy = require('http-proxy');
var proxy = new httpProxy.RoutingProxy();
var restify = require('restify');
var server = restify.createServer();
@adamgit
adamgit / .gitignore
Last active November 11, 2024 06:14
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
var request = require('request')
request.get('http://api.twitter.com/1/users/show.json?screen_name=mikeal', {json:true}, function (e, r, doc) {
console.log(doc)
})
request.get('https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=mikeal', {json:true}, function (e, r, doc) {
console.log(doc)
})
######## WATCHER SCRIPT. Runs very .5 seconds, checks for changes in the source 'html5' dir.
#!/bin/sh
MD5=`cat /tmp/watcher.md5 | awk '{print $4}'`;
X=0;
while [ $X -eq 0 ]; do
newMD5=`ls -altR html5/ | grep -v app.json > /tmp/watcher.md5 && md5 /tmp/watcher.md5 | awk '{print $4}'`;
if [[ "$MD5" != "$newMD5" ]]; then