Skip to content

Instantly share code, notes, and snippets.

View begriffs's full-sized avatar

Joe Nelson begriffs

View GitHub Profile
@begriffs
begriffs / onlylock.diff
Created February 8, 2016 23:29
remove all actual updating
diff --git a/src/PostgREST/App.hs b/src/PostgREST/App.hs
index d1d27b4..abf3d8f 100644
--- a/src/PostgREST/App.hs
+++ b/src/PostgREST/App.hs
@@ -53,6 +53,7 @@ import PostgREST.QueryBuilder ( callProc
, addRelations
, createReadStatement
, createWriteStatement
+ , lockRowExclusive
, ResultsWithCount
@begriffs
begriffs / lockrow.diff
Created February 8, 2016 22:28
Lock row exclusive on update requests
diff --git a/src/PostgREST/App.hs b/src/PostgREST/App.hs
index d1d27b4..b701501 100644
--- a/src/PostgREST/App.hs
+++ b/src/PostgREST/App.hs
@@ -53,6 +53,7 @@ import PostgREST.QueryBuilder ( callProc
, addRelations
, createReadStatement
, createWriteStatement
+ , lockRowExclusive
, ResultsWithCount
@begriffs
begriffs / rep.csv
Created February 8, 2016 21:49
deadlock with return=representation, pool=3, clients=3
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 23 columns, instead of 1 in line 5.
2016-02-08 13:47:45.472 PST,"j","demo1",90926,"::1:49581",56b90d00.1632e,1,"idle",2016-02-08 13:47:44 PST,2/88,0,LOG,00000,"statement: SET client_encoding = 'UTF8';SET client_min_messages TO WARNING;",,,,,,,,,""
2016-02-08 13:47:45.972 PST,"j","demo1",90926,"::1:49581",56b90d00.1632e,2,"idle",2016-02-08 13:47:44 PST,2/89,0,LOG,00000,"statement: begin ISOLATION LEVEL READ COMMITTED;",,,,,,,,,""
2016-02-08 13:47:47.979 PST,"j","demo1",90927,"::1:49586",56b90d02.1632f,1,"idle",2016-02-08 13:47:46 PST,3/16,0,LOG,00000,"statement: SET client_encoding = 'UTF8';SET client_min_messages TO WARNING;",,,,,,,,,""
2016-02-08 13:47:48.479 PST,"j","demo1",90927,"::1:49586",56b90d02.1632f,2,"idle",2016-02-08 13:47:46 PST,3/17,0,LOG,00000,"statement: begin ISOLATION LEVEL READ COMMITTED;",,,,,,,,,""
2016-02-08 13:47:50.485 PST,"j","demo1",90928,"::1:49587",56b90d05.16330,1,"idle",2016-02-08 13:47:49 PST,4/89,0,LOG,00000,"statement: SET client_encoding = 'UTF8';SET client_min_messages TO WARNING;",,,,,,,,,""
2016-02-08 13:47:5
@begriffs
begriffs / ghcmod.txt
Created February 8, 2016 18:29
ghc mod diagnose
Current filetype: haskell
filetype detection:ON plugin:ON indent:ON
ghcmod.vim version: 1.3.1
ghc-mod is executable: 1
vimproc.vim: 902
ghc-mod version: 5.4.0
ghc-mod debug command: ghc-mod debug
Root directory: /root/hasql
Current directory: /root/hasql
GHC Package flags:
@begriffs
begriffs / dd.hs
Created February 8, 2016 18:14
simplified deadlock test
module Main where
import Control.Monad (replicateM_)
import Hasql.Connection
import Hasql.Session
import Hasql.Query
main :: IO ()
main = do
acquire "postgres://postgres@localhost:5432/demo1" >>= \case
@begriffs
begriffs / with.sql
Created February 7, 2016 22:12
Examples of queries built up using WITH statements
-- JSON FESTIVAL
WITH pg_source AS
(SELECT "public"."festival".* FROM "public"."festival")
SELECT
(SELECT pg_catalog.Count(1) FROM "public"."festival") AS total_result_set,
pg_catalog.Count(t) AS page_total,
NULL AS header,
Array_to_json(Array_agg(Row_to_json(t)))::character VARYING AS body
FROM
@begriffs
begriffs / learnme.txt
Created February 4, 2016 16:34
Songs I'd like to learn to play
Leo Ornstein - Sonata No. 8, Mvt. 2c
Satie - Descriptions automatiques
Mompou - Musica Callada, first song
Poulenc - Suite française, 2nd mvmt, specificially Bransle de Champagne
Rodrigo - Berceuse d'automne
Blancafort - Cançó en l'Ermita
Severac - En Vacances 4th song
Percy Grainger - Walking Tune (at least the start)
George Enescu - Suite no.3, Op.18, “Pièces impromptues”
Copland - Midsummer Nocturne
@begriffs
begriffs / graphql.md
Last active January 29, 2016 18:23
User with profile pic - GraphQL vs PostgREST

Selecting a user with their profile pic (from GraphQL introduction).

{
  user(id: 3500401) {
    id,
    name,
    isViewerFriend,
    profilePicture(size: 50)  {
 uri,
@begriffs
begriffs / already-in-progress-2.hs
Created January 24, 2016 08:20
another situation that causes the command in progress error
module Lib
( someFunc
) where
import Control.Monad
import Data.Int
import Data.Monoid
import Data.Functor.Contravariant
import Hasql.Connection
import Hasql.Session
@begriffs
begriffs / pool-stash.diff
Created January 23, 2016 22:08
A stash I have laying around that tries to use a db pool for tests
diff --git a/test/Feature/AuthSpec.hs b/test/Feature/AuthSpec.hs
index f678ae2..6f7d8bb 100644
--- a/test/Feature/AuthSpec.hs
+++ b/test/Feature/AuthSpec.hs
@@ -6,13 +6,14 @@ import Test.Hspec.Wai
import Test.Hspec.Wai.JSON
import Network.HTTP.Types
import qualified Hasql.Connection as H
+import Data.Pool