This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html><html><head><meta charset="utf-8"/><script> | |
const isValid = raw => { | |
const words = raw.split(/\s+/) | |
// writeToBody("raw: " + raw) | |
// writeToBody("words: " + words) | |
const checker = (prevAcc, nextWord) => { | |
const acc = { set: prevAcc.set, count: prevAcc.count }; | |
if( acc.set.has(nextWord) ) { acc.count = acc.count + 1 } | |
else { acc.set.add(nextWord) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- http://blog.sigfpe.com/2006/12/evaluating-cellular-automata-is.html | |
-- The above post learned me about this neat comonad instance! :D | |
data U x = U [x] x [x] | |
right,left:: U x -> U x -- shift focus of the zipper | |
right (U a b (c:cs)) = U (b:a) c cs | |
left (U (a:as) b c) = U as a (b:c) | |
-- the zipper is a functor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This is using a haskell comonad to find right angles between given geometrical vectors | |
-- The code is kind of overkill, but it is a cute showcase of comonads | |
-- a FocusSet. One element in Focus, and all other elements in a list. | |
data Fs a = Fs a [a] deriving (Show) | |
instance Functor Fs where | |
fmap fun (Fs k l) = Fs (fun k) (map fun l) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This is using a haskell comonad to find right angles between given geometrical vectors | |
-- The code is kind of overkill, but it is a cute showcase of comonads | |
-- a FocusSet. One element in Focus, and all other elements in a list. | |
data Fs a = Fs a [a] deriving (Show) | |
instance Functor Fs where | |
fmap fun (Fs k l) = Fs (fun k) (map fun l) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
import json | |
import typing | |
import functools | |
SEK = typing.NewType('SEK',float) | |
EUR = typing.NewType('EUR', float) | |
ConversionRate = typing.NewType('ConversionRate',float) | |
ThreeLetterCurrencyCode = str # ISO4217 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# standards | |
from abc import ABC | |
from itertools import islice | |
from collections import Counter | |
import types | |
# 3rd party | |
import numpy as np | |
import scipy.stats as stats | |
import matplotlib.pyplot as plt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# standards | |
from itertools import islice | |
import types | |
# 3rd party | |
import numpy as np | |
class RandomVariable(): | |
def __iter__(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MemorizingNormalizer(nn.Module): | |
def __init__(self, d, eps, rho): | |
super().__init__() | |
self.means = nn.Parameter(torch.zeros(d), requires_grad=False) | |
self.vars = nn.Parameter(torch.ones(d), requires_grad=False) | |
self.eps = nn.Parameter(torch.tensor(eps, dtype=float), requires_grad=False) | |
self.rho = nn.Parameter(torch.tensor(rho, dtype=float), requires_grad=False) | |
def forward(self, x): | |
self.means.data = self.means * self.rho + (1 - self.rho) * x.mean(axis=0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Python script that takes a folder, and for each CALS Raster file, it converts to a TIFF file. | |
https://en.wikipedia.org/wiki/CALS_Raster_file_format | |
file ending ".cal" | |
It so happens that TIFF can be compressed with Group 4 compression (as in faxes), and that is the compression format of CALS Raster images Type 1. |
OlderNewer