Skip to content

Instantly share code, notes, and snippets.

View davidpdrsn's full-sized avatar

David Pedersen davidpdrsn

  • Denmark
View GitHub Profile
SELECT u.id, u.slug, pp.points, pp.id AS pp_id
FROM users u
JOIN performance_points pp ON pp.user_id = u.id
JOIN team_memberships tm ON tm.team_id = pp.team_id AND tm.user_id = pp.user_id
WHERE (pp.date > '2015-08-02 13:57:14.042221')
LIMIT 50
def name
"#{firstname} #{lastname}"
end
function! s:path_to_current_file()
return expand("%")
endfunction
function! s:splitv(file_name)
execute "vsplit " . a:file_name
endfunction
function! s:splith(file_name)
execute "split " . a:file_name
testing...
@davidpdrsn
davidpdrsn / pre-push
Created January 27, 2016 10:29
Git pre-push hook that prevents you from pushing commits with "WIP" in the message
#!/bin/sh
# Prevent you from pushing commits that have "WIP" in the message
branch=`git branch 2>/dev/null | grep '^*' | colrm 1 2`
git log $branch ^origin/$branch --pretty="format:%h %s" | grep "WIP"
if [[ $? -eq 0 ]]; then
echo "Found commits with WIP messages"
exit 1
@davidpdrsn
davidpdrsn / EvalStack.hs
Last active December 30, 2015 19:51
Example using Monad Transformer stack handles failure, IO, and state. Useful for evaluating ASTs.
module MoreState where
import Control.Monad.Except
import Control.Monad.State.Class
import Control.Monad.Trans.State hiding (get, put)
import Data.List
import Data.Map (Map)
import qualified Data.Map as M
(load-file "~/.emacs.d/sensible-defaults.el")
(sensible-defaults/use-all-settings)
;;; Load emacs builtin package manager
;;; Load packages both from marmalade and melpa
(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(setq package-enable-at-startup nil)
module StateIOYo where
import Control.Monad.Trans.State
import Control.Concurrent
import Control.Monad.IO.Class
main :: IO ()
main = do
(_, fs) <- runStateT sampleAction []
evalAll putStrLn fs
@davidpdrsn
davidpdrsn / twister.rb
Created November 4, 2015 20:29
For playing when you don't have a spinner board
sides = [
"left",
"right",
]
colors = [
"on red",
"on blue",
"on yellow",
"on green",
module Optional where
data Optional a = Some a
| None
instance Functor Optional where
fmap f (Some x) = Some (f x)
fmap _ None = None
instance Applicative Optional where