Skip to content

Instantly share code, notes, and snippets.

View off-by-some's full-sized avatar
🖥️
Turning puzzles into principles and questions into frameworks.

Cassidy Bridges off-by-some

🖥️
Turning puzzles into principles and questions into frameworks.
View GitHub Profile
@off-by-some
off-by-some / run.py
Created June 1, 2023 20:32
MIDI to text
import mido
def translate_midi_to_custom_format(midi_file):
# Load the MIDI file
mid = mido.MidiFile(midi_file)
# Get the format and division from the MIDI file
format = mid.type
division = mid.ticks_per_beat
@off-by-some
off-by-some / base64_lazy.rb
Created April 23, 2022 03:10
Lazy Decode Base64 from a file using Ruby
module Base64Lazy
def decode64_in_chunks(file)
Base64Lazy::Helpers.chunk_file(file) do |chunk|
# Convert each character to it's 6 bit representation of it's index in MAPPING
chunks_6_bit = chunk.map { |char| Base64Lazy::Helpers.to_n_bit(char, 6) }
# Join each 6 bits into a 24 bit representation, then splits back into 8 bit representations;
# Omits the last chunk as it doesn't meet 8 bits
chunks_8_bit = chunks_6_bit.join("").scan(/.{8}/)
@off-by-some
off-by-some / IAM Permissions List.md
Created June 9, 2020 16:40 — forked from mechcozmo/IAM Permissions List.md
A list of IAM permissions you can use in policy documents. Collected from the myriad of places Amazon hides them. (incomplete)

Update 7/28/2019: An updated version of this guide for Ubuntu Server 18.04 LTS is now available. Feel free to check it out.

Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS

This guide will walk you through steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest. Tested on Ubuntu Server 16.04.3 LTS (Xenial Xerus)

Steps:

  1. Open VirtualBox
  2. Right-click your VM, then click Settings
  3. Go to Shared Folders section
@off-by-some
off-by-some / create_avd.md
Created March 13, 2020 02:47 — forked from hkhc/create_avd.md
Creating and launching Android emulator AVD properly

Creating AVD

avd_name=my_avd
api_level=23
abi=x86_64
tag=google_apis
device="Nexus 5" # list of available devices see below

${ANDROID_HOME}/tools/bin/avdmanager --verbose create avd --name ${avd_name} \
import _ from "lodash"
// Small date util lib to fill those missing features of moment
// TL;DR, Native Date sucks at adding dates
// var d = new Date("10/31/2011");
// d.setMonth(d.getMonth() + 1);
// console.log(d); => Thu Dec 01 2011 00:00:00 GMT-0800 (PST)
const _modifier = {
months: (startDate, amount) => _.range()
}
@off-by-some
off-by-some / kill_active_window.sh
Created May 18, 2016 18:41
Grabs the active window and kills it
!#/bin/bash
ps -o pid $(xprop -id $(xprop -root -f _NET_ACTIVE_WINDOW 0x " \$0\\n" _NET_ACTIVE_WINDOW | awk "{print \$2}") -f _NET_WM_PID 0c " \$0\\n" _NET_WM_PID | awk "{print \$2}") | grep -o -P ".*?(\\d+)" | xargs kill
@off-by-some
off-by-some / k.js
Created July 31, 2015 02:11
Calculating notes from frequencies
let n = (a, i, b) => Math.log(i/b) / Math.log(a)
function findNote(freq, base=440.00) {
let notes = ["A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"]
let octave = 4
const a = Math.pow(2, 1 / 12)
// Our base of A4
const b = base
@off-by-some
off-by-some / stateless_iter.py
Last active August 29, 2015 14:25
Stateless iteration in python
def s_iter(min, max):
def iter(max, current):
if not current > max:
return current
# End of iteration
return None
return iter(max, min)
module main
let print sol =
printfn "%i" sol
let solve problem =
problem |> print
let fibonacci =
Seq.unfold
(fun (current, next) -> Some(current, (next, current + next)))