Skip to content

Instantly share code, notes, and snippets.

// Benchmark for https://github.com/wjh/beaver/issues/1
package main
import (
"bytes"
"fmt"
"os"
"strconv"
"testing"
"text/template"

Keybase proof

I hereby claim:

  • I am conradludgate on github.
  • I am oon (https://keybase.io/oon) on keybase.
  • I have a public key ASC2TLtfnEF2ql78BKE2E1-fNoxnqiZ5tlRItwK-wBdqmQo

To claim this, I am signing this object:

@conradludgate
conradludgate / main.c
Last active August 2, 2018 09:16
Print bits of built in data types in C
#include <stdio.h>
//#include <stdint.h>
#include <math.h>
void PrintBits64(unsigned long u)
{
char str[66];
str[64] = '\n';
str[65] = 0;
for (int i = 63; i >= 0; i--)
@conradludgate
conradludgate / dft.go
Created September 9, 2018 22:35
Implementation of the Cooley-Tukey Radix2 DIT fast Fourier Transform
package dft
import (
"math"
"math/cmplx"
)
func Radix2DIT(data []complex128) []complex128 {
l := len(data)
l-- // power of two >= l
@conradludgate
conradludgate / euclidian.py
Created September 26, 2018 14:26
Euclidian Algorithm
import sys
# Example usage
# $ python euclidian.py 1745 1485
# gcd(1745, 1485) = (1 + 297n) * 1745 - (0 + 349n) * 1485 = 5
# The euclidian algorithm took 6 steps
a = int(sys.argv[1]) # 1745
b = int(sys.argv[2]) # 1485
# Imports for word2vec
from gensim.test.utils import common_texts, get_tmpfile
from gensim.models import Word2Vec, KeyedVectors
# imports for tensorflow
import tensorflow as tf
# Numpy
import numpy as np
fluffy = Labrador("fluffy")
scruffy = GoldenRetriever("scruffy")
cat = Cat(fluffy)
cat.say() # Meow, I am a cat and my enemy says: 'Bark, I am a Labrador'
cat.move() # I am running away from fluffy
scruffy.say() # Bark, I am a Golden Retriever
scruffy.move() # I am chasing cats
@conradludgate
conradludgate / combi.rs
Last active May 21, 2021 09:12
Combinations Iterator
// Outputs:
// [1, 2, 3], ([4, 5, 6])
// [1, 2, 4], ([5, 6, 3])
// [1, 2, 5], ([6, 3, 4])
// [1, 2, 6], ([3, 4, 5])
// [1, 3, 4], ([5, 6, 2])
// [1, 3, 5], ([6, 4, 2])
// [1, 3, 6], ([4, 5, 2])
// [1, 4, 5], ([6, 3, 2])
// [1, 4, 6], ([5, 3, 2])
@conradludgate
conradludgate / combi2.rs
Created May 22, 2021 09:57
Works for r = 3, almost works for other r
use std::{fmt::Debug, ops::Range};
fn main() {
let mut v = vec![1, 2, 3, 4, 5, 6];
let r = 3;
for x in CombiIterator::new(&mut v, r) {
println!("{:?}", x);
}
}
@conradludgate
conradludgate / combi3.rs
Last active May 23, 2021 09:24
Seems to work for any r and any n
fn main() {
let v = vec![1, 2, 3, 4, 5, 6];
let r = 3;
for x in CombiIterator::new(v, r) {
println!("{:?}", x);
}
}
#[derive(Debug, Clone)]