Skip to content

Instantly share code, notes, and snippets.

@petulla
petulla / nn_lr.py
Created May 31, 2021
Logistic regression numpy vanilla implementation
View nn_lr.py
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 Mar 31, 2021
Snippets for memorization/contests
View template.py
## 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 Nov 20, 2020
Minimal vimrc
View .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 Aug 29, 2020
Simplified rewrite of Karpathy character-level language model with a Vanilla Recurrent Neural Network
View min-char-rnn.py
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():
View chroma_clamp.csv
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 Jun 18, 2019
CIE 1931 2-deg xyz chromaticity coordinates
View cccie31_1.csv
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 Jan 23, 2019
Generic Promise.all + Axios scraper for fetching html content
View visualisingdata.js
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];
View 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: