Skip to content

Instantly share code, notes, and snippets.

View rpearce's full-sized avatar
👶
infant and toddler duty

Robert Pearce rpearce

👶
infant and toddler duty
View GitHub Profile
@rpearce
rpearce / gift-len
Created August 22, 2023 01:52
Gift for my friend, Len
#!/bin/bash
set -o errexit
set -o errtrace
set -o nounset
set -eou pipefail
# ==============================================================================
function clearscreen {
@rpearce
rpearce / .ghci
Last active August 15, 2023 00:36
Flake for using Haskell in nix develop
:def hoogle \x -> return $ ":!hoogle --count=15 \"" ++ x ++ "\""
:def doc \x -> return $ ":!hoogle --info \"" ++ x ++ "\""
:set -Wall
:set -fno-warn-type-defaults -ferror-spans -freverse-errors -fprint-expanded-synonyms
:set prompt "\ESC[0;32m%s\n\ESC[m[ghci]\ESC[38;5;172mλ \ESC[m"
:set prompt-cont " \ESC[38;5;172m> \ESC[m"
@rpearce
rpearce / install-script--personal.sh
Last active July 25, 2023 16:04
New Mac Install Script (Personal)
#!/bin/sh
###############################################################################
# Homebrew
###############################################################################
echo "Installing command line utilities"
# Check for Homebrew,
# Install if we don't have it
@rpearce
rpearce / retry
Last active January 19, 2023 01:13
Bash script for retrying commands
#!/usr/bin/env bash
set -o errexit
#set -o errtrace
set -o nounset
#set -eou pipefail
# ==============================================================================
VERSION="0.1.0"
@rpearce
rpearce / bash_args_parsing_template
Last active January 19, 2023 01:12
Bash argument parsing program template
#!/bin/bash
set -o errexit
set -o errtrace
set -o nounset
set -eou pipefail
# ==============================================================================
VERSION="0.1.0"
@rpearce
rpearce / lightenDarkenHex.js
Created March 31, 2021 14:17
Ligthen Darken Hex Colors
// helper functions are from https://github.com/rpearce/hex
const lightenDarken = (direction, color) => {
const rgb = hexToRgba(color).slice(0, 3)
// algo from https://stackoverflow.com/a/21038522/680394
const rgbAdjusted = direction >= 0
? rgb.map(x => (1 - direction) * x + direction * 255)
: rgb.map(x => (1 + direction) * x)
@rpearce
rpearce / xmas-sam
Created December 9, 2022 08:29
Xmas present for a great brother in-law
#!/bin/bash
set -o errexit
set -o errtrace
set -o nounset
set -eou pipefail
# ==============================================================================
function clearscreen {
@rpearce
rpearce / bday-kp.sh
Last active December 9, 2022 06:41
bday text game gift for my sister
#!/usr/bin/env bash
set -o errexit
set -o errtrace
set -o nounset
set -eou pipefail
function clearscreen {
printf '\033c'
}
@rpearce
rpearce / tmp.rb
Created April 10, 2017 22:55
Rails – open a file, read it and write it to a temp file
module Tmp
def self.build(src:, name:, ext:, binmode: false)
file = Tempfile.new([name, ext], Rails.root.join('tmp'))
file.binmode if binmode
open(src) { |f| file.write(f.read) }
file.rewind
file.close
file
end
end
@rpearce
rpearce / flake.nix
Created June 19, 2021 18:29
IHP Web Framework Nix Flake
{
description = "IHP flake";
nixConfig.bash-prompt = "[nix]\\e\[38;5;172mλ \\e\[m";
inputs = {
nixpkgs.url = "nixpkgs/nixos-21.05";
flake-utils = {
url = "github:numtide/flake-utils";