Skip to content

Instantly share code, notes, and snippets.

@ak4zh
ak4zh / accounting.sql
Last active October 21, 2023 04:03 — forked from NYKevin/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE account_groups
(
id bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ),
name text COLLATE pg_catalog."default" NOT NULL,
account_group_id bigint,
CONSTRAINT account_types_pkey PRIMARY KEY (id),
CONSTRAINT account_groups_account_group_id_fkey FOREIGN KEY (account_group_id)
REFERENCES public.account_groups (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
@hl
hl / context.ex
Last active August 28, 2021 04:55
defmodule Context do
@moduledoc false
defmacro __using__(opts) do
repo = Keyword.fetch!(opts, :repo)
quote do
import Context, only: [context: 1, context: 2]
Module.put_attribute(__MODULE__, :__repo__, unquote(repo))
@bruce
bruce / absinthe.md
Last active November 2, 2019 16:03
Very brief description of how Absinthe processes GraphQL
@ejpcmac
ejpcmac / setup
Created September 28, 2018 20:39
Setup script for Phoenix projects using Nix and PostgreSQL
#!/bin/sh
echo
if [ ! -d "deps" ] || [ ! "$(ls -A deps)" ]; then
printf "\e[32m=> Fetching dependencies and building the application...\e[0m\n\n"
echo "+ mix do deps.get, compile --verbose"
mix do deps.get, compile --verbose
echo
fi
@andyrbell
andyrbell / scanner.sh
Last active April 5, 2024 09:01
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
@JBlond
JBlond / bash-colors.md
Last active April 23, 2024 00:02 — forked from iamnewton/bash-colors.md
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
@LostKobrakai
LostKobrakai / post.md
Last active April 7, 2020 20:07 — forked from nahtnam/post.md
Using Laravel-Mix with Phoenix

Introduction

Laravel-Mix is "an elegant wrapper around Webpack for the 80% use case". It has nothing to do with Elixir's Mix and does not require Laravel to work!

Set up

Create a new phoenix application with mix phx.new. You may choose to add the --no-brunch flag to stop brunch from being intiailized, but I personally prefer leaving that in and replacing brunch so that the folder structure is set up for me.

$ mix phx.new demo

Install Laravel-Mix

@dankrause
dankrause / postgresql_recursive.sql
Last active February 26, 2024 16:03
An example of creating a recursive postgresql query to generate data about parent-child relationships within a single table.
CREATE TABLE test
(
id INTEGER,
parent INTEGER
);
INSERT INTO test (id, parent) VALUES
(1, NULL),
(2, 1),
@MicBrain
MicBrain / metatags.html
Last active April 8, 2024 12:53
The list of useful meta tags used in HTML5 documents.
<html>
<head>
<!--Recommended Meta Tags-->
<meta charset="utf-8">
<meta name="language" content="english">
<meta http-equiv="content-type" content="text/html">
<meta name="author" content=”Rafayel Mkrtchyan”>
<meta name="designer" content=”Rafayel Mkrtchyan”>
<meta name="publisher" content=”Rafayel Mkrtchyan”>
@yang-wei
yang-wei / destructuring.md
Last active February 20, 2024 04:40
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))