Skip to content

Instantly share code, notes, and snippets.

View lw16.go
package main
import (
"crypto/hmac"
"crypto/rand"
"crypto/sha1"
"fmt"
"math/big"
)
@husobee
husobee / clww16.go
Created Oct 24, 2018
CLWW16 toy project
View clww16.go
package main
import (
"crypto/hmac"
"crypto/sha256"
"fmt"
)
func main() {
fmt.Println("Example CLWW 2016 Implementation")
View rwmutexvchan_test.go
package main
import (
"sync"
"testing"
)
type stuff struct {
ret chan string
input string
@husobee
husobee / producer-consumer-problem1.go
Created Feb 6, 2018
producer-consumer problem with message passing
View producer-consumer-problem1.go
package main
import (
"errors"
"fmt"
"math/rand"
"time"
)
func init() {
@husobee
husobee / producer-consumer-problem.go
Created Feb 6, 2018
example producer-consumer problem
View producer-consumer-problem.go
package main
import (
"errors"
"fmt"
"math/rand"
"time"
)
func init() {
View arithmetic.c
#include <stdio.h>
int main() {
// Given an unsigned char, if we add 1 to the max value an unsigned char can have,
// we strangely get the correct value, which should have overflown the char...
unsigned char a = 255;
printf("%lu + 1 == %d \n", a, a + 1);
// Output: 255 + 1 == 256
// When we take this value and assign it to an unsigned char, and look at the
@husobee
husobee / overunder.c
Last active Sep 10, 2017
overflow-underflow-casting
View overunder.c
#include <stdio.h>
int main() {
// Down Casting an unsigned long to an unsigned char
unsigned long a = 257;
printf("%lu == %d \n", a, (unsigned char)a);
// Output: 257 == 1
// This is obviously not true, but there are not enough bits in a
// char (8 bits) to hold 257, so it will carry over the extra into the value
@husobee
husobee / linkedlist.go
Created Apr 27, 2017
simple linked list implementation
View linkedlist.go
package main
import "fmt"
func main() {
// create list
l := new(List)
// append to list
for i := 0; i < 100; i++ {
l.Append(i)
@husobee
husobee / fib.py
Last active Apr 27, 2017
examples of fibonacci in python
View fib.py
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 / keyadd.sh
Created Jan 26, 2017
using passwordstore with ssh-add
View keyadd.sh
#!/bin/bash
PASS_NAME=$1
KEY_FILENAME=$2
# start ssh-agent
eval `ssh-agent -s`
# decrypt the rsa private key, using the password from the `pass` command by means of a named pipe
openssl rsa -inform PEM -passin file:<(pass show ${PASS_NAME}) -in ${KEY_FILENAME} -text | ssh-add -