Skip to content

Instantly share code, notes, and snippets.

View maleghast's full-sized avatar

Oliver Godby maleghast

View GitHub Profile
@maleghast
maleghast / table_copy.md
Last active May 22, 2018 10:17
Aide Memoire for how to move / copy a table from one DB to another under PostgreSQL...

pg_dump -> psql

e.g.

  1. pg_dump -U [username] -h [hostname] -p [port number] -d [source database] -t [source_table] > [output_filename].sql

  2. cat [output_filename].sql | psql -U [username] -h [hostname] -p [port number] -d [target database]

If the [target database] already has the table that you want to copy, then run the pg_dump with a "-a" flag to dump 'data only'

@maleghast
maleghast / form-3-functions.cljs
Created June 10, 2018 17:48
Example form-3 functions for redefining TreeMap in Recharts
(defn treemap-label
[]
(r/create-class
{:reagent-render (fn
[]
(let [props (r/props this)]
[:g
[:text
{:x (/ (+ (:x props) (:width props)) 2)
:y (+ (/ (+ (:y props) (:height props)) 2) 7)
@maleghast
maleghast / aoc2023_day1.clj
Created December 1, 2023 17:34
AoC 2023 - Day 1
(ns maleghast.aoc2023.day1
(:require [clojure.string :as str]
[clojure.java.io :as io])
(:gen-class))
(defn first-and-last
[vec-of-nums-as-strings]
(str (first vec-of-nums-as-strings) (last vec-of-nums-as-strings)))
(defn numbers-as-text-to-digits
@maleghast
maleghast / aoc2023_day2.clj
Created December 3, 2023 17:37
Advent of Code 2023 - Day 2 completed Clojure solution
(ns maleghast.aoc2023.day2
(:require [clojure.string :as str]
[clojure.java.io :as io])
(:gen-class))
(def colour-maximums {:blue 14 :green 13 :red 12})
(defn check-game-valid
[game-data]
(reduce