Skip to content

Instantly share code, notes, and snippets.

View christianberg's full-sized avatar

Christian Berg christianberg

View GitHub Profile
@christianberg
christianberg / Dockerfile
Last active December 20, 2015 04:29
PostgreSQL Dockerfile
FROM ubuntu:12.04
@christianberg
christianberg / Dockerfile
Last active December 20, 2015 03:49
Example Dockerfile
FROM ubuntu:precise
MAINTAINER Christian Berg <berg.christian@gmail.com>
RUN echo "deb http://archive.ubuntu.com/ubuntu precise-security main" > /etc/apt/sources.list.d/security.list
RUN apt-get update
RUN apt-get upgrade -y && apt-get clean
RUN apt-get install -y openjdk-6-jre && apt-get clean
@christianberg
christianberg / .tmux.conf
Created January 25, 2013 14:23
tmux config
set -g bell-action any
set -g default-terminal xterm
set -g display-panes-colour red
set -g message-bg cyan
set -g message-fg white
set -g mouse-select-pane on
set -g pane-border-bg default
set -g pane-border-fg cyan
set -g pane-active-border-bg default
set -g pane-active-border-fg white
@christianberg
christianberg / magit-commit-babysitter-advice.el
Created December 11, 2012 09:14
Nice commit message enforcement for magit.
(defadvice magit-log-edit-commit (around magit-commit-babysitter)
"Make sure we have a nice commit message."
(let ((bad-commit-message nil)
(case-fold-search nil))
(save-excursion
(beginning-of-buffer)
(unless (string-match "[A-Z]" (string (char-after (point-min))))
(setq bad-commit-message "Commit message should begin with a capital letter."))
(end-of-line)
(if (> (current-column) 50)
@christianberg
christianberg / .screenrc
Created December 15, 2010 13:37
My screen config
escape ``
vbell off
startup_message off
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "
(defn start-server [app]
"Initializes the App Engine services and (re-)starts a Jetty server
running the supplied ring app, wrapping it to enable App Engine API use
and serving of static files."
(set-app-engine-delegate "/tmp")
(swap! *server* (fn [instance]
(when instance
(.stop instance))
(let [app (-> (routes login-routes app)
(wrap-local-app-engine)
(defroutes login-routes
(GET "/_ah/login" [continue] (login-form continue))
(POST "/_ah/login" [action email isAdmin continue] (do (if (= action "Log In")
(login email (boolean isAdmin))
(logout))
(redirect continue)))
(GET "/_ah/logout" [continue] (do (logout)
(redirect continue))))
(defn login
([email] (login email false))
([email admin?] (swap! login-info merge {:email email
:logged-in? true
:admin? admin?})))
(defn logout []
(swap! login-info merge {:email ""
:logged-in? false
:admin? false}))
(defn- set-app-engine-environment []
"Sets up the App Engine environment for the current thread."
(let [att (HashMap. {"com.google.appengine.server_url_key"
(str "http://localhost:" *port*)})
env-proxy (proxy [ApiProxy$Environment] []
(isLoggedIn [] (:logged-in? @login-info))
(getEmail [] (:email @login-info))
(getAuthDomain [] (:auth-domain @login-info))
(isAdmin [] (:admin? @login-info))
(getRequestNamespace [] "")
(def login-info (atom {:logged-in? false
:admin? false
:email ""
:auth-domain ""}))