Skip to content

Instantly share code, notes, and snippets.

@bemasher
bemasher / 1.2.2.py
Created August 29, 2011 01:44
EE4220 - HW01 - 1.2.2
S = set([])
Zf = set([])
Xa = set([])
C = set([])
D = set([])
bin = lambda y: map(lambda x: "{:0>3b}".format(x), y)
for x in range(0,2**3):
S.add(x)
@bemasher
bemasher / bitrot.go
Created August 29, 2011 20:18
Left and right bitwise rotation functions for 32-bit unsigned integers.
package main
import "fmt"
func ROTL(x uint32, s uint) uint32 {
return (x << s) | (x >> (32 - s))
}
func ROTR(x uint32, s uint) uint32 {
return (x >> s) | (x << (32 - s))
@bemasher
bemasher / ammonia_centroid.py
Created August 31, 2011 03:25
Centroid of an ammonia molecule (not accurate to standard specification of ammonia molecules)
d = 9.4e-11
L = 10.4e-11
N = [0,0,4.44972e-11,13.9]
H1 = [d,0,0,1]
H2 = [-4.7e-11,8.14064e-11,0,1]
H3 = [-4.7e-11,-8.14064e-11,0,1]
Cx = 0
Cy = 0
@bemasher
bemasher / readBlocks.go
Created September 5, 2011 01:56
Reads all of the blocks from blk0001.dat and tallies the number of nonces less than half of the maximum possible nonce.
package main
import (
"os"
"fmt"
"log"
"bytes"
"crypto/sha256"
"encoding/binary"
)
@bemasher
bemasher / Nibbler.go
Created September 15, 2011 03:19
Reads a single nibble at a time from a byte buffer.
package main
import (
"io"
"bytes"
"encoding/binary"
)
type Nibbler struct {
r *bytes.Buffer
@bemasher
bemasher / Castle.xml
Created September 18, 2011 03:46
Example of parsing xml in golang.
<?xml version="1.0" encoding="UTF-8" ?>
<Data>
<Series>
<id>83462</id>
<Actors>|Nathan Fillion|Stana Katic|Molly C. Quinn|Jon Huertas|Seamus Dever|Tamala Jones|Susan Sullivan|Ruben Santiago-Hudson|Monet Mazur|</Actors>
<Airs_DayOfWeek>Monday</Airs_DayOfWeek>
<Airs_Time>10:00 PM</Airs_Time>
<ContentRating>TV-PG</ContentRating>
<FirstAired>2009-03-09</FirstAired>
<Genre>|Drama|</Genre>
@bemasher
bemasher / EqnSheet.tex
Created September 22, 2011 01:08
Partial LaTeX for an equation sheet for Electromagnetics.
\documentclass[letter,10pt]{article}
\usepackage[cm,empty]{fullpage}
\usepackage{amssymb, amsmath, amstext}
\usepackage{datetime}
\usepackage{listings}
\usepackage[pdftex]{graphicx}
\usepackage{subfigure}
\usepackage{siunitx}
\setlength{\parindent}{0.0cm}
package main
import (
"io"
"os"
"fmt"
"bytes"
"image"
"image/png"
"encoding/binary"
presets:
tvshows:
import_series:
from:
trakt_list:
username: username
api_key: apikey
series: watchlist
download: /home/username/torrents/transmission/
transmission:
import numpy as np
import matplotlib.pyplot as plt
w = np.logspace(-1, 7, 200)
s = np.complex(0,1) * w
t = (10 * np.power(s,2))/((1 + s/10)*(1 + s/100)*(1 + s/(10**6)))
g = 20 * np.log10(abs(t))
p = np.angle(t) / (np.pi/180)
plt.subplot(211)