Skip to content

Instantly share code, notes, and snippets.

View philandstuff's full-sized avatar

Philip Potter philandstuff

View GitHub Profile
@philandstuff
philandstuff / russ-garrett.org
Created March 7, 2014 15:53
russ garrett talking about postgres

russ garrett on postgres

  • I like it as a default database when I don’t know what database I want to use

schemas

  • I like schemas and I hate schemaless databases
  • it’s useful to be able to enforce your schema before the data gets written to disk
    • rather than in your ORM!
    • CHECK constraints: ensure balance >= 0

schema changes often aren’t great

  • this is why people don’t like schemas
@philandstuff
philandstuff / scale-summit.org
Last active August 29, 2015 13:57
scale-summit 2014

Scale Summit 2014

Intro, MBS

ideas for sessions

  • bootstrapping environments (without object stores)
  • service discovery
  • removing spofs
public class User {
public enum Gender { MALE, FEMALE };
public static class Name {
private String _first, _last;
public String getFirst() { return _first; }
public String getLast() { return _last; }
public void setFirst(String s) { _first = s; }
class Need
extend ActiveModel::Naming
attr_reader :id
attr_accessor :role, :goal, :benefit
def initialize(id, exists=false)
need = need_api_client.need(id)
if exists
assign_protected_attributes(need)
{-# LANGUAGE ExistentialQuantification #-}
import Data.Foldable
import Data.Set (Set)
import qualified Data.Set as Set
import Prelude hiding (mapM_)
data FizzBuzzTag = Fizz | Buzz deriving (Eq, Ord, Show)
type FizzBuzz = Set FizzBuzzTag
module FizzBuzz where
import Data.Maybe
data FizzBuzz = Fizz | Buzz deriving Show
whenDivisible :: Integral a => a -> b -> a -> Maybe b
whenDivisible d x n = if n `rem` d == 0 then Just x else Nothing
fizzbuzz :: (Show a, Integral a) => a -> String
fizzbuzz n = if null tags then show n else concatMap show tags
module FizzBuzz where
import Data.Foldable (fold)
whenDivisible :: Integral a => a -> b -> a -> Maybe b
whenDivisible d x n = if n `rem` d == 0 then Just x else Nothing
fizzbuzz :: (Show a, Integral a) => a -> String
fizzbuzz n = maybe (show n) id tagStr
where tagStr = fold [fizz n, buzz n]
fizz = whenDivisible 3 "Fizz"
@philandstuff
philandstuff / README.org
Last active August 29, 2015 14:20
spike

datomic-spike

A spike into using datomic to model data registers.

Usage

You need Datomic. If you agree to the Datomic Free License you can install it using homebrew: brew install datomic.

analysis

2015-05-19T14:12:14.514559+00:00 app[web.1]: [error] c.j.b.ConnectionHandle - Database access problem. Killing off this connection and all remaining connections in the connection pool. SQL State = 57P01
2015-05-19T14:12:14.762639+00:00 app[web.1]: [error] application -
2015-05-19T14:12:14.762643+00:00 app[web.1]:
2015-05-19T14:12:14.762646+00:00 app[web.1]: ! @6m7idhci3 - Internal server error, for (GET) [/] ->
2015-05-19T14:12:14.762647+00:00 app[web.1]:
2015-05-19T14:12:14.762651+00:00 app[web.1]: play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.RuntimeException: org.postgresql.util.PSQLException: FATAL: terminating connection due to administrator command]]
2015-05-19T14:12:14.762653+00:00 app[web.1]: at play.api.Application$class.handleError(Application.scala:296) ~[com.typesafe.play.play_2.11-2.3.8.jar:2.3.8]
2015-05-19T14:12:14.762655+00:00 app[web.1]: at play.api.DefaultApplication.handleError(Application.scala:402) [com.typesafe.play.play_2.11-2.3.8.jar:2.3.8]
2015-05-19