Skip to content

Instantly share code, notes, and snippets.

Avatar

Steve Purcell purcell

View GitHub Profile
@purcell
purcell / HereQ.hs
Last active Apr 28, 2019
Quasi-quoter for postgresql-simple
View HereQ.hs
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleContexts #-}
{-# OPTIONS_GHC -fno-warn-missing-fields #-}
-- | Interpolate any type that inhabits both IsString and Semigroup
-- This code is based on the "here" package. It would be nice to strip
-- leading whitespace, as the "neat-interpolation" package does.
-- Additionally, "neat-interpolation" has a simpler interpolation
@purcell
purcell / emacs-osx-srgb.patch
Last active Jun 19, 2018
Make Emacs on OSX treat all RGB colors as being within the sRGB color space
View emacs-osx-srgb.patch
commit 3b63b2c6e9e93adab09eace60750ed981a8e528f
Author: Steve Purcell <steve@sanityinc.com>
Date: Sat Dec 21 11:44:12 2013 +0000
Treat hex colors as sRGB (see http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8402)
diff --git a/src/nsterm.m b/src/nsterm.m
index 733c05a..0c79186 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@purcell
purcell / with-docker-db.sh
Last active Mar 6, 2018
Run a command against a PostgreSQL DB installed and started on demand using Docker
View with-docker-db.sh
#!/bin/bash -e
image=mdillon/postgis:9.6-alpine
container_name=my-app-postgresql
if [ -z "$1" ]; then
echo "Run command with a dockerised PostgreSQL DB.
usage: $(basename "$0") command
@purcell
purcell / .slate
Last active Feb 7, 2018
Slate config
View .slate
# See https://github.com/jigish/slate#readme
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config focusPreferSameApp false
config focusCheckWidthMax 3000
config checkDefaultsOnLoad true
config windowHintsShowIcons true
config windowHintsSpread true
@purcell
purcell / application_helper.rb
Created Sep 9, 2011
Make will_paginate generate HTML that bootstrap.less will render nicely
View application_helper.rb
# Based on https://gist.github.com/1182136
class BootstrapLinkRenderer < ::WillPaginate::ActionView::LinkRenderer
protected
def html_container(html)
tag :div, tag(:ul, html), container_attributes
end
def page_number(page)
tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page)
@purcell
purcell / migrations.sql
Last active Sep 16, 2017
PostgreSQL schema migrations system
View migrations.sql
This code now lives in its own repo at https://github.com/purcell/postgresql-migrations
View Puzzle.hs
module Puzzle where
import Data.List (permutations)
import Control.Monad (guard)
solution = do
[a,b,c,d,e,f] <- permutations "123456"
guard $ multiple 6 [a,b,c,d,e,f]
guard $ multiple 5 [a,b,c,d,e]
guard $ multiple 4 [a,b,c,d]
View Main.hs
module Main where
import Text.Parsec
import Text.Parsec.String
main :: IO ()
main = do
input <- getLine
@purcell
purcell / elpa-compare.el
Created Jun 27, 2012
Compare melpa and marmalade package lists
View elpa-compare.el
(defun elpa/package-names (archive-name)
(let* ((archive-contents (expand-file-name (concat "archives/" archive-name "/archive-contents")
package-user-dir))
(names (mapcar 'car (rest (pb/read-from-file archive-contents)))))
(sort names 'string<)))
(defun list-minus (a b)
(let ((result (copy-seq a)))
(dolist (e b)
(delq e result))
View no-proxy-mode.el
;;; no-proxy-mode.el --- Temporarily disable built-in proxy settings
;; Copyright (C) 2013 by Sachin Patil
;; Author: Sachin Patil <isachin@iitb.ac.in>
;; URL: http://github.com/psachin/proxy-mode
;; Keywords: network, proxy, tool, convenience
;; Version: 0.9
;; This file is NOT a part of GNU Emacs.
You can’t perform that action at this time.