Skip to content

Instantly share code, notes, and snippets.

View Breefield's full-sized avatar

Bree Hoffman Breefield

View GitHub Profile
data class Animal(
val name: String
)
data class Farm(
val animals: List<Animal> = emptyList(),
)
CREATE TRIGGER test_trigger_insert_update AFTER UPDATE OR INSERT ON inventory FOR EACH ROW EXECUTE PROCEDURE record_inventory_change();
CREATE TRIGGER test_trigger_delete BEFORE DELETE ON inventory FOR EACH ROW EXECUTE PROCEDURE record_inventory_change();
CREATE OR REPLACE FUNCTION
record_inventory_change()
RETURNS TRIGGER LANGUAGE plpgsql AS $$
DECLARE
columns text;
entity RECORD := NEW;
_deleted VARCHAR(5) := 'false';
BEGIN
SELECT string_agg(column_name, ',') INTO columns from information_schema.columns where table_name = 'inventory';
IF TG_OP = 'DELETE' THEN
CREATE TABLE inventory_audit AS TABLE inventory WITH NO DATA;
ALTER TABLE inventory_audit ADD COLUMN _deleted BOOLEAN DEFAULT FALSE;
ALTER TABLE inventory_audit ADD COLUMN audit_id SERIAL PRIMARY KEY;
ALTER TABLE inventory_audit ADD COLUMN _created_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
CREATE INDEX idx_inventory_audit_id ON inventory_audit (id);
CREATE TABLE inventory (
id SERIAL PRIMARY KEY,
item VARCHAR(255) NOT NULL,
price INTEGER NOT NULL,
created_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
import time
i = 0
while True:
i += 1
print("ping" if i % 2 else "pong")
time.sleep(0.5)
screen /dev/tty.usbmodem14301 115200
ls /dev/tty.*
@Breefield
Breefield / weekly_email.rb
Created February 11, 2015 18:55
Weekly Event Mailer
<h2>This week's parties!</h2>
These parties are all in/close to <%= @user.profile.location %> - because you set your Speakeasy profile's location to there.
<br>You can change your location by <%= link_to "updating your profile", edit_profile_url(:subdomain => 'www') %>.
<br>
<%
# List events at top of email
day = nil
@locations.each do |location|
event = location.event
//
// Stripe.m
// Stripe
//
// Created by Saikat Chakrabarti on 10/30/12.
// Copyright (c) 2012 Stripe. All rights reserved.
//
#import "STPAPIConnection.h"
#import "Stripe.h"