Skip to content

Instantly share code, notes, and snippets.

@husobee
husobee / vigenere.go
Last active August 29, 2015 14:06
vigenere cipher in go
package main
import (
"flag"
"fmt"
)
// plaintext flag
var plaintext = flag.String("plaintext", "", "plaintext is the message you want to cipher")
@husobee
husobee / wemux.conf
Created April 23, 2015 13:43
wemux.conf
host_list=(husobee)
host_groups=(wheel engineering)
default_client_mode="pair"
allow_server_change="true"
allow_server_list="true"
socket_prefix="/tmp/wemux"
@husobee
husobee / coverage.html
Created November 17, 2015 14:03
go coverage external tests
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
body {
background: black;
color: rgb(80, 80, 80);
}
body, pre, #legend span {
@husobee
husobee / nyan.c
Last active January 19, 2016 15:44
Exploring Ncurses in C with nyan cat
#include <stdlib.h>
#include <ncurses.h>
#include <unistd.h>
/* our cat */
const char nyan_cat[4][12] = {
",------, \n",
"| /\\_/\\\n",
"|__( ^ .^) \n",
"\"\" \"\" \n"};
@husobee
husobee / main.go
Last active May 18, 2016 20:57
handle signals golang
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"
)
@husobee
husobee / main.go
Created October 1, 2016 02:04
reverse an int (friend's interview question)
package main
import (
"fmt"
)
func reverse(input int) int {
var result int
for ; input != 0; input = input / 10 {
result = input%10 + 10*result
@husobee
husobee / main.go
Created October 1, 2016 02:36
reverse a string
package main
import (
"fmt"
)
func reverseStr(s string) string {
input := []byte(s)
for i := 0; i < len(input)/2; i++ {
input[i], input[(len(input)-1)-i] = input[(len(input)-1)-i], input[i]
@husobee
husobee / digital_root.py
Last active October 3, 2016 14:28
submission for codewars.com digital root
def digital_root(n):
""" digital_root - recursively figure out the digital root of a number"""
s = 0 # s -> running sum
while n > 0:
# take each digit from the number by running mod 10 (ones position in base 10 number)
s += int(n%10)
# reduce the number by a factor of 10 to remove the ones position
n = int(n/10)
if s >= 10:
# if the num is greater than or equal to 10 recursively call self
@husobee
husobee / fib.py
Last active April 27, 2017 17:47
examples of fibonacci in python
from functools import reduce, lru_cache
fib_bad = lambda n:reduce(lambda x,n:[x[1],x[0]+x[1]], range(n),[0,1])[0]
def fib_naive(n):
""" fib_naive - naive solution to the fibonacci """
a,b = 1,1
for i in range(n-1):
a,b = b,a+b
@husobee
husobee / linkedlist.go
Created April 27, 2017 18:59
simple linked list implementation
package main
import "fmt"
func main() {
// create list
l := new(List)
// append to list
for i := 0; i < 100; i++ {
l.Append(i)