Skip to content

Instantly share code, notes, and snippets.

View fasiha's full-sized avatar
💭
🐦‍🔥

Ahmed Fasih fasiha

💭
🐦‍🔥
View GitHub Profile
@fasiha
fasiha / ebisu.py
Created January 29, 2020 03:46
Single all-in-one pure-Python Ebisu module https://fasiha.github.io/ebisu/
# -*- coding: utf-8 -*-
## logsumexp.py
from math import exp, log
def logsumexp(a, b):
a_max = max(a)
s = 0
@fasiha
fasiha / quizHistoryToEbisuToMemorize.py
Last active January 29, 2020 03:54
Converting a generic history of quizzes (times and results) to an Ebisu model (given initial half-life and model parameters) to a Memorize schedule
import ebisu
from memorizesrs import schedule
from datetime import datetime, timedelta
from math import inf
learnTime = datetime(2020, 1, 27, 0, 0, 0)
reviewTimes = [
learnTime + timedelta(hours=1.1), learnTime + timedelta(hours=4.4),
learnTime + timedelta(hours=22.0), learnTime + timedelta(days=2.4)
]
# while read f; do
for f in $@; do
d=`exiftool -CreateDate "$f" | tail -n1 | cut -d: -f2- | sed -e 's/^ *//' -e 's/ /_/' -e 's/:/-/g'`;
b=$(basename "$f");
final="$d-$b";
echo $final;
/Users/fasih/Downloads/Dropbox-Uploader/dropbox_uploader.sh -q upload "$f" "/Camera Uploads/$final"
done
@fasiha
fasiha / svelte-tutorial.md
Last active January 14, 2020 02:45
All-in-one Svelte tutorial—for anyone who hates clicking through the tutorial to refresh your memory! Original at https://svelte.dev/tutorial

Generated by running cd svelte/site/content/tutorial && for i in *;do echo "# $i"; for j in $i/*; do echo "## $j"; cat $j/text.md; echo "\n\n"; done;done |grep -v meta.json!

01-introduction

01-introduction/01-basics


title: Basics

Welcome to the Svelte tutorial. This will teach you everything you need to know to build fast, small web applications easily.

アアァ
イイィ
ウウゥ
エエェ
オオォ
カカ
キキ
クク
ケケ
ココ
@fasiha
fasiha / frequencies.json
Created October 18, 2019 00:25
Mecab-IPADIC "-O yomi" output of a bunch of Japanese subtitle files, and associated character frequencies (kanji that MeCab couldn't understand deleted). I can't figure out how to get "yomi"-style output out of UNIDIC.
[
["\n",300426],
[" ",158830],
["!",638],
["(",2022],
[")",2023],
[",",136462],
["-",136708],
["0",421613],
["1",193907],
@fasiha
fasiha / Fsympad.py
Created August 29, 2019 03:30
How to zero-pad nicely symmetric vectors for FFT, so FFT of real symmetric inputs is (to machine precision) real
def Fsympad(h, m=None, inputOriginMiddle=True):
if inputOriginMiddle:
h = fft.ifftshift(np.array(h))
else:
h = np.array(h)
if not m:
return fft.fftshift(fft.fft(h))
n = h.size
assert m >= n
# odd-length case: just insert zeros
<meta charset="UTF-8">
<script src="plotly-1.48.1.min.js"></script>
<p>
Source: <a href="https://www1.ncdc.noaa.gov/pub/data/ghcn/daily/by_year/"><code>ghcn/daily/by_year</code></a>.
Background: <a href="https://www.ncdc.noaa.gov/ghcn-daily-description">Global Historical Climate Network Daily -
Description</a>.
</p>
<div id="tester" style="width:100%;height:90%;"></div>
<script>
const yearlyRaw = `1763,3379.2,730
@fasiha
fasiha / money.md
Created May 9, 2019 23:35
Excerpt from Aaron Brown’s “Red-Blooded Risk: The Secret History of Wall Street” (chapter 10) on gold money, paper money, and derivatives

To start a business with precious metal money, you need to have or to find an investor with enough precious metal to buy all the assets you need to start generating cash sales. To start a business with paper money, you need to find a bank willing to supply you with pieces of paper. Neither you nor the bank need have any net worth, although in practice banks tend to maintain net worth equal to a fraction of the loans they make. Even so, the amount of capital required to start the business with paper money lent by a bank is much less than the total value of the assets required. What is essential is that the bank’s lending standards are low enough to approve your loan, but high enough to make its paper money acceptable enough to acquire the assets you need.

To start a business with derivative money, you identify all assets you require and all products you will deliver in the future. Of course, there is uncertainty around these things, especially the amount and quality of products you will deliver. You don’t hav