Skip to content

Instantly share code, notes, and snippets.

View chuckwagoncomputing's full-sized avatar

David Holdeman chuckwagoncomputing

View GitHub Profile
#!/bin/bash
clear
one()
{
FILETEXT=`cat $FILE | tail -c +5`
echo $FILETEXT
rm -f $FILE
}
two()
{
@chuckwagoncomputing
chuckwagoncomputing / main.c
Created January 28, 2014 04:05
First attempt at AVR C programming. (Attiny85)
#include <avr/sleep.h>
#include <avr/interrupt.h>
volatile int pinOutState;
ISR(PCINT0_vect){
if (pinOutState == 0){
PORTB = (1 << PB1);
pinOutState = 1;
}
@chuckwagoncomputing
chuckwagoncomputing / instructions.txt
Created January 28, 2014 21:44
Magic Jack Serial Port Output
38400 8N1
@chuckwagoncomputing
chuckwagoncomputing / spl2c.sh
Created February 18, 2014 00:12
Shakespeare 2 C Wrapper script
#!/bin/bash
LOCATION="/usr/local/bin"
if [ $# -eq 2 ]; then
if [ -f $1 ]; then
$LOCATION/spl/bin/spl2c < $1 > $2.c
gcc $2.c -o $2 -I $LOCATION/spl/include -L $LOCATION/spl/lib -lspl -lm
rm $2.c
rm $1
else
echo "USAGE: spl2c [file to compile] [name of resulting program]"
@chuckwagoncomputing
chuckwagoncomputing / xkcd_now_get.sh
Created February 27, 2014 01:40
get xkcd now image files
#!/bin/bash
for HOUR in {00..23}; do
for MINUTE in 00 15 30 45; do
wget "http://imgs.xkcd.com/comics/now/"$HOUR"h"$MINUTE"m.png"
done
done
exit
@chuckwagoncomputing
chuckwagoncomputing / xkcd_now_selector.sh
Created February 27, 2014 01:41
Selects the proper xkcd now image file for the time.
#!/bin/bash
# Change this to the directory containing the image files.
XKCDPATH="/usr/local/bin/xkcdnow"
HOUR=$(TZ=Asia/Kamchatka date +%H)
MINUTE=$(date +%M)
if [ $MINUTE -gt 00 -a $MINUTE -le 15 ]; then
MINUTE=15
elif [ $MINUTE -gt 15 -a $MINUTE -le 30 ]; then
MINUTE=30
#!/bin/bash
BIRTHDAY=$1
DAYSTODAY=$(date +%j | sed "s/^0*//g")
DAYSATBIRTH=$(date -d "$BIRTHDAY" +%j | sed "s/^0*//g")
YEARSOLD=$(($(date +%Y)-$(date -d "$BIRTHDAY" +%Y)))
if [ $DAYSATBIRTH -gt $DAYSTODAY ]; then
YEARSOLD=$(($YEARSOLD-1));
DAYSSINCE=$(($((365-$DAYSATBIRTH))+$DAYSTODAY))
else
DAYSSINCE=$(($DAYSTODAY-$DAYSATBIRTH))
@chuckwagoncomputing
chuckwagoncomputing / foac.rb
Last active December 14, 2016 17:07
Four on a couch game sim
#!/usr/bin/env ruby
class Player
attr_accessor :name, :team, :position, :pseudonym
def initialize(name, team, pseudonym, strategy)
@name = name
@team = team
@position = name
@pseudonym = pseudonym
@selection = $players.reject { |a| a == @pseudonym }.sample
@chuckwagoncomputing
chuckwagoncomputing / text.js
Created February 25, 2015 23:31
coordinate line font in javascript
var letters = {
' ' : [[50, 0, 50, 0]],
'!' : [[0, 45, 0, 50, 8],
[0, 10, 0, 35, 8]],
'"' : [[0, 10, 0, 20, 8],
[10, 10, 10, 20, 8]],
'#' : [[0, 35, 20, 35, 8],
[0, 25, 20, 25, 8],
[15, 20, 15, 40, 8],
[5, 20, 5, 40, 8]],
@chuckwagoncomputing
chuckwagoncomputing / threePseudonyms.rb
Last active December 14, 2016 17:19
FOAC Strategy: Keeps track of who has three pseudonyms
# Keep track of who has three pseudonyms
class StrategythreePseudonyms
def initialize(parent)
@strategy = parent
@player = @strategy.player
@memory = @strategy.memory
end
def remember(calledName, calledTeam, calledPosition, calledPseudonym, callerName)
# if someone called a number being remembered