Skip to content

Instantly share code, notes, and snippets.

@aviflax
aviflax / using welder.js
Created June 28, 2011 21:15
Usage patterns for Weld
welder(things, 'things.html', 'thing', function(err, html) {
if (err) throw new Error(err);
res.send(html, {'Content-Type': 'text/html'});
});
@aviflax
aviflax / GoalResource.js
Created August 26, 2011 01:41
resource.js for Express
"use strict";
var Resource = require('../lib/resource');
var ResourceError = require('../lib/resourceerror');
var Goal = require('../models/Goal');
var GoalResource = new Resource();
GoalResource.get = function(req, res) {
var self = this;
@aviflax
aviflax / restlet_request_timeout.groovy
Created September 7, 2011 23:13
How to reliably implement a request timeout for Restlet's Client and ClientResource classes
#!/usr/bin/env groovy
@GrabResolver(name="restlet", root="http://maven.restlet.org/")
@Grab(group="org.restlet.jse", module="org.restlet", version="2.0.9")
// request timeouts reliably only with Apache HttpClient
@Grab(group="org.restlet.jse", module="org.restlet.ext.httpclient", version="2.0.9")
import org.restlet.*
import org.restlet.data.*
@aviflax
aviflax / brew install node
Created September 12, 2011 02:47
brew install node not working with osx-gcc-installer
$ brew doctor
Your system is raring to brew.
$ brew install -v node 2>&1 | pbcopy
==> Downloading http://nodejs.org/dist/node-v0.4.11.tar.gz
File already downloaded in /Users/avi/Library/Caches/Homebrew
/usr/bin/tar xf /Users/avi/Library/Caches/Homebrew/node-0.4.11.tar.gz
==> ./configure --prefix=/usr/local/Cellar/node/0.4.11
./configure --prefix=/usr/local/Cellar/node/0.4.11
Checking for program g++ or c++ : /usr/bin/llvm-g++
Checking for program cpp : /usr/bin/cpp
@aviflax
aviflax / curl_request
Created December 4, 2011 23:16
Trying to figure out how to determine http transfer progress accurately in Node,js
curl -i -# -o /dev/null http://localhost:3000/
@aviflax
aviflax / gist:1634459
Created January 18, 2012 17:53
Some convenience methods I’d like to see added to java.util.logging.Logger
public void log(Level level, String message, Throwable throwable, Object... params) {
log(level, MessageFormat.format(message, params), throwable);
}
public void severe(String message, Throwable throwable) {
log(Level.SEVERE, message, throwable);
}
public void severe(String message, Object... params) {
log(Level.SEVERE, message, params);
@aviflax
aviflax / gist:3147740
Created July 19, 2012 23:55
Compile your CoffeeScript along with your Clojure
;;; Compile your CoffeeScript along with your Clojure
;; NOTE: For Clojure projects using Leiningen 1.7.x.
;; Instructions for Leiningen 2.0.x coming soon.
;; Step 1: add [robert/hooke "1.1.2"] to the :dev-dependencies option of your defproject call
;; Step 2: add the following code to the bottom of your project.clj:
(require ['robert.hooke :as 'hooke]
@aviflax
aviflax / gist:3428919
Created August 22, 2012 20:10
Problem upgrading Node
Running 10.8.0 and latest brew.
$ brew upgrade -v node 2>&1 | pbcopy
==> Upgrading node
==> Downloading http://nodejs.org/dist/v0.8.7/node-v0.8.7.tar.gz
Already downloaded: /Library/Caches/Homebrew/node-0.8.7.tar.gz
/usr/bin/tar xf /Library/Caches/Homebrew/node-0.8.7.tar.gz
==> ./configure --prefix=/usr/local/Cellar/node/0.8.7 --without-npm
./configure --prefix=/usr/local/Cellar/node/0.8.7 --without-npm
@aviflax
aviflax / link_header.py
Created December 5, 2012 18:09 — forked from mnot/link_header.py
link_header.py: HTTP Link header parsing
@aviflax
aviflax / List all Tabs in Front Window.scpt
Last active January 4, 2016 18:44
Applescript to List all Tabs in Front Safari Window
tell application "Safari"
set docText to ""
set tabcount to number of tabs in front window
repeat with y from 1 to tabcount
set tabName to name of tab y of front window
set tabURL to URL of tab y of front window
set tabText to tabName & linefeed & tabURL
set docText to docText & tabText & linefeed & linefeed as string
end repeat