Skip to content

Instantly share code, notes, and snippets.

View smithcommajoseph's full-sized avatar

Joseph (Jos) Smith smithcommajoseph

View GitHub Profile
@smithcommajoseph
smithcommajoseph / 1_temp_knots_and_mat.ipynb
Last active April 23, 2024 18:56
calculate_temp_knots and create_temp_matrix ported from R to Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@smithcommajoseph
smithcommajoseph / joseph-smith-bird-species-kaggle-project.ipynb
Last active June 26, 2022 14:57
Joseph Smith - Bird Species (Kaggle Project).ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# based on https://gist.github.com/daviddalpiaz/ae62ae5ccd0bada4b9acd6dbc9008706
# load image files
load_image_file = function(filename) {
f = gzfile(filename, 'rb')
readBin(f, 'integer', n = 1, size = 4, endian = 'big')
n = readBin(f, 'integer', n = 1, size = 4, endian = 'big')
nrow = readBin(f, 'integer', n = 1, size = 4, endian = 'big')
ncol = readBin(f, 'integer', n = 1, size = 4, endian = 'big')
x = readBin(f, 'integer', n = n * nrow * ncol, size = 1, signed = FALSE)
// truth table POC
let vars = ['x1', 'x2', 'x3', 'x4'],
r = Math.pow(2, vars.length),
str = '',
i,
j;
str += `\r\n\r\n`
for (i = 0; i < vars.length; i++) {
q1
qAccept
qReject
0,1
q1 (0,x,R) q2
q1 (y,y,R) q4
q1 ( , ,L) qAccept
q1 (1, ,R) qReject
q2 (0,0,R) q2
q2 (y,y,R) q2
@smithcommajoseph
smithcommajoseph / booths.md
Last active January 16, 2021 14:36
A booth's example

#Booth's algorithm

base 10

-13 * 9 = -117

binary

 -13 = 10011
   9 = 01001 
@smithcommajoseph
smithcommajoseph / dfa.pl
Last active October 6, 2020 20:28
A simple DFA implemented in Prolog
dfa_start(dfa1, q0).
dfa_final(dfa1, q3).
dfa_transition(dfa1, q0, '0', q1).
dfa_transition(dfa1, q0, '1', q1).
dfa_transition(dfa1, q0, '.', q2).
dfa_transition(dfa1, q1, '0', q1).
dfa_transition(dfa1, q1, '1', q1).
dfa_transition(dfa1, q1, '.', q3).
dfa_transition(dfa1, q2, '0', q3).
@smithcommajoseph
smithcommajoseph / Dfa.hs
Last active September 23, 2020 18:35
A simple DFA implemented in Haskell
module Dfa
(
stateFactory
, alphabet
, allStates
, firstState
, acceptStates
, allTransitions
, transFromState
, transLabel