Skip to content

Instantly share code, notes, and snippets.

View schie's full-sized avatar
:octocat:
doing stuff

Dustin Schie schie

:octocat:
doing stuff
View GitHub Profile
@schie
schie / Primitive_root.py
Created October 27, 2013 06:02
This code finds the primitive roots of a relatively small number. It is not optimized for very large numbers.
from fractions import gcd
import copy
def get_relative_primes(number):
# will hold all numbers that are relatively prime to number
rel_primes = set()
# Dictionary: key is primitive root
# value is the set of powers mod number
@schie
schie / PRNG.java
Created October 27, 2013 17:13
This is java program implements the psuedo-random number generator: X(n+1) = (7^5 * X(n)) mod(2^31 - 1) to approximate the value of pi
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class PRNG {
private long seed = 0;
private final long mod = Integer.MAX_VALUE,
seven_pow = (long)Math.pow(7, 5);
@schie
schie / Extended_Euclidean_algm.py
Created October 27, 2013 18:14
This python script finds the multiplicative inverse of X mod Y
from sys import stdout
rs = []
qs = [' ',' ']
xs = [1,0]
ys = [0,1]
def gcd(a, b):
if(len(rs) is 0):
rs.append(a)
@schie
schie / ClassExample.py
Created September 18, 2015 02:53
Example of how classes work in python
# import the math module (this will be used in Circle class)
import math
# created a generic shape class
class Shape:
# the function to initialize the shape
def __init__(self, width, height):
# the properties of the shape
self.width = width
self.height = height
@schie
schie / TurtleExample.py
Created September 18, 2015 03:27
Example of using turtle, python's built-in graphics module
# Example of using turtle, python's built-in graphics module
# import turtle with a new name
# who wants to write out t-u-r-t-l-e that many times?
import turtle as t
t.speed(5) # speed
t.pensize(5) # thickness
# convenience method for drawing circles
@schie
schie / test
Created September 25, 2015 19:04
test
test
@schie
schie / LCD_Blinker.ino
Created December 2, 2015 04:05
Arduino Blinker w/ LCD KeyPad Shield
#include <LiquidCrystal.h>
// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// define some values used by the panel and buttons
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
@schie
schie / hc-sr04.ino
Created December 4, 2015 02:09 — forked from flakas/hc-sr04.ino
Modified Arduino Ping))) example to work with 4-Pin HC-SR04 Ultrasonic Sensor Distance Measuring Module
/* HC-SR04 Sensor
https://www.dealextreme.com/p/hc-sr04-ultrasonic-sensor-distance-measuring-module-133696
This sketch reads a HC-SR04 ultrasonic rangefinder and returns the
distance to the closest object in range. To do this, it sends a pulse
to the sensor to initiate a reading, then listens for a pulse
to return. The length of the returning pulse is proportional to
the distance of the object from the sensor.
The circuit:
@schie
schie / Dockerfile
Created January 27, 2016 05:04
Dockerfile example for hubot with slack adapter
FROM node:latest
MAINTAINER Dustin Schie, [email protected]
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
@schie
schie / query-string-form-fill.js
Created September 28, 2017 18:33
Setting form fields with query string
function parseSearchString () {
var qs = window.location.search
qs = qs.replace(/^\?/,'')
var parts = qs.split('&')
var params = {}
parts.forEach(function (part) {
var pair = part.split('=')
params[pair[0]] = decodeURIComponent(pair[1])
})
return params