Skip to content

Instantly share code, notes, and snippets.

View Shoeboxam's full-sized avatar

Michael Shoemate Shoeboxam

View GitHub Profile
@Shoeboxam
Shoeboxam / BMI.asm
Created October 31, 2016 16:08
BMI Calculator written in MIPS assembly
#Michael Shoemate
#This program calculates BMI
.data
npr:.asciiz "Name: "
wpr:.asciiz "Weight (whole pounds): "
hpr:.asciiz "Height (whole inches): "
bpr:.asciiz " Calculated BMI: "
name: .space 20
weight: .word
@Shoeboxam
Shoeboxam / rotate-composite.py
Created November 13, 2016 23:56
Rotate-composite image
#!/usr/bin/env python
from math import pi
from gimpfu import *
def composite_rotate(image, drawable, quantity):
pdb.gimp_image_undo_group_start(image)
visibility = {}
for layer in image.layers:
@Shoeboxam
Shoeboxam / rhodonea.py
Created November 25, 2016 16:10
Gimp rhodonea graphing
from gimpfu import *
from math import pi, sin, cos
# Quantity of lines to draw per period
# Lower - performance
# Higher - quality
granularity = 2000
# Base formula: r = sin(n * theta)
@Shoeboxam
Shoeboxam / taylor.nb
Last active January 15, 2017 07:06
Mathematica: calculates truncated taylor series with n terms
n := 3
origin := 0
offset := .0001
f[x_] := (x + 1)^0.5
precision := 40
Sum[(((SeriesCoefficient[f[x], {x, x, i}]) /. x -> SetPrecision[origin, precision])*(SetPrecision[offset, precision])^i), {i, 0, n - 1}]
Sqrt[SetPrecision[1.0001, precision]]
@Shoeboxam
Shoeboxam / nn_example.m
Last active February 7, 2017 20:32
Functional erf minimization with scalar theta
environment = [4, 5, 7, 8];
expectation = 23;
% Initial weight
theta = 0.5;
theta_old = theta - 0.25;
while abs(theta - theta_old) > 1e-12
% Derivative of squared error: ln = (expectation - reinforcement)^2
dln_dr = -2 * (expectation - theta * environment);
@Shoeboxam
Shoeboxam / speedcrunch_numlock.ahk
Created February 26, 2017 05:28
Autohotkey numlock SpeedCrunch calculator keybinding
; Binds the Numlock key to a calculator.
; Double tap to launch or close.
; Single tap to focus or minimize.
; Place in start folder to automatically run.
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
SetNumLockState AlwaysOn
@Shoeboxam
Shoeboxam / dihedral_permutations.py
Last active March 4, 2017 04:10
Generates the Cayley table for any element in the dihedral group
from math import cos, sin, pi
import numpy as np
deg = 4
rotations = []
mirrors = []
for i in range(deg):
rotat = np.array([[cos(2 * pi * i / deg), -sin(2 * pi * i / deg)],
@Shoeboxam
Shoeboxam / symmetric_octahedral.py
Created March 11, 2017 05:47
Matplotlib foolishness, attempt at rendering the dual cube of an octahedra
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
from matplotlib.pyplot import figure, show
octahedron = np.array([[1,0,0], [-1,0,0],
[0,1,0], [0,-1,0],
[0,0,1], [0,0,-1]])
@Shoeboxam
Shoeboxam / diagonal_flip.py
Created May 7, 2017 23:13
Flip an image across diagonal. Uses perspective transform.
#!/usr/bin/env python
from gimpfu import *
def diagonal_flip(image, drawable, downward_diag, upward_diag):
pdb.gimp_image_undo_group_start(image)
if downward_diag:
pdb.gimp_item_transform_perspective(drawable, 0, 0, 0, drawable.height,
drawable.width, 0, drawable.width, drawable.height)
@Shoeboxam
Shoeboxam / reflection_tile.py
Created May 9, 2017 07:17
Gimp: Tile an image to 16x the size via reflections
#!/usr/bin/env python
from gimpfu import *
def reflection_tile(image, drawable):
canvas = gimp.Image(drawable.width * 4, drawable.height * 4, RGB)
for layer in reversed(image.layers):
layer_tile = canvas.new_layer(layer.name)