Skip to content

Instantly share code, notes, and snippets.

View RobBlackwell's full-sized avatar

Robert Blackwell RobBlackwell

View GitHub Profile

Keybase proof

I hereby claim:

  • I am robblackwell on github.
  • I am robblackwell (https://keybase.io/robblackwell) on keybase.
  • I have a public key ASCKTiK-mr2e19Jzs6EwX2MserBJYFoa0_EY1j7gEhXNUAo

To claim this, I am signing this object:

@RobBlackwell
RobBlackwell / Si5351_VFO.ino
Last active December 26, 2020 17:59 — forked from NT7S/Si5351_VFO.ino
A simple VFO for the Si5351 for either LCD, LCDI2C or OLED
/*
Si5351 VFO
By LA3PNA 27 March 2015
Modified by NT7S 25 April 2015
Modified to be Si5351 Arduino v2 compliant by NT7S 21 Nov 2016
Added LiquidCrystal_I2C support, M0NIL, December 2020.

Patch Julia

find /nix -name '*ld-linux-x86-64.so.2'
/nix/store/68sa3m89shpfaqq1b9xp5p1360vqhwx6-glibc-2.25/lib/ld-linux-x86-64.so.2

set -x the_interpreter "/nix/store/68sa3m89shpfaqq1b9xp5p1360vqhwx6-glibc-2.25/lib/ld-linux-x86-64.so.2"

patchelf --set-interpreter $the_interpreter julia
using Glob
using CSVFiles
using DataFrames
filenames = glob("*.csv")
function load_dataframes(filenames)
df = DataFrame(CSVFiles.load(filenames[1]))
for filename in filenames[2:end]
df2 = DataFrame(CSVFiles.load(filename))
"""
column_vectors(A)
Given a two dimensional array `A` of size `m` x `n`, return an array
of `n` vectors being the columns in `A`. Each vector is of length `m`.
"""
function column_vectors(A)
m,n = size(A)
[A[:,i] for i in 1:n]
using PyCall
@pyimport pickle
# This works for complex objects such as Scikit learn models. REB
# 20171129
function mypickle(filename, obj)
out = open(filename,"w")
pickle.dump(obj, out)
close(out)
"""
freedman_diaconis(x)
Estimates the required bin width for the distribution x.
Freedman, D. and Diaconis, P., 1981. On the histogram as a density
estimator: L 2 theory. Zeitschrift für Wahrscheinlichkeitstheorie und
verwandte Gebiete, 57(4), pp.453-476.
"""
const MATLAB_EPOCH = Dates.DateTime(-0001,12,31)
"""
datenum(d::Dates.DateTime)
Converts a Julia DateTime to a MATLAB style DateNumber.
MATLAB represents time as DateNumber, a double precision floating
point number being the the number of days since January 0, 0000
using MAT
function mymatread(filename, varname)
file = matopen(filename)
x = read(file, varname)
close(file)
return x
end
using PerceptualColourMaps
using Images
function myimagesc(A)
x = minimum(A)
y = maximum(A)
B = (A .- x) ./ (y - x)
imgc = applycolormap(B, cmap("R3")) # outputs a 3-dimensional array
imgc2 = colorview(RGB, permuteddimsview(imgc, (3,1,2)))
end