Skip to content

Instantly share code, notes, and snippets.

//CountLT.cpp
//Aryelle Young
//Sep 23 2014
//Defines the CountLT class
#include "CountLT.h"
//Default Constructor
//takes a value from client code to use as initial bound
CountLT::CountLT(double bound) : the_bound(bound), count(0)
@bemasher
bemasher / keybase.md
Created August 14, 2014 18:10
Keybase Proof

Keybase proof

I hereby claim:

  • I am bemasher on github.
  • I am bemasher (https://keybase.io/bemasher) on keybase.
  • I have a public key whose fingerprint is 0C80 689F 7D73 2BFB 4F94 8876 80C8 DC56 DD1E C7EE

To claim this, I am signing this object:

@bemasher
bemasher / bch.c
Created June 17, 2014 16:31
Basic receiver and bch error checking for TI ChipCon sub-Ghz receivers.
#include <cc1110.h>
#include "cc1110-ext.h"
#include <stdint.h>
#define GENPOLY 0x6F63
//! Receives a packet out of the radio from 0xFE00.
char __xdata __at 0xFE00 packet[0xFF];
@bemasher
bemasher / bencode.go
Last active August 29, 2015 14:01
Dirty Hack #37: Reflection is hard. Have a decoder you've written in Go and don't want to write all the logic for reflection to store data in native types? Does your decoder output map[string]interface{} and []interface{} flavored data? Problem solved: just marshal and unmarshal using the JSON package.
package main
import (
"bufio"
"log"
"strconv"
)
// Bencoding Specification
@bemasher
bemasher / process.py
Last active August 29, 2015 14:01
For all *.txt and *.awd files in the data folder, calculate the sum of each line across all files starting at the 20th value.
import glob
output = []
# For both extensions
for ext in ["txt", "awd"]:
# For all files matching the current extension
for filename in glob.iglob("data/*.{}".format(ext)):
print filename
@bemasher
bemasher / hash.java
Last active April 11, 2022 07:45
Implement a hash table using 3 different collection handling techniques: linear probing, quadratic probing and chaining.
/**
* Author: Douglas Hall
* Course: CSC345
* Assignment: Homework #7
* Instructor: Steven Kobourov
* Due Date: 2009-11-16 23:59
*
* Purpose: Implement a hash table using 3 different collection handling techniques.
* Linear probing, quadratic probing and chaining.
*/
@bemasher
bemasher / dft.go
Last active January 3, 2016 10:58
A Cooley-Turkey based DFT in Go. On my Core i7 3770k only about half an order of magnitude slower than FFTW!
package dft
import "math"
type DFT struct {
Log uint
Factors []complex128
}
func NewDFT(lg2 uint, is float64) (dft DFT) {
@bemasher
bemasher / rewrite.js
Created January 13, 2014 11:50
Relatively painless magnet uri generation for torrentz.eu. There's some extra scaffolding for extension related stuff but this is the main guts.
// Relatively painless magnet uri generation for torrentz.eu. Digging reveals
// that the torrent hash and id (torrentz.eu specific) are stored as hidden
// inputs for the comment system. All that's required is some Ajax and string
// parsing for the announce list and some html injection to add the link to
// the page.
// Get the torrent name, hash and id (for announce list lookup)
var name = $(".download>h2>span").first().text();
var hash = $(':input[name="hash"]').first().val()
var torrent = $(':input[name="torrent"]').first().val()
@bemasher
bemasher / rtltcp_example.go
Created December 13, 2013 04:37
Snippet to demonstrate rtltcp package usage
package main
import (
"log"
"github.com/bemasher/rtltcp"
)
const (
SampleRate = 2.4e6 // 2.4MHz
package correlate
import (
"dft"
"fmt"
"math/cmplx"
)
// Cross-correlation is a measure of similarity of two waveforms as a function
// of a time-lag applied to one of them. Aka the sliding dot product. This is