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:2983222
Created June 24, 2012 13:22 — forked from weavejester/gist:1001206
Clojure on Heroku
~/$ lein new ring-on-heroku
Created new project in: /home/jim/Development/ring-on-heroku
~/$ cd ring-on-heroku
~/ring-on-heroku$ echo 'web: lein run -m ring-on-heroku.core' > Procfile
~/ring-on-heroku$ cat > src/ring_on_heroku/core.clj
(ns ring-on-heroku.core
(:use ring.util.response
ring.adapter.jetty))
(defn app [req]
# Here's the example from rpsec-given
#
# Initially, I thought I'd like the Given/When/Then
# replacement for RSPec's cruddy "it", but I don't
# I find this test very hard to follow, as there are
# several statements that create state via variables
# in a subtle and unclear way. Further, we have some
# strange indirection with the "stack_with(initial_contents)".
# It seems like we're adding a lot of complexity just to save
# a simple variable assignment.
@boutros
boutros / Gemfile
Created July 7, 2012 18:29 — forked from ecuageo/Gemfile
goliath demo
source 'http://rubygems.org'
gem 'goliath', :git => 'https://github.com/postrank-labs/goliath.git'
gem 'yajl-ruby'
gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git', :require => 'eventmachine'
gem 'em-http-request', :git => 'https://github.com/igrigorik/em-http-request.git'
gem "em-synchrony", :git => 'https://github.com/igrigorik/em-synchrony.git'
@boutros
boutros / api.rb
Created July 9, 2012 15:43 — forked from lucatironi/api.rb
Snippets for an API with grape
# Server App
# This file must be in lib/myapp/api.rb
module MyApp
module Entities
class Products < Grape::Entity
expose :id, :code, :name, :short_description
expose :description, :unless => { :collection => true }
expose (:category) { |model, options| model.category.name }
expose (:brand) { |model, options| model.brand.name }
end
@boutros
boutros / gist:3755497
Created September 20, 2012 12:01 — forked from gorsuch/gist:1418850
clojure uuid
(defn uuid [] (str (java.util.UUID/randomUUID)))
@boutros
boutros / callbacksarehard.js
Created September 24, 2012 09:49 — forked from isaacs/callbacksarehard.js
let's go shopping!
// before
mainWindow.menu("File", function(err, file) {
if(err) throw err;
file.openMenu(function(err, menu) {
if(err) throw err;
menu.item("Open", function(err, item) {
if(err) throw err;
item.click(function(err) {
if(err) throw err;
mainWindow.getChild(type('Window'), function(err, dialog) {
@boutros
boutros / addendum.markdown
Created October 1, 2012 15:40 — forked from geemus/addendum.markdown
API - Assumptions Probably Incorrect
@boutros
boutros / cl-graph.clj
Created October 11, 2012 18:21 — forked from martintrojer/cl-graph.clj
core.logic graph blog
(ns cl-graph
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
;; Directed Acyclic Graphs
(defrel edge a b)
;; a
;; |
@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)