Skip to content

Instantly share code, notes, and snippets.

View evansneath's full-sized avatar

Evan Sneath evansneath

  • Auria Space
  • Durango, Colorado, USA
  • 16:07 (UTC -06:00)
View GitHub Profile
@evansneath
evansneath / pybrain-ode-setup.sh
Last active December 17, 2015 21:59
Streamlines the installation of PyBrain with support for ODE environments on OSX
#!/bin/bash
# This script is meant to streamline the installation of pybrain with
# support for ODE enviroments on the OS X operating system.
#
# To run:
# source pybrain-ode-setup.sh
#
# Requirements:
# * pip -- easy_install pip
@evansneath
evansneath / crc.py
Created January 27, 2013 22:29
Performs a cyclic redundancy check implemented in Python 3.3 with examples. More about CRC can be found here: http://en.wikipedia.org/wiki/Cyclic_redundancy_check
#!/usr/bin/env python3
def crc(msg, div, code='000'):
"""Cyclic Redundancy Check
Generates an error detecting code based on an inputted message
and divisor in the form of a polynomial representation.
Arguments:
msg: The input message of which to generate the output code.
@evansneath
evansneath / Python3 Virtualenv Setup
Last active March 7, 2022 16:31
Setting up and using Python3 Virtualenv
To install virtualenv via pip
$ pip3 install virtualenv
Note that virtualenv installs to the python3 directory. For me it's:
$ /usr/local/share/python3/virtualenv
Create a virtualenvs directory to store all virtual environments
$ mkdir somewhere/virtualenvs
Make a new virtual environment with no packages
@evansneath
evansneath / msg_to_img.py
Created May 28, 2012 15:51
msg_to_image - converts binary string to matrix form using its prime factors
# name: msg_to_img
#
# description: a simple program for converting a binary string of values
# and decyphering that string into a matrix form using its factors
#
# author: evan sneath
# date: 5/28/2012
# license: This software licensed under the Open Software License version 3.0:
# http://www.opensource.org/licenses/OSL-3.0
@evansneath
evansneath / palindromes.py
Created August 20, 2011 23:14
Palindromes
def palindromes(min, max):
"""Finds the largest palindrome of the product of two numbers between an desired range.
Arguments:
min: Minimum value limit.
max: Maximum value limit.
Returns:
Largest palindrome of the product of two numbers between the established range.
"""
a, b, product, highest = min, min, 0, 0
@evansneath
evansneath / nth_prime.py
Created August 20, 2011 23:06
Nth Prime
def nth_prime(n):
"""Finds the nth prime number.
Arguments:
n: The index of the saught after prime number.
Returns:
The value of the nth prime number.
"""
prime_table, counter = [], 2
prime_number, top, last = 0, 10000000, 0
@evansneath
evansneath / pythagorean_triples.py
Created August 20, 2011 22:56
Pythagorean Triples
def pythagorean_triples(n):
"""Finds a, b, and c such that a + b + c = n and a^2 + b^2 = c^2.
Arguments:
n: Value from which to determine pythagorean triples.
Returns:
Resulting combination of a, b, and c to satisfy the formula.
"""
a, b = 1, 1
while (a < n // 2):
@evansneath
evansneath / tiny_fibonacci.rb
Created August 20, 2011 22:44
Tiny Fibonacci
def tiny_fibonacci(n):
# A very small Fibonacci sequence generator which prints 'n' values of the sequence.
a, b = 0, 1
(1..n).each{puts b; a, b = b, b + a}
end