Skip to content

Instantly share code, notes, and snippets.

Avatar
👶
dad life

Robert Pearce rpearce

👶
dad life
View GitHub Profile
@rpearce
rpearce / flake.nix
Created Jun 19, 2021
IHP Web Framework Nix Flake
View flake.nix
{
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";
@rpearce
rpearce / .ghci
Last active Jul 16, 2021
Flake for using Haskell in nix develop
View .ghci
: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 / lightenDarkenHex.js
Created Mar 31, 2021
Ligthen Darken Hex Colors
View lightenDarkenHex.js
// 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 / bday.sh
Last active May 16, 2020
bday text game gift for my sister
View bday.sh
#!/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 Apr 10, 2017
Rails – open a file, read it and write it to a temp file
View tmp.rb
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
View install-script--temp-computer.sh
#!/bin/sh
###############################################################################
# XCode
###############################################################################
echo "Setting up XCode..."
xcodebuild -license
xcode-select --install
sudo xcode-select -switch /Library/Developer/CommandLineTools
View keybase.md

Keybase proof

I hereby claim:

  • I am rpearce on github.
  • I am rpearce (https://keybase.io/rpearce) on keybase.
  • I have a public key whose fingerprint is 6F5D 52E9 DEF3 D210 66AE 97F4 E8DD 20E4 8EFB 46B5

To claim this, I am signing this object:

View bank_users.csv
name pin balance
Elmo 5746 99999999
Oscar 4444 20
Mario 9090 10000
Peach 0000 100000000
Luigi 1234 474748
@rpearce
rpearce / interpol_hash_challenge.rb
Last active Sep 13, 2015
Interpolation & Hash Accessing Challenge
View interpol_hash_challenge.rb
# Your task is to use the `people` array of hashes below
# to create interpolated strings that will `puts` to the
# console the following lines:
#
# James, aged 82, is from Charleston, SC
# Jane, aged 67, is from New York, NY
# Jude, aged 42, is from London, UK
people = [
{ name: 'James', age: '82', location: 'Charleston, SC' },
View range_modulo_challenge.rb
# Use Enumerable to select all of the multiples
# of 3 in any given Range and return them in an Array.
# Hint: Check out the modulo operator.
#
# The output should read like the following:
# => [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]
#
# The resources you can use:
# http://ruby-doc.org/core-2.2.3/Enumerable.html
# http://stackoverflow.com/a/3517240