Skip to content

Instantly share code, notes, and snippets.

View abrahamy's full-sized avatar

Abraham Yusuf abrahamy

View GitHub Profile
import { make } from "@effect/platform/Template";
import { SqlClient } from "@effect/sql";
import { Array, Context, Effect, Layer, pipe, Stream } from "effect";
interface EmailMessage {
contents: string;
recipients: string | string[];
}
const makeLiveEmailService = Effect.gen(function* () {
@abrahamy
abrahamy / read-access.sql
Created June 13, 2019 12:50 — 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;
@abrahamy
abrahamy / gpg-import-and-export-instructions.md
Created June 10, 2019 10:04 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@abrahamy
abrahamy / clean_code.md
Created April 4, 2019 12:51 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@abrahamy
abrahamy / README.md
Created February 12, 2019 13:20 — forked from rduplain/README.md
Connect to MSSQL using FreeTDS / ODBC in Python.

Goal: Connect to MSSQL using FreeTDS / ODBC in Python.

Host: Ubuntu 11.10 x86_64

Install:

sudo apt-get install freetds-dev freetds-bin unixodbc-dev tdsodbc
pip install pyodbc sqlalchemy

In /etc/odbcinst.ini:

@abrahamy
abrahamy / environment.yml
Created October 8, 2018 08:49
Conda ENV
name: grasp
channels:
- defaults
dependencies:
- _tflow_1100_select=0.0.3=mkl
- absl-py=0.5.0=py36_0
- appdirs=1.4.3=py36h28b3542_0
- asn1crypto=0.24.0=py36_0
- astor=0.7.1=py36_0
- attrs=18.2.0=py36h28b3542_0

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

@abrahamy
abrahamy / app.py
Created May 11, 2018 15:55 — forked from jmvrbanac/app.py
Using Jinja2 with Falcon
import os
import falcon
import jinja2
def load_template(name):
path = os.path.join('templates', name)
with open(os.path.abspath(path), 'r') as fp:
return jinja2.Template(fp.read())
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abrahamy
abrahamy / gist:e46578cab7df82b4aa3f83258f0c6553
Last active March 7, 2018 08:47 — forked from econchick/gist:4666413
Python implementation of Dijkstra's Algorithm
class Graph:
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
self.nodes.add(value)
def add_edge(self, from_node, to_node, distance):