Skip to content

Instantly share code, notes, and snippets.

View valkheim's full-sized avatar
🔥
ORUGKIDHMFWWKCQ=

valkheim

🔥
ORUGKIDHMFWWKCQ=
View GitHub Profile
@valkheim
valkheim / LGC.asm
Last active December 2, 2020 10:20
Linear Congruential Generator
00000000004011b0 <my_srand>:
4011b0: 55 push rbp
4011b1: 48 89 e5 mov rbp,rsp
4011b4: 89 7d fc mov DWORD PTR [rbp-0x4],edi
4011b7: 8b 7d fc mov edi,DWORD PTR [rbp-0x4]
4011ba: 89 3c 25 3c 40 40 00 mov DWORD PTR ds:0x40403c,edi ; 0x40403c holds rand_state
4011c1: 5d pop rbp
4011c2: c3 ret
4011c3: 66 2e 0f 1f 84 00 00 nop WORD PTR cs:[rax+rax*1+0x0]
4011ca: 00 00 00
const hashCode = str =>
_.reduce(
str,
(acc, c) => {
return (acc += c.charCodeAt(0)); // + ((acc << 5) - acc);
},
0
);
const intToRGB = i => {
==> main.py <==
import math
from Crypto.Hash import SHA256
from Crypto.Util.number import getPrime, inverse, bytes_to_long, long_to_bytes, inverse, isPrime
import pyecm
def phi(p, q):
" Euler totient "
return (p - 1) * (q - 1)
@valkheim
valkheim / alma.py
Last active March 17, 2021 17:27
Arnaud Legoux Moving Average
def add_alma(df):
alma = pd.DataFrame(columns=["ALMA"])
close = df["close"]
size = len(close)
def ALMA(data, sigma=6, offset=0.90, size=40):
"""
Arnaud Legoux Moving Average
:param data: data array
@valkheim
valkheim / yellow_dots_decoder.py
Last active April 12, 2020 15:46
Yellow dots, tracking dots decoder
# 0 1 2 3 4 5 6 7 8 9 A B C D E
# X X X X X X X X X X (parity row)
# +---------------------------
# 64 X| X X
# |
# 32 X|X X X X
# |
# 16 X|X X X X X X
# |
# 8 | X X X X X
version: '2'
services:
web:
image: odoo:12.0
depends_on:
- db
ports:
- "8069:8069"
volumes:
- odoo-web-data:/var/lib/odoo
const DEBUG = true;
const logger = (fn, label) => {
if (!DEBUG)
return fn
return function() {
console.debug('='.repeat(3), !!fn.name ? fn.name + ': ' + label : label)
console.debug(arguments)
console.debug(fn.toString())
fn.apply(this, arguments)
const DEBUG = true;
const logger = (fn, label) => {
if (!DEBUG)
return fn
return function() {
console.debug('='.repeat(3), !!fn.name ? fn.name + ': ' + label : label)
console.debug(arguments)
console.debug(fn.toString())
fn.apply(this, arguments)
@valkheim
valkheim / ballhausen.c
Created May 9, 2019 12:30
Ballhausen's solution to classical reader-writers fairness problem
/* Ballhausen's solution to classical reader-writers fairness problem */
/* Initial problem : a continual flow of readers blocks writers from updating */
/* Ballhausen's solution :
* * one readers takes up the same space as all readers reading together
* * a semaphore access_db is used by readers to enter the database with a
* an initial value equalling the number of readers
* * every time a reader is accessing the db, the semaphore value is
* decremented
* * every time a reader is leaving the db, the semaphore value is incremented
* * writers want exclusive access to the db. It occupies all spaces step by
/* Lamport's bakery algorithm */
/* Improve safety in the usage of shared resources among multiple threads by */
/* means of mutual exclusion */
/* Communications of the ACM, August 1974, Volume 17, Number 8, P.453 */
#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>