Skip to content

Instantly share code, notes, and snippets.

View chuckwagoncomputing's full-sized avatar

David Holdeman chuckwagoncomputing

View GitHub Profile
@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 / 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 / instructions.txt
Created January 28, 2014 21:44
Magic Jack Serial Port Output
38400 8N1
@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;
}
#!/bin/bash
clear
one()
{
FILETEXT=`cat $FILE | tail -c +5`
echo $FILETEXT
rm -f $FILE
}
two()
{
badopts()
{
echo -e "Usage: ifchanged [command to check] [number of seconds to wait between checks] [command to execute if not changed] [command to execute if changed]"
exit
}
if [ $# -ne 4 ]; then
badopts
else
while true; do
RES=`$1`
@chuckwagoncomputing
chuckwagoncomputing / random.rb
Created September 7, 2013 03:03
Random Selection Chance Counter
#!/usr/bin/env ruby
$randwins = 0
$swins = 0
$equal = 0
$tried = []
ARGV[0].to_i.times do
$times = 0
$num = rand(1..9)
$sel = rand(1..$num)
loop do
@chuckwagoncomputing
chuckwagoncomputing / counter.rb
Created September 7, 2013 03:02
Random Number Occurence Counter
#!/usr/bin/env ruby
$one = 0
$two = 0
$three = 0
$four = 0
$five = 0
$six = 0
$seven = 0
$eight = 0
$nine = 0
@chuckwagoncomputing
chuckwagoncomputing / schlock.sh
Created September 7, 2013 02:58
Schlock Mercenary Getter
#!/bin/bash
DATE=$(date -d "$1" +%Y-%m-%d)
URL="http://schlockmercenary.com/$DATE"
PICS=$(xidel $URL -e "//@src/resolve-uri(.)" 2> /dev/null | egrep '[0-9][a-z].(png|jpg)')
if [ -z "$PICS" ]; then
PICS=$(xidel $URL -e "//@src/resolve-uri(.)" 2> /dev/null | egrep '[0-9].[png|jpg]' | head -n 1)
fi
echo "$PICS"
exit
@chuckwagoncomputing
chuckwagoncomputing / infun.sh
Created August 10, 2013 16:53
Text insertion in functions
#!/bin/bash
LINE=$((`grep -n "$2()" $1 | head -c 1`+1))
./insert.sh $1 $LINE "$3"
exit