Skip to content

Instantly share code, notes, and snippets.


Tobin Fricke tobin

View GitHub Profile
tobin /
Last active Sep 4, 2020
Solution to "invert three signals with two not gates" puzzle
# Solution to the following puzzle:
# Invert three boolean signals Using only two NOT gates,
# and as many AND or OR gates as needed,
# Tobin Fricke 2020-09-03
for x in [True, False]:
for y in [True, False]:
for z in [True, False]:
# If we assume that there is only one solution, then, when searching for the input
tobin / static_const.c
Last active May 9, 2017
static const
View static_const.c
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
const int baz = rand(); // ok!
baz = 99; // compile-time error.
static int goo = rand(); // compile-time error.
goo = 99; // ok.
tobin /
Created Apr 23, 2014
Integer square root
def exact_sqrt(x):
"""Calculate the square root of an arbitrarily large integer.
The result of exact_sqrt(x) is a tuple (a, r) such that a**2 + r = x, where
a is the largest integer such that a**2 <= x, and r is the "remainder". If
x is a perfect square, then r will be zero.
The algorithm used is the "long-hand square root" algorithm, as described at
tobin / twinT.m
Created Nov 21, 2013
Plot the frequency response (Bode plot) of an ideal active twin-T notch
View twinT.m
% Plot the frequency response of an ideal active twin-T notch, versus
% bootstrap feedback gain \alpha.
% Tobin Fricke <>
% 2013-11-21
% Pick the color map (to make the plot pretty)
cm = jet();
% Choose the frequency axis
tobin / 3867.txt
Created May 17, 2013
Notes on PDH waveform
View 3867.txt
A PDH error signal can be calibrated (into Hz per volt) simply by
observing the peak-to-peak amplitude of the PDH signal as the
cavity is swept through resonance. Here's the math:
An impedance-matched, lossless cavity has amplitude reflectivity of
r_c(f) = i f / (i f + pcav)
where pcav is the cavity pole, and f is the detuning frequency (i.e.
the difference between the frequency of the light and the resonant
tobin / BNQ_W600+.edid
Last active Dec 17, 2015
BenQ W600+ Projector EDID/Modelines
tobin /
Last active Dec 16, 2015
Today I learned

This is valid:

M = [1,2,3]    
for M[0] in range(0,10):
    print M[0]


The star operator opens tuples and other sequences:

tobin / fu_puzzle.m
Last active Dec 16, 2015
Solve a magic square variant in Matlab
View fu_puzzle.m
% Program to solve a sort of magic square, where only the rows and columns
% must sum to the magic constant, and not the diagonals. Some elements of
% the square are given in advance while others (indicated with 0) are
% unknown.
% TF Time-Wasting Project 04-2013
function result = fu_puzzle
puzzle = ...
[ 1 0 0 0 22
tobin / pdh.gnuplot
Created Feb 28, 2013
Plot PDH error signal in Gnuplot
View pdh.gnuplot
f_mod = 35.5e6
pcav = 300e3
i = {0, 1}
conj(z) = real(z) - i*imag(z)
r_c(f) = i*f / (i*f + pcav)
pdh(f) = imag(r_c(f)*conj(r_c(f+f_mod))-conj(r_c(f))*r_c(f-f_mod))
set samples 501
tobin / example1.m
Last active Dec 14, 2015
Experimenting with Numerical Python
View example1.m
% Matlab code to plot a cavity resonance
F = 10; % Finesse
f = linspace(-0.5, 1.5, 201);
P = 1./(1 + (2/pi) * F^2 * sin(pi*f).^2);
plot(f, P);
xlabel('free spectral ranges');
ylabel('power buildup');
You can’t perform that action at this time.