Skip to content

Instantly share code, notes, and snippets.

View jonmoshier's full-sized avatar

Jon Moshier jonmoshier

View GitHub Profile
# Rock, Paper, Scissors command line python3 game
# run at commandline by typing `python rock-paper-scissors.py`
from random import randint # import random for computer choice
class NotAChoiceException(Exception): # creating a custom exception to handle by inputs
"""doc statement about error"""
pass
def takeInput(): # the function that handles input
float bend;
float pitch_value;
float divider = 38;
int vcaPin = 10;
int current;
void setup() {
usbMIDI.setHandleNoteOff(OnNoteOff);
usbMIDI.setHandleNoteOn(OnNoteOn);
usbMIDI.setHandleVelocityChange(OnVelocityChange);
@jonmoshier
jonmoshier / Teensy ByteBeat
Last active June 7, 2018 18:16
Simple setup for teensy bytebeats. Example at https://www.youtube.com/watch?v=I6M_S562yKI
void setup() {
analogWriteResolution(8);
}
void loop() {
int t=0;
for(;;t++) {
analogWrite(A14,(t*3 &t>>9 &t*5 &t>>9 &t*7&t>>9 ));
}
}
@jonmoshier
jonmoshier / genetic_algo.py
Created April 30, 2018 18:58
Another found on the hard drive gist, sticking it here for later, not sure that it works.
from random import random, randint
letters="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def individual(len):
return [letters[int(round(random()*100)%26)] for x in xrange(len)]
def population(size, len):
return [individual(len) for x in xrange(size)]
@jonmoshier
jonmoshier / self_replicating_file.py
Created April 30, 2018 18:54
Cleaning out my hard drive and I found this self replicating python file I wrote 5 years ago. Saving for posterity.
#!/usr/bin/env python
# use unittest to test if new file equals original, will
# fail test if it does not.
import unittest
# Get the file name of 'this' file. Will be 'file.py'
ORIG_FILE_NAME = __file__
# Get the contents of the ORIGINAL FILE file.
@jonmoshier
jonmoshier / .vimrc
Created December 28, 2016 06:48
my vimrc
set nocompatible " be iMproved, required
filetype off " required
let mapleader = ","
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'vim-airline/vim-airline'
Plugin 'flazz/vim-colorschemes'