Skip to content

Instantly share code, notes, and snippets.

View boutros's full-sized avatar

Petter Goksøyr Åsen boutros

  • Oslo Public Library
  • Oslo
View GitHub Profile
@boutros
boutros / gist:3903807
Created October 17, 2012 05:12 — forked from djKianoosh/gist:2648751
Some Clojure functions to help read custom access log files into maps
(defn comment? [s]
(.startsWith s "#"))
(defn not-comment? [s]
(not (comment? s)))
(defn remove-comments [line]
(filter not-comment? line))
(defn nil-if-hyphen [s]
AA = Rickard Stark (M) AB = Eddard Stark (M) AC = Catelyn Tully (F)
AD = Brandon Stark (M) AE = Benjen Stark (M) AF = Jon Snow (M)
AG = Robb Stark (M) AH = Sansa Stark (F) AI = Arya Stark (F)
AJ = Bran Stark (M) AK = Rickon Stark (M) AL = Hoster Tully (M)
AM = Minisa Whent (F) AN = Edmure Tully (M) AO = Lysa Tully (F)
AP = Jon Arryn (M) AQ = Robert Arryn (M) AR = Tytos Lannister (M)
AS = Tywin Lannister (M) AT = Joanna Lannister (F) AU = Kevan Lannister (M)
AV = Cersei Lannister (F) AW = Jamie Lannister (M) AX = Tyrion Lannister (M)
AY = Robert Baratheon (M) AZ = Joffrey Baratheon (M) BA = Myrcella Baratheon (F)
BB = Tommen Baratheon (M) BC = Lancel Lannister (M) BD = Steffon Baratheon (M)
# This is just an hint for a simple Redis caching "framework" using Sinatra
# A friend of mine asked for something like that, after checking the first two gems realized there was
# a lot of useless complexity (IMHO). That's the result.
#
# The use_cache parameter is useful if you want to cache only if the user is authenticated or
# something like that, so you can do cache_url(ttl,User.logged_in?, ...)
require 'rubygems'
require 'sinatra'
require 'redis'
func worker(die chan bool) {
for {
select {
// ... do stuff cases
case <- die:
return
}
}
}
@boutros
boutros / gist:5424817
Created April 20, 2013 04:58
Torquebox + Immutant
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /opt/torquebox/current/jboss
JAVA: java
JAVA_OPTS: -server -XX:+UseCompressedOops -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml -Xss2048k -Djruby.compile.invokedynamic=false -Dorg.quartz.scheduler.skipUpdateCheck=true
@boutros
boutros / db.go
Created May 1, 2013 16:15 — forked from anonymous/db.go
package dropbox
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strconv"

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

@boutros
boutros / cms.conf
Created August 18, 2013 16:55 — forked from ray1729/cms.conf
# cms - simple CMS
#
# The simple-cms server is a Compojure application serving content for cms.1729.org.uk
description "CMS server"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
respawn
package main
import (
"net"
"log"
"time"
)
func Ping(proto, addr string, out chan<- string) {
c, err := net.Dial(proto, addr)

CasperJS Google Suggest

The script:

/*global casper:true*/
var casper = require('casper').create();
var suggestions = [];
var word = casper.cli.get(0);