This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Newbie Programmer | |
def factorial(x) | |
if x == 0 | |
return 1 | |
else | |
return x * factorial(x - 1) | |
end | |
end | |
puts factorial(6) | |
puts factorial(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mongoid' | |
require 'rspec' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('testing') | |
config.autocreate_indexes = true | |
end | |
class User | |
include Mongoid::Document |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Schema: map[string]*schema.Schema{ | |
"addon": { | |
Type: schema.TypeString, | |
Required: true, | |
ForceNew: true, | |
}, | |
"app": { | |
Type: schema.TypeString, | |
Required: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type Options struct { | |
Input string | |
Output string | |
Switch bool | |
} | |
func parseFlags(options *Options) { | |
flag.StringVar(&options.Input, "", "input file") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The exercism "Leap" program in Kitten | |
// http://exercism.io/exercises/ruby/leap/readme | |
// http://kittenlang.org/ | |
1996 isLeapYear "1996 is a leap year" assert | |
1997 isLeapYear "1997 is not a leap year" refute | |
1998 isLeapYear "1998 is not a leap year" refute | |
1900 isLeapYear "1900 is not a leap year" refute | |
1800 isLeapYear "1800 is not a leap year" refute | |
2400 isLeapYear "2400 is a leap year" assert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
while true; do | |
battery=`cat /sys/class/power_supply/BAT0/capacity` | |
time=`date +"%H:%M"` | |
xsetroot -name "${battery}% | ${time}" | |
sleep 30 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# DEPENDENCIES: | |
# bynanz | |
# xdotool | |
echo | dmenu -p "Enter to set X/Y start" | |
eval $(xdotool getmouselocation --shell) | |
STARTX=$X |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/inputrc b/inputrc | |
index c9d1b79..36d91cd 100644 | |
--- a/inputrc | |
+++ b/inputrc | |
@@ -2,3 +2,7 @@ | |
"\e[B": history-search-forward | |
"\C-p": history-search-backward | |
"\C-n": history-search-forward | |
+"\e[A": "" | |
+"\e[B": "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// like io.Pipe(), but returns two connected ReadWriteClosers. | |
func newConn() (io.ReadWriteCloser, io.ReadWriteCloser) { | |
type rwc struct { | |
io.Reader | |
io.WriteCloser | |
} | |
rs, wc := io.Pipe() | |
rc, ws := io.Pipe() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
set -e | |
echo "starting doozer:8046" | |
doozerd -timeout 10 -hist 100 -l "127.0.0.1:8046" -w ":8080" -c test &>tmp/8046.log & | |
sleep 1 | |
echo "starting doozer:8047" | |
doozerd -timeout 10 -hist 100 -l "127.0.0.1:8047" -w false -b "doozer:?ca=127.0.0.1:8046" -c test &>tmp/8047.log & | |
sleep 1 |
NewerOlder