Skip to content

Instantly share code, notes, and snippets.

View petulla's full-sized avatar

Sam Petulla petulla

View GitHub Profile
@petulla
petulla / nn_lr.py
Created May 31, 2021 13:53
Logistic regression numpy vanilla implementation
import numpy as np
inp = np.array([0,1,2,2,23,35,32,52])
target = np.array([0,0,0,0,1,1,1,1])
inp = inp.reshape(8,1)
target = target.reshape(8,1)
params = 1
class Model:
def __init__(self, dim_inp, lr):
@petulla
petulla / template.py
Last active March 31, 2021 01:34
Snippets for memorization/contests
## Delete element from heap in O(logn)
def delete(num, heap):
index = heap.index(num)
heap[index] = heap[-1]
del heap[-1]
if index < len(heap):
heapq._siftup(heap, index)
heapq._siftdown(heap, 0, index)
@petulla
petulla / .vimrc
Last active November 20, 2020 03:34
Minimal vimrc
" Vimscript file settings ---------------------- {{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" }}}
" Plugins {{{
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
@petulla
petulla / min-char-rnn.py
Last active August 29, 2020 01:25
Simplified rewrite of Karpathy character-level language model with a Vanilla Recurrent Neural Network
import numpy as np
import random
import unidecode
from bidict import bidict
file = unidecode.unidecode(open("./bin/input.txt").read())
file_len = len(file)
print("file_len =", file_len)
def random_chunk():
@petulla
petulla / chroma_clamp.csv
Created June 28, 2019 20:26
chroma_clamp
We can't make this file beautiful and searchable because it's too large.
clamp,x
"0-0",0
"1-0",0
"2-0",0
"3-0",0
"4-0",0
"5-0",0
"6-0",0
"7-0",0
"8-0",0
@petulla
petulla / cccie31_1.csv
Created June 18, 2019 22:18
CIE 1931 2-deg xyz chromaticity coordinates
wl x y z
360 0.175560 0.005294 0.819146
361 0.175483 0.005286 0.819231
362 0.175400 0.005279 0.819321
363 0.175317 0.005271 0.819412
364 0.175237 0.005263 0.819500
365 0.175161 0.005256 0.819582
366 0.175088 0.005247 0.819665
367 0.175015 0.005236 0.819749
368 0.174945 0.005226 0.819829
@petulla
petulla / visualisingdata.js
Last active January 23, 2019 19:45
Generic Promise.all + Axios scraper for fetching html content
const io = require('indian-ocean');
const cheerio = require('cheerio');
const axios = require('axios');
// config
const fileName = 'kirk.csv';
const selector = '.row > div > p';
// url generation
const months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
@petulla
petulla / keybase.md
Created October 24, 2018 15:02
keybase.md

Keybase proof

I hereby claim:

  • I am petulla on github.
  • I am petulla (https://keybase.io/petulla) on keybase.
  • I have a public key whose fingerprint is BCE1 0467 E0D9 C457 6ABA 0134 5ED0 0E6C 72C3 51F6

To claim this, I am signing this object:

@petulla
petulla / animation.gif
Last active July 8, 2018 23:17
Harmonic wave diagram
animation.gif