Skip to content

Instantly share code, notes, and snippets.

View chuckwagoncomputing's full-sized avatar

David Holdeman chuckwagoncomputing

View GitHub Profile
@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 / 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 / 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
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`
#!/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 / greed.rb
Created November 23, 2016 19:04
How much more likely are you to roll 6 dice uniquely than all the same?
greed = 0
flush = 0
10000000.times do
dice = []
6.times do
dice.push((1..6).to_a.sample)
end
if dice.include?(1) and dice.include?(2) and dice.include?(3) and dice.include?(4) and dice.include?(5) and dice.include?(6)
greed += 1
elsif dice[0] == dice[1] and dice[1] == dice[2] and dice[2] == dice[3] and dice[3] == dice[4] and dice[4] == dice[5]
@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 / 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