Skip to content

Instantly share code, notes, and snippets.

💭
🧘‍♂️

Ahmed Fasih fasiha

💭
🧘‍♂️
Block or report user

Report or block fasiha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View index.html
<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
Excerpt from Aaron Brown’s “Red-Blooded Risk: The Secret History of Wall Street” (chapter 10) on gold money, paper money, and derivatives
View money.md

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

View gist:53797924cafb5dbca69eeadcebe76312
# Put new words in a CSV with this format
# 表層形,左文脈ID,右文脈ID,コスト,品詞,品詞細分類1,品詞細分類2,品詞細分類3,活用形,活用型,原形,読み,発音
# surface_form,left_context_id,right_context_id,cost,part_of_speech,pos_division_1,pos_division_2,pos_division_3,inflection_type,inflection_style,lemma,reading,pronunciation
$ echo "fasihsignal,-1,-1,100,名詞,一般,*,*,*,*,fasihsignal,ファシシグナル,ファシシグナル" > a.csv
# Then use mecab-dict-index to compile the csv into a .dic file, based on an existing mecab dictionary file
$ /usr/local/Cellar/mecab/0.996/libexec/mecab/mecab-dict-index -d/usr/local/Cellar/mecab/0.996/lib/mecab/dic/ipadic/ -u a.dic -f utf8 -t utf8 a.csv
# The use it
$ mecab -ua.dic
@fasiha
fasiha / brown.md
Last active Apr 27, 2019
Aaron Brown on risk and sleep deprivation
View brown.md

Aaron Brown, on Chat with Traders episode 149, on risk and sleep deprivation.

The other half of risk. In poker at first you can just play quantitatively. You know the numbers, you know the probabilities. At low levels you collected money just by probability. But as you get higher and higher and you start to get some of the best players in the country, you realize there’s a whole other level you gotta get and it’s all done by your unconscious brain. You can’t calculate it, you gotta feel it, and you gotta train your unconscious brain to play poker. It’s a powerful computer up there … but it doesn’t know how to play poker. And your conscious brain is very weak, can’t multiply two three digit numbers together which a computer can do easily. So your conscious brain is relegated tasks like coming up with advertising jingles and wondering which celebrity marriages are in trouble while your unconscious brain handles heartbeat and respiration and whether you’

@fasiha
fasiha / holdem.md
Last active Feb 3, 2019
Several four-player hands of hold ’em via https://github.com/fasiha/hold-em-tools
View holdem.md

1

Player 1

Percents rf sf qu fh fl st tr 2p pa hi
9c10c = hi <1 <1 <1 2 6 9 4 22 41 16
10c 9c× 5h Kc 6d = hi 0×0 <1×<1 0×<1 0×2 4×<1 3×5 1×4 8×21 47×47 36×21
10c 9c× 5h Kc 6d 6s = pa 0×0 0×0 0×<1 0×6 0×0 0×2 4×9 26×42 70×42 0×0
10c 9c× 5h Kc 6d 6s Jc = pa ×0 ×0 ×<1 ×3 ×0 ×0 ×7 ×39 ×52 ×0
@fasiha
fasiha / Ebisu-Java-Bare.ipynb
Created Nov 11, 2018
Very barebones Java implementation of Ebisu https://fasiha.github.io/ebisu/
View Ebisu-Java-Bare.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fasiha
fasiha / logSumExp.java
Last active Nov 9, 2018
LogSumExp, first cut in Java with Collections and lambdas. Port of https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html
View logSumExp.java
//
// SUPPORT FUNCTIONS
// Via https://stackoverflow.com/a/32342172/500207
//
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import java.util.function.BiFunction;
<T> Stream<T> iteratorToFiniteStream(Iterator<T> iterator, boolean parallel) {
final Iterable<T> iterable = () -> iterator;
return StreamSupport.stream(iterable.spliterator(), parallel);
@fasiha
fasiha / enumerate.ts
Created Sep 23, 2018
TypeScript (and, for ES2015 and above, JavaScript) port of Python's `enumerate` to make index-value pairs.
View enumerate.ts
/**
* Generates `[index, value]` 2-tuples, so you can `for (let [index, value] of enumerate(v) {...})`.
* @param v array or iterable iterator to enumerate
* @param n starting number (defaults to 0)
*
* Hat tip: https://docs.python.org/3/library/functions.html#enumerate
*/
export function* enumerate<T>(v: T[]|IterableIterator<T>, n: number = 0): IterableIterator<[number, T]> {
for (let x of v) { yield [n++, x]; }
}
@fasiha
fasiha / bestGroupBy.ts
Last active Sep 21, 2018
bestGroupBy.ts
View bestGroupBy.ts
/**
* Like "groupBy", but only track the "best" group.
* @param arr Array of values
* @param grouper Mapper from elements of array to some group. Should be pure (it'll be called on first element twice).
* @param compare Compare two groups: if `compare(x, y) > 0`, then `x > y`, and similarly `=` and `<`.
* @return array containing the best group as first element, then the array of entries in that group.
*
* I only care about `compare`'s output's sign/zero, so it doesn't need to be a true distance.
*/
export function bestGroupBy<T, U>(arr: T[], grouper: (x: T) => U, compare: (x: U, y: U) => number): [U, T[]] {
@fasiha
fasiha / polly.sh
Created Sep 17, 2018
AWS Polly-aided text-to-speech, like, literally: a text file to numbered MP3 files.
View polly.sh
counter=1
cat input.txt | while read line; do
echo $counter $line
aws polly synthesize-speech --output-format mp3 --voice-id Takumi --text "$line" "$counter $line.mp3"
counter=$((counter+1))
sleep 0.5
done
You can’t perform that action at this time.