Skip to content

Instantly share code, notes, and snippets.

View booherbg's full-sized avatar

Blaine Booher booherbg

View GitHub Profile
@booherbg
booherbg / migration.md
Last active July 25, 2022 20:20
Migrating from Elixir to SQLAlchemy declarative

I have a project that's a few years old, but needs some maintenance. Since I last worked on the project, two major things have happened. First, Elixir -- a declarative layer on top of SQLAlchemy -- has not been maintained. Secondly, SQLAlchemy now has its own declarative layer.

Rather than continue using Elixir, I decided to migrate my data models to use the new SQLAlchemy declarative layer, which interestingly enough appear to be relatively compatible with Elixir's philosophy.

The first thing I did was do a direct mapping in my model columns and update the import statements.

# from Elixir import Entity, Field, DateTime, Unicode, Integer, Boolean, setup_all, create_all, session, metadata
from sqlalchemy import Column, DateTime, String, Integer, ForeignKey, Boolean
from sqlalchemy.ext.declarative import declarative_base
@booherbg
booherbg / dotnet-notes.md
Last active March 9, 2022 21:14
Up and running with dotnet

Notes from early experiments with dotnet on Mac OSX

Installation: dotnet and VS Code

Installation was amazingly easy. < 2 minutes and dotnet is available from the command line.

Don't forget to install the c# plugin for VS Code (powered by omnisharp).

Omnisharp

@booherbg
booherbg / gist:f812c9145d157d8945b2
Last active February 25, 2022 23:44
Cross compiling a simple go server for windows

How to build Golang windows/arm static binaries from linux

Alternate title: Cross compiling Windows/Darwin/Linux amd64/386/arm all from linux

After fumbling around trying to figure out the go toolchain and cross compilation configuration, I ran across the wiki page on Go's homepage. It's super helpful, and worked out of the box. I'm including the necessary scripts here in case they get changed or lost, and we can help Google find it (since it's the first real source I've found that "Just Worked"). http://code.google.com/p/go-wiki/wiki/WindowsCrossCompiling

@booherbg
booherbg / gist:b4f26a947c52ba31940c
Last active November 11, 2021 09:44
Setting up RetroPi + iBuffalo SNES controllers
The documentation online can be confusing, especially with config paths from old files floating around.
1. Download an image file for RetroPi (Ideally 2.5+)
2. Unzip the image file, plug in your SD card (likely /dev/sdb)
3. dd if=retropi.img of=/dev/sdb (this will erase your entire SD card)
4. Optional: increase the size of the new partition with gparted
System Setup
1. Add your ROMs to ~/RetroPi/roms/snes (which will cause your EmulationStation to now show the system in the menu). Be sure to unzip them.
2. (Not needed in RetroPie 2.5) Update your controller config, either by running ~/retropi_setup/retropi_setup.sh, or copying a known config to /opt/retropie/emulators/RetroArch/USB,2-axis8-buttongamepad.cfg
@booherbg
booherbg / ffmpeg-split.md
Last active November 10, 2021 22:21
ffmpeg split video
ffmpeg -ss 00:00:00.000 -i turtle.mkv -t 00:45:00.000 -c copy out.mkv

To cut out a section, just split it before and after the section to cut, then create a file with the filenames in it and run concat:

:: Create File List
echo file file1.mp4 >  mylist.txt 
echo file file2.mp4 >> mylist.txt
echo file file3.mp4 &gt;&gt; mylist.txt
@booherbg
booherbg / katas-notes.md
Last active October 7, 2021 21:11
Katas Notes

Kata Practice

Given an integer, write a function findSum that returns the sum of all multiples of 3 or 5 up to up to n.

findSum(8) returns 5 findSum(33) returns 10

JavaScript

@booherbg
booherbg / certbot-auto.md
Last active August 3, 2021 18:39
Replacing legacy certbot-auto with docker

Replacing existing certbot-auto installation on Ubuntu 14 with Docker

The problem: Legacy certbot-auto is no longer supported, and ACMEv1 challenge has been deprecated and removed. On newer systems, you can simply upgrade certbot using apt-get install --upgrade-only certbot and you'll be good to go.

However, on legacy servers (Ubuntu 14), it isn't possible to upgrade. Installing manually isn't good either because python3 uses python3.4 which has a broken pip installation (ugh).

Docker to the rescue!

@booherbg
booherbg / postgres-upgrade.md
Created July 7, 2021 18:29
Upgrading Postgres from 12 to 13

I have no idea how but postgres was upgraded to 13, but the database was still in 12, so it wouldn't boot.

This URL saved the day: https://quaran.to/Upgrade-PostgreSQL-from-12-to-13-with-Homebrew

brew services stop postgresql
brew postgresql-upgrade-database
./analyze_new_cluster.sh
brew services start postgresql
ps ax | grep postgres
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
// ctx.globalCompositeOperation = 'destination-over';
const edge = 200;
const particleScale = 20;
let drawing = false;
~/.config/spacebar/spacebarrc
```
spacebar -m config status_bar off
spacebar -m config text_font "Helvetica Neue:Bold:11.0"
spacebar -m config icon_font "FontAwesome:Regular:11.0"
spacebar -m config background_color 0xff202020
spacebar -m config foreground_color 0xffa8a8a8
spacebar -m config space_icon_strip 1 2 3 4 5 6 7 8 9 10
spacebar -m config power_icon_strip  
spacebar -m config space_icon 