Skip to content

Instantly share code, notes, and snippets.

View danwakefield's full-sized avatar
🤠
Probably breaking something.

Daniel Wakefield danwakefield

🤠
Probably breaking something.
View GitHub Profile
# Export the text from the papier chrome extension (https://chromewebstore.google.com/detail/papier/hhjeaokafplhjoogdemakihhdhffacia)
# Extension was not updated to Manifest V3 and chrome won't allow it to be opened again so you lose you're notes.
# I was able to get them back with the below. You need go & jq, commands are for a Mac, but hopefully things work with other OS's
# No support given
$ go install github.com/cions/leveldb-cli/cmd/leveldb@latest
$ cp -r ~/Library/Application\ Support/Google/Chrome/Default/Local\ Storage/leveldb ~/documents/chrome-leveldb
$ rm ~/documents/chrome-leveldb/LOCK
$ cd ~/documents
$ level-db get "_chrome-extension://hhjeaokafplhjoogdemakihhdhffacia\0\x01papier-save" -d chrome-leveldb > key_value.txt
require 'csv'
# This reads a CSV and outputs it in the Cross Stitch osx format
# For the life of me I could not get https://flosscross.com/ to actually read the output
# when run with `ruby csv_to_osx_cross_stitch_format.rb > output.osx`
# despite `file output.osx` telling me it was valid XML (and being the same as
# a file _exported_ from flosscross)
# Instead I created a new blank project in flosscross, exported that to OSX,
#!/bin/bash
set -e
files=$(git diff --staged --name-only --diff-filter=ACMRTUXB | grep '\.rb$' | tr '\\\n' ' ')
# Check we have files before trying to run the tests.
# Prevents getting stuck if we only update non .rb files.
if [[ -n $files ]];then
if [ $commands[gxargs] ]; then
git diff --staged --name-only --diff-filter=ACMRTUXB | grep '\.rb$' | tr '\\\n' ' ' | gxargs --no-run-if-empty bundle exec rubocop -A --force-exclusion --config "$(git rev-parse --show-toplevel)/.rubocop.yml"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
-- The args being numeric cause auto casting; This is what we want
-- e.g `COUNT(*)` returns a whole number but we often want to divide it to float
-- Postgres percent function
CREATE OR REPLACE FUNCTION percent(portion numeric, total numeric, round_level integer default 1)
RETURNS numeric
IMMUTABLE
RETURNS NULL ON NULL INPUT
PARALLEL SAFE
as $fbd$
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@danwakefield
danwakefield / uk-postcode-district-centroid.json
Last active February 6, 2024 16:43
UK Postcode District GeoJSON, Centroid points
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@danwakefield
danwakefield / pre-commit
Created January 6, 2022 14:23
Rubocop pre-commit
#!/bin/bash
# move to `.git/hooks/pre-commit`; run `chmod +x .git/hooks/pre-commit`
set -e
files=$(git diff --staged --name-only --diff-filter=ACMRTUXB | grep '\.rb$' | tr '\\\n' ' ')
# Check we have files before trying to run the tests.
# Prevents getting stuck if we only update non .rb files.
if [[ -n $files ]];then
git diff --staged --name-only --diff-filter=ACMRTUXB | grep '\.rb$' | tr '\\\n' ' ' | xargs --no-run-if-empty bundle exec rubocop -A --config "$(git rev-parse --show-toplevel)/.rubocop.yml"
\set QUIET 1
\pset null '¤'
\set PROMPT1 '[%/] > '
\set PROMPT2 '%R > '
\timing
\x auto
\set VERBOSITY verbose
1 2 diff wanted result
A A A
B < B
C C C
D > D