Skip to content

Instantly share code, notes, and snippets.

View SuborbitalPigeon's full-sized avatar

Bruce Cowan SuborbitalPigeon

View GitHub Profile
@SuborbitalPigeon
SuborbitalPigeon / rpn2.py
Last active August 29, 2015 14:08
Stack calculator
stack = []
def get_numbers():
stack.pop()
b = int(stack.pop())
a = int(stack.pop())
return (a, b)
while True:
val = input()
@SuborbitalPigeon
SuborbitalPigeon / numpi.py
Last active August 29, 2015 14:09
Estimates pi using a Monte-Carlo method
import numpy as np
import numpy.random as random
iters = 10e6
# 1. The equation of the area of a unit circle is `ac = pi * 1^2 = pi'
# 2. The area of a 2x2 square is `as = 2^2 = 4'
# 3. The probability of a random point being in the circle is pi / 4
# 4. Given a random point, the point is in the circle if the point's
# radius from the centre is less or equal to 1
@SuborbitalPigeon
SuborbitalPigeon / unity-coders.svg
Created April 17, 2012 01:19
Unity Coders icon
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
[
{
"id" : "stage",
"type" : "ClutterStage",
"width" : 800,
"height" : 600,
"color" : "black",
"children" : [ "rectangle" ],
"signals" :
[
@SuborbitalPigeon
SuborbitalPigeon / numbase.py
Last active October 12, 2015 07:07
Number to base
#!/usr/bin/env python
class Converter:
"""A bunch of converters"""
def __init__(self, number):
self.number = number
def to_base(self, digits):
# TODO: make the digits automatic and input the base instead
div = self.number
from datetime import datetime
import json
import os
import subprocess
from sys import argv
dir = argv[1]
files = []
for dirpath, dirname, filenames in os.walk(dir):

Keybase proof

I hereby claim:

  • I am SuborbitalPigeon on github.
  • I am suborbitalpigeon (https://keybase.io/suborbitalpigeon) on keybase.
  • I have a public key whose fingerprint is 973E D580 A846 6D55 AA74 285B A0D0 4867 BBC3 4355

To claim this, I am signing this object:

from math import pi
from matplotlib import pyplot as plt
import pandas as pd
import seaborn as sns
A = pi/4 * 0.8**2 # Diameter: 800 mm
speeds = list(range(60, 270, 10))
altitudes = list(range(0, 45000, 1000))
@SuborbitalPigeon
SuborbitalPigeon / postcode.js
Last active November 12, 2016 16:44
Postcode validation using GJS or PyGObject
#!/usr/bin/gjs
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
var re = /[A-Z]{1,2}[\d][A-Z0-9]? ?[\d][A-Z]{2}/
const Postcode = new Lang.Class(
{
Name: 'Postcode',
@SuborbitalPigeon
SuborbitalPigeon / model.lua
Last active December 13, 2016 21:17
FEMM model for group A1
-- Useful functions
function average(a, b)
return (a + b) / 2
end
function get_x_y(radius, angle)
x = radius * cos(angle * (pi / 180))
y = radius * sin(angle * (pi / 180))
return x, y
end