Skip to content

Instantly share code, notes, and snippets.

View benjie's full-sized avatar

Benjie benjie

View GitHub Profile
begin;
create table a(foo varchar not null primary key);
create table b(foo varchar not null primary key, constraint qux foreign key (foo) references a deferrable initially deferred);
create function bar() returns trigger as $$
begin
if TG_OP = 'INSERT' then
insert into b(foo) values(new.foo);
elsif TG_OP = 'DELETE' then
delete from b where foo = old.foo;
end if;
@benjie
benjie / circle.yml
Last active December 13, 2016 01:25
Getting PLv8 to run on Postgresql 9.5 on CircleCI (Ubuntu 14.04)
dependencies:
pre:
- sudo apt-get update
- sudo pip install pgxnclient
- sudo apt-get install libpq-dev libv8-dev postgresql-server-dev-9.5
- sudo pgxn install 'plv8=1.4.4'
# Just to be 100% certian you are using 9.5, and save a bit of memory.
- sudo service postgresql stop 9.4
- sudo service postgresql restart 9.5
@benjie
benjie / 2016-04-13.md
Last active April 20, 2016 08:18
Dalek Committee notes

Phase 2 Initial Dalek Planning Meeting

Tuesday 12th April 2016, 8pm

Present: Alan D, Al B, Benjie G, Bracken D, James B, Mark H, Paul D, Richard G, Step S, Tyler W

Apologies: Jem G, Stephen C, Chris S

First we attempted to outline some of the issues the Dalek has and what we'd like to improve about him. These included things such as (in alphabetical order...):

@benjie
benjie / README.md
Created April 1, 2016 09:15
Easy plv8 on OSX

Heroku runs plv8 v1.4.2 (checked on 1st April 2016). On OSX it's easiest to install v1.4.3 since that allows V8 3.15 which is available via homebrew. (1.4.2 wants V8 3.14.5).

To install:

brew install v8-315
pip install pgxnclient
LIBRARY_PATH="/usr/local/opt/v8-315/lib" CPATH="/usr/local/opt/v8-315/include" pgxnclient install plv8=1.4.3
@benjie
benjie / README.md
Created April 1, 2016 09:15
Easy plv8 on OSX

Heroku runs plv8 v1.4.2 (checked on 1st April 2016). On OSX it's easiest to install v1.4.3 since that allows V8 3.15 which is available via homebrew. (1.4.2 wants V8 3.14.5).

To install:

brew install v8-315
pip install pgxnclient
LIBRARY_PATH="/usr/local/opt/v8-315/lib" CPATH="/usr/local/opt/v8-315/include" pgxnclient install plv8=1.4.3
@benjie
benjie / npm-shrinkwrap.json
Created February 25, 2016 08:28
Members Area shrinkwrap
{
"name": "members-area",
"version": "0.4.0",
"dependencies": {
"addressparser": {
"version": "0.3.2",
"from": "addressparser@>=0.3.2 <0.4.0",
"resolved": "https://registry.npmjs.org/addressparser/-/addressparser-0.3.2.tgz"
},
"amdefine": {
@benjie
benjie / CoffeeScriptReasons.md
Last active November 4, 2016 15:43
Reasons CoffeeScript is still relevant for me

I'm often asked why I still use CoffeeScript rather than ES6/7. Well, in truth I use both, but I do still prefer CoffeeScript for the following reasons:

  • Correctly trimmed multiline strings (ES6 includes the indentation because it doesn't have significant whitespace)
  • Existential operator (a?.b; b?(); a?.b?() and of course a ? b)
    • a ? b is more appropriate than a || b if "" or 0 are values of a you wish to persist
    • (a && a.b && typeof a.b === 'function') ? a.b() : undefined doesn't quite have the same ring to it as a?.b?()
  • Significant whitespace
    • (a personal preference, but since you already lay your code out sensibly why do you need the additional visual distraction of braces?)
  • Convenient shorthand for common things (-> (regular non-bound function), @ (this.), :: (.prototype.))
  • in to check if something in a list
@benjie
benjie / dalek
Last active August 29, 2015 14:20
Dalek Notes
#!/bin/sh
### BEGIN INIT INFO
# Provides: dalek
# Required-Start: $local_fs $syslog $bluetooth
# Required-Stop: $local_fs $syslog $bluetooth
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Description: Dalek control software
### END INIT INFO
@benjie
benjie / something_like_this.sh
Created April 17, 2015 20:49
Members Area rough instructions
git clone https://github.com/somakeit/somakeit-members-area.git
cd somakeit-members-area
npm install
./node_modules/.bin/members migrate
./node_modules/.bin/members seed
npm start
@benjie
benjie / README.md
Created April 2, 2015 21:20
DOOR NOTES

Notes on installing the door-controller

DO NOT FOLLOW THESE NOTES, THEY ARE HACKS!

Do not install node from apt, install v0.10.x (x = 28)

Use gpio-admin from pull request #6 romilly/quick2wire-gpio-admin#6

Make similar changes to pi-gpio node module