Skip to content

Instantly share code, notes, and snippets.

View chuckwagoncomputing's full-sized avatar

David Holdeman chuckwagoncomputing

View GitHub Profile
@chuckwagoncomputing
chuckwagoncomputing / nginx.conf
Last active February 13, 2017 21:21 — forked from mimosz/nginx.conf
nginx + unicorn + padrino on ubuntu
# sudo ln -s ~/nginx.conf unicorn.conf
upstream app_server {
server unix:/tmp/unicorn_padrino.sock fail_timeout=0;
}
server {
listen 80;
charset utf-8;
server_name db.innshine.com;
@chuckwagoncomputing
chuckwagoncomputing / age.lua
Created December 27, 2016 04:09
A function to get fractional age for my conky
function conky_get_age(year, month, day)
if conky_window == nil then
return
end
daystoday = os.date("%j")
daysatbirth = os.date("%j", os.time{year=year, month=month, day=day})
yearsold = os.date("%Y") - os.date("%Y", os.time{year=year, month=month, day=day})
if daysatbirth > daystoday then
yearsold = math.floor(yearsold - 1)
dayssince = (365 - daysatbirth) + daystoday
@chuckwagoncomputing
chuckwagoncomputing / qualitativeThreeCouchCaller.rb
Last active December 14, 2016 17:24
FOAC Strategy: qualitativeThree, now with a preference for the person called by the first person on the couch.
# Keep track of who has three pseudonyms, forgetting one in order to remember a better one
class StrategyqualitativeThreeCouchCaller
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
@chuckwagoncomputing
chuckwagoncomputing / qualitativeThree.rb
Last active December 14, 2016 17:21
FOAC Strategy: Keeps track of who has three pseudonyms, forgetting one in order to remember a better one
# Keep track of who has three pseudonyms, forgetting one in order to remember a better one
class StrategyqualitativeThree
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
@chuckwagoncomputing
chuckwagoncomputing / threePseudonymsMaybe.rb
Last active December 14, 2016 17:20
FOAC Strategy: Keeps track of who has three pseudonyms, with a 50% chance of remembering
# Keep track of who has three pseudonyms
class StrategythreePseudonymsMaybe
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
@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
@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 / 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 / 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;
}