Skip to content

Instantly share code, notes, and snippets.

View cwoodall's full-sized avatar
✈️

Christopher Woodall cwoodall

✈️
View GitHub Profile
@cwoodall
cwoodall / run_proc.rb
Created July 22, 2011 02:30
A nice little (very rough and being matured) wrapper for reading output asynchronously in ruby using PTY (built-in PseudoTerminal Library). I plan on expanding on this.
# Author :: Christopher Woodall <chris.j.woodall@gmail.com>
# Copyright :: 2011 Christopher Woodall
# License :: MIT License
require 'pty'
# run_proc(proc) runs a psuedoterminal version of a command returning output to a block
# asynchronously as it is produced.
def run_proc(proc)
# Spawn the PTY process
@cwoodall
cwoodall / comparator.v
Created October 30, 2011 20:57
Comparator for EC311
// Behavioral 3-bit Comparator
module comparator_3bit_behavioral(A, B, GT, LT, EQ);
input signed [2:0] A;
input signed [2:0] B;
output GT, LT, EQ;
wire signed [2:0] A, B;
reg GT, LT, EQ;
always @ (A, B) begin
@cwoodall
cwoodall / generate_verilog_lut.py
Created November 27, 2011 00:26
This is how we Generate Verilog Luts using python!
import math
import random
def generateSineTable(max_dac_val=63.0, steps_per_cycle=256):
sine_lut = [];
for r in range(0, steps_per_cycle):
sine_lut.append((max_dac_val/2) * (math.sin(r*2*math.pi/steps_per_cycle) + 1))
return sine_lut
def generateTriangleWave(max_dac_val=63.0, steps_per_cycle=256):
@cwoodall
cwoodall / gist:1478499
Created December 14, 2011 20:59
wmiirc
MODKEY=Mod4
# Colors tuples: "<text> <background> <border>"
WMII_NORMCOLORS='#ffffff #000000 #ffffff'
WMII_FOCUSCOLORS='#ffffff #555555 #ffffff'
WMII_BACKGROUND='#cccccc'
WMII_FONT='fixed'
@cwoodall
cwoodall / toggle_led.sh
Created June 9, 2012 22:13
TOGGLE AN LED ON RASPBERRY PI
#!/bin/sh
## TOGGLE LED on a RASPBERRY PI
# Christopher Woodall and Thomas Nadovich
# June 9, 2012
#
# Some reference material: http://elinux.org/RPi_Low-level_peripherals
# Done using the special made image of Debian Squeeze for the Raspberry Pi
# MUST BE ROOT:
# precede with `su -` if you trust me
@cwoodall
cwoodall / toggle_led_w_switch.sh
Created June 9, 2012 22:48
Toggle LED with a switch
#!/bin/sh
echo "25" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio25/direction
echo "24" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio24/direction
OUTPUT="0"
INPUT="$(cat /sys/class/gpio/gpio24/value)"
@cwoodall
cwoodall / cw_fixed_point.py
Created June 28, 2012 13:50
Unsigned Fixed Point... With a little bit of work can work for signed, will convert to signed for large numbers if you try to convert to float or string... Not much interest in fixing, because it works for my little 16 bit numbers (and masks down to your
class UFixedPoint(object):
def __init__(self, num, m, n):
self.mask = 2**(m + n) - 1
self.k = (1 << (n - 1))
self.m = m
self.n = n
temp = int(num * 2**self.n)
self.value = temp & self.mask
@cwoodall
cwoodall / gist:7952754
Last active December 31, 2015 07:18
Extract data from data_file which is a "binary string". Returns it in the format (Data[31 downto 8], Data[7 downto 0]) which is technically data, ADC channel... Created this after talking to Dean DeCarli.
import struct
from itertools import izip_longest
def grouper(n, iterable, fillvalue=None):
"grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx... From stackoverflow"
args = [iter(iterable)] * n
return izip_longest(fillvalue=fillvalue, *args)
# Extract data from data_file which is a "binary string". Returns it in the format (Data[31 downto 8], Data[7 downto 0])
# which is technically data, ADC channel
@cwoodall
cwoodall / gist:5c1db855d896d4476111f273f2f631ea
Created June 24, 2016 21:59
Intersting C++ embedded process runner
#include <iostream>
#include <stdint.h>
using namespace std;
template <uint32_t f>
bool ProcessTask(void);
template <uint32_t f>
uint32_t RunProcess(uint32_t start) {
@cwoodall
cwoodall / bash_prompt.sh
Created December 20, 2016 03:17
My New Bash Prompt with Git Status
green() {
printf "\e[32m${1}\e[00m"
}
light_red() {
printf "\e[91m${1}\e[00m"
}
radioactive="\u2622"
check_mark="\u2714"