Skip to content

Instantly share code, notes, and snippets.

View trylks's full-sized avatar
🤖
Automating

trylks trylks

🤖
Automating
View GitHub Profile
@trylks
trylks / Pipfile
Last active January 31, 2023 12:17
minimal working example pytest fastapi multiprocessing (not working)
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
pytest = "*"
fastapi = "*"
requests = "*"
uvicorn = "*"
@trylks
trylks / CurseOfDimensionality.ipynb
Created August 19, 2022 13:01
Curse of dimensionality
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@trylks
trylks / CurseOfDimensionality.ipynb
Created August 19, 2022 12:36
Curse of dimensionality
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@trylks
trylks / macd_aggregator.sql
Created January 31, 2012 19:52
Here is a brief pl/pgsql code to calculate the MACD indicator from a table storing daily candles. It's not finished and help is welcome, either wrt efficiency or wrt correctness, for some reason EMA formulas online are calculated with alpha [0,1] whereas
create table candles(ticker text, day date, value real, primary key (ticker, day));
drop table macdtuple cascade;
CREATE TABLE macdtuple (ticker real, ema1val real, ema2val real, signalval real);
create or replace function macd_tuple_func(state macdtuple, inval real, ticker real, alpha1 real, alpha2 real, alpha3 real) returns macdtuple as $previousmacd$
declare
x macdtuple;
begin
if (state is null OR ticker <> ticker(state)) then
@trylks
trylks / MACDCalculator.java
Created January 31, 2012 12:04
MACD calculator. Not a standalone Java program but some Java code as good as pseudocode.
import java.util.ArrayList;
public class MACDCalculator extends SimpleCalculator {
private float ema1alpha;
private float ema2alpha;
private float signalalpha;
private float[] pema1;
private float[] pema2;
private float[] psignal;
@trylks
trylks / index.html
Last active March 21, 2018 19:01
I just wanted a cleaner view, sorry
<html><head><title>too much stuff around to just share a video...</title></head><body>
<div class="tumblr-post" data-href="https://embed.tumblr.com/embed/post/igpB6hm57YxdC-5PUt8Z5w/172095725562" data-did="4cff748eb40aa96b418284368459b401e8d86715">
<a href="http://pordondemeda.tumblr.com/post/172095725562/luisonte-el-tío-ya-sospecha-desde-el-principio">http://pordondemeda.tumblr.com/post/172095725562/luisonte-el-tío-ya-sospecha-desde-el-principio</a>
</div>
<script async src="https://assets.tumblr.com/post.js"></script>
<p>To be viewed at: <a href="https://cdn.rawgit.com/trylks/c4f6f2d4a2c14fc6e7f9dd7d493ed01f/raw/a7614ae9066cdb59f84391e272a0df159e0ed374/index.html">rawgit</a></p>
</body></html>
@trylks
trylks / 0_README.md
Last active July 17, 2016 22:36
Five small programming problems.

It's Friday night, I'm too tired to do anything useful, but not enough to sleep. I find five small programming katas and I decide that I can start the weekend procrastination already. They are meant to be programmed in the language you feel most comfortable with. Unfortunately, I don't feel comfortable with any language, therefore I used several of them.

PS: Upon closer inspection, probably I should learn Hy.

import nltk
from nltk.probability import LidstoneProbDist
from nltk.model.ngram import NgramModel
import pandas as pd
tweets = pd.read_csv('tweeets.csv')
tokenize = lambda x: nltk.word_tokenize(str(x))
train = [tokenize(text) for text in tweets[tweets.user == 'trylks']['text']]
text = tokenize("I think that the #Python library #nltk is great")
@trylks
trylks / longreply.md
Created September 16, 2013 18:17
This is a very long reply, so I needed somewhere else to write it.

This is a reply to a comment in philosophy@stackexchange, but to some extent it's self-contained and definitively quite long.

If photons actually behave like a wave or not doesn't matter for the point I'm trying to make. The model could simply be imprecise without hidden variables. For instance photons could be like a sphere rotating inside a greater sphere (that we call photon, even though it's just a boundary for the true photon), therefore the inner sphere would work like the wave I'm talking about. Photons could be composed of subparticles that could be moving in the photon in such a way that could explain this behaviour, and in this way we can find many other possible explanations. Randomness, on the other hand, cannot be explained, randomness is the lack of explanation, the lack of cause, it cannot be verified.

About Bell experime

@trylks
trylks / tailrecmaxcomparable
Created August 6, 2013 13:10
I'm still learning Scala so this may be very wrong for a number of reasons. I'm not even sure about the meaning of the <: operator
// for: http://stackoverflow.com/questions/14011181/how-can-i-find-the-index-of-the-maximum-value-in-a-list-in-scala
@tailrec
final def maxindex[T <: Ordered[T]](list:Iterable[T], defaultIndex:Int = -1, defaultValue:T=None, currentIndex:Int = 0):(Int, T) = list match {
case Nil => (defaultIndex, defaultValue)
case head::tail =>
if (head > defaultValue)
maxindex(tail, currentIndex, head, currentIndex+1)
else
maxindex(tail, defaultIndex, defaultValue, currentIndex+1)