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 / gist:a075b307a234772eee44
Created April 9, 2015 20:18
Database migrations with SQLAlchemy, Flask, Elixir, SQLite
I have a project that was built 3 years ago, back before Elixir stopped being maintained. As projects have a tendancy to do, it's now time for an update. I've learned a lot in the last 3 years, and am looking forward to adding database migrations to the project. At the same time, if it aint broke don't fix it. I'm keeping Elixir in place, as it works well for our needs. However, Flask-Migrate relies on direct access to an SQLAlchemy object. I'm keeping is simple and going directly to the source: alembic.
The nice thing about this is that I can do the migrations directly on the db, without needing Elixir or any of our app logic.
``` bash
$ alembic init alembic
$ alembic revision -m "adding fields to media: id, filename_uploaded, and tags"
Generating /data/cliftonlabs/sportsvision/alembic/versions/4b7eedb40b12_adding_fields_to_media_id_filename_.py ... done
```
During install, my /dev/sda was not recognized (even though fdisk -l shows it). I did, however, get prompted about enabling RAID devices.
blkid /dev/sda
/dev/sda: UUID="DELL ^P(" TYPE="ddf_raid_member"
dmraid -E -r /dev/sda
Do you really want to erase "ddf1" ondisk metadata on /dev/sda? y/n :y
ERROR: ddf1: seeking device "/dev/sda" to 12803086946048
ERROR: writing metadata to /dev/sda, offset 250059349504 sectors, size 0 bytes returned 0
ERROR: erasing ondisk metadata on /dev/sda
@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 / gist:b083cac2982f4e0ae590
Last active August 29, 2015 14:02
Reasons I like Golang

For my own reminders...

General

  • Go is fun, like python fun.
  • Structs are fun, easy to use
  • maps are fun, easy to use
  • Pointers, references act as you'd expect them to
  • Duck typing, static typing mix
  • Feels expressive, like python. Compiled and fast, like C++
@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