Skip to content

Instantly share code, notes, and snippets.

View bernerdschaefer's full-sized avatar

Bernerd Schaefer bernerdschaefer

View GitHub Profile
# Newbie Programmer
def factorial(x)
if x == 0
return 1
else
return x * factorial(x - 1)
end
end
puts factorial(6)
puts factorial(0)
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
Schema: map[string]*schema.Schema{
"addon": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"app": {
Type: schema.TypeString,
Required: true,
package main
type Options struct {
Input string
Output string
Switch bool
}
func parseFlags(options *Options) {
flag.StringVar(&options.Input, "", "input file")
@bernerdschaefer
bernerdschaefer / leap.ktn
Last active June 18, 2016 20:27
Leap in Kitten
// 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
#!/bin/sh
while true; do
battery=`cat /sys/class/power_supply/BAT0/capacity`
time=`date +"%H:%M"`
xsetroot -name "${battery}% | ${time}"
sleep 30
done
#!/usr/bin/env bash
#
# DEPENDENCIES:
# bynanz
# xdotool
echo | dmenu -p "Enter to set X/Y start"
eval $(xdotool getmouselocation --shell)
STARTX=$X
@bernerdschaefer
bernerdschaefer / inputrc.patch
Created January 8, 2016 19:41
Turn off arrow keys anywhere inputrc is respected
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": ""
// 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()
#!/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