Skip to content

Instantly share code, notes, and snippets.

View josephfinlayson's full-sized avatar

Joseph Finlayson josephfinlayson

View GitHub Profile
[
{
"code": "1001",
"category": "HOME",
"type": "SUBSCRIPTION",
"name": "Home emergency assistance and insurance",
"description": "We cover the typical mishaps you may encounter: If you lost your keys, a window or door gets broken and many more. Our assistance service is able to dispatch every type of craftsmen at no additional cost & at high quality and guaranteed low cost. 12 month subscription, coverage max. 1,500 per incident.",
"price": 119
},
@josephfinlayson
josephfinlayson / schema.js
Last active August 29, 2015 14:23
JSON Schemas
//all are /application/json
//Offering an item
// POST request to endpoint /api/postItem
{
itemName: String,
itemPrice: Number,
Description: String,
lockerCode: String,
image: String, //BASE64
//all are /application/json
//Offering an item
// POST request to endpoint /api/postItem
{
itemName: String,
itemPrice: Number,
Description: String,
lockerCode: String,
image: String, //BASE64

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@josephfinlayson
josephfinlayson / decorators.js
Created June 15, 2016 14:23
Analytics decorator
/**
* This function is used to push client side events to redshift. It should only be used for client side only events,
* any event that involves a request to the backend, will create similar events there
*
* ::USAGE::
* ========
*
* analyticsDecorator({
* constant: 'CONSTANT', mapping(arg1, arg2) {
* return {
@josephfinlayson
josephfinlayson / gist:d9c79a73cecf4f24bf91167a1cfe43e8
Created December 28, 2016 18:43
What is HelloWorld in this example?
package com.tutorialspoint;
import org.springframework.context.annotation.*;
@Configuration
public class HelloWorldConfig {
@Bean
public HelloWorld helloWorld(){
return new HelloWorld();
}
@josephfinlayson
josephfinlayson / diffObjs.js
Created February 10, 2017 11:00
Difference between objects
import R from 'ramda'
const groupObjBy = R.curry(R.pipe(
// Call groupBy with the object as pairs, passing only the value to the key function
R.useWith(R.groupBy, [R.useWith(R.__, [R.last]), R.toPairs]),
R.map(R.fromPairs)
))
const diffObjs = R.pipe(
R.useWith(R.mergeWith(R.merge), [R.map(R.objOf("leftValue")), R.map(R.objOf("rightValue"))]),
@josephfinlayson
josephfinlayson / ofxconverter.ipynb
Created January 3, 2018 15:29
Convert N26 CSV to OFX
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@josephfinlayson
josephfinlayson / read-access.sql
Created August 1, 2019 12:28 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;