Skip to content

Instantly share code, notes, and snippets.

View simosentissi's full-sized avatar

simo sentissi simosentissi

View GitHub Profile
@hays-hutton
hays-hutton / schema.sql
Created March 16, 2016 16:31
A Simplified Schema Example for PostgREST
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE IF NOT EXISTS
users (
email TEXT PRIMARY KEY CHECK ( email ~* '^.+@.+\..+$' ),
pass TEXT NOT NULL CHECK (length(pass) < 256),
role NAME NOT NULL CHECK (length(role) < 256)
);
CREATE TABLE IF NOT EXISTS
@shamasis
shamasis / describe-it.js
Last active September 5, 2023 07:12
mocha/jasmine compatible test framework for postman test scripts (in less than 1KB minified)
/**
* @module describe-it
*
* This module defines global variables to provide unit test case runner functions compatible with mocha and jasmine.
* The codebase is written for brevity and facilitate being as lightweight as possible.
*
* The code is intended to be included in Postman Test Sandbox.
*/
/**
@aanari
aanari / batch_at_will_commander.sql
Last active August 8, 2020 15:31
7 PostgreSQL data migration hacks you should be using (but aren't)
CREATE FUNCTION batch_at_will() RETURNS INTEGER LANGUAGE plpgsql AS $$
DECLARE batched_count INTEGER = 1;
BEGIN
WITH selected_users AS (
SELECT id
FROM users
WHERE role = 'moderator'
AND registration_date < CURRENT_DATE - INTERVAL '4' YEAR
LIMIT 1000
FOR UPDATE NOWAIT
@timyates
timyates / Currying.java
Last active March 7, 2020 07:11
Currying and composition in Java 8
package java8tests ;
import java.util.function.BiFunction ;
import java.util.function.Function ;
public class Currying {
public void currying() {
// Create a function that adds 2 integers
BiFunction<Integer,Integer,Integer> adder = ( a, b ) -> a + b ;
@abrkn
abrkn / sql-tdd.markdown
Last active May 22, 2020 14:59
Migrations and testing for PostgreSQL using node.js and Travis-CI

Migrations and testing for PostgreSQL using node.js and Travis-CI

We're looking to add a column to the table user called admin (boolean) in an existing database.

Project layout

migrations