Skip to content

Instantly share code, notes, and snippets.

View dillonhafer's full-sized avatar
🍄
Nintendo Power

Dillon Hafer dillonhafer

🍄
Nintendo Power
View GitHub Profile
@dillonhafer
dillonhafer / tern_diff.sh
Last active August 16, 2023 15:38
Tern diff
function terndiff() {
temp_db_name="tern_dev_$(date +%s)"
dropdb $temp_db_name 2>/dev/null
createdb $temp_db_name
PGDATABASE=$temp_db_name tern migrate >/dev/null
expected_structure=$(PGDATABASE=$temp_db_name pg_dump -s)
dropdb $temp_db_name
current_structure=$(pg_dump -s)
@dillonhafer
dillonhafer / gotest.rb
Last active May 23, 2023 21:46
go tests
#!/usr/bin/env ruby
file = ARGV[0]
line_num = ARGV[1].to_i
TestFn = Struct.new(:name, :start_line, :end_line)
tests = []
current_test = nil
File.read(file).lines.each.with_index do |line, i|
if line.start_with?("func Test")
@dillonhafer
dillonhafer / keybindings.json
Created December 29, 2022 16:09
terminal command keys
{
"key": "\\ t",
"command": "terminalCommandKeys.run",
"when": "editorTextFocus && vim.mode != 'Insert'",
"args": {
"cmd": "\u0015rails test ${file}",
"newTerminal": false,
"saveAllFiles": true,
"showTerminal": true,
"focus": true
@dillonhafer
dillonhafer / ,libqr.sh
Created December 23, 2022 20:21
Get local ip address for rails servers
function ,lipqr() {
ruby << RUBY
require "rqrcode"
class String
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def bg_black
@dillonhafer
dillonhafer / nginx.conf
Created August 12, 2022 22:34
Dream Machine Pro TLS reverse Proxy with nginx
# Custom Domain: dmp.dillonhafer.com
# DMP's LAN ip: 172.16.0.1
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name dmp.dillonhafer.com;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 10m;
@dillonhafer
dillonhafer / sanitize_emails.sql
Created June 9, 2022 13:10
Sanitize emails in mysql
update users
set email = replace(
email,
substring(
email,
locate('@', email),
length(email) - locate(email, '@')
),
'@example.com'
);
🍄: bin/rails server
💨: bin/rails tailwindcss:watch
🔥: firebase emulators:start --project firebase-project-id --import=./emulator-data
☕️: yarn build --watch
sox -q -d -t .wav f.wav silence 1 0.1 4% 1 0.01 5%
./right-click
sleep 1
./right-click
@dillonhafer
dillonhafer / pg-backups.sh
Created December 23, 2021 02:50
Keep last 5 days worth of pg backups
#!/bin/bash
# Keep last 5 files ending in .dump
# Don't forget to
# Installation
# 1. cp pg-backups.sh /usr/local/bin/
# 2. chmod u+x /usr/local/bin/pg-backups.sh
# 3. Set the DB variable
# 4. Set the BACKUP_DIR variable
@dillonhafer
dillonhafer / RN-actioncable-PATCH.ts
Last active September 30, 2021 03:54
Patch bugs in Rails' action cable to be able to use with ReactNative
// Just "import from './RN-actioncable-PATCH'" before using @rails/actioncable
import { AppState } from 'react-native';
let appState = AppState.currentState;
let sub: { remove(): void } | null = null;
// @ts-ignore
global.document = { visibilityState: 'visible' };