Skip to content

Instantly share code, notes, and snippets.

View valkheim's full-sized avatar
🔥
ORUGKIDHMFWWKCQ=

valkheim

🔥
ORUGKIDHMFWWKCQ=
View GitHub Profile
@valkheim
valkheim / sin.c
Created September 15, 2018 10:18
#include <stdio.h>
#include <math.h>
char wav_to_char(const float f)
{
return "_,.-*`''"[(unsigned char)((f + 1.f) * (7.f / 2.f))];
}
int main(void)
{
@valkheim
valkheim / own_dump.c
Last active March 29, 2019 20:00
Dump itself
#include <stdio.h>
extern char __executable_start;
extern char __etext;
static void dump(const void* data, size_t size)
{
char ascii[17];
size_t i, j;
/* Implementation of Dekker's algorithm */
/* It allows two threads to share a single-use resource without conflict */
/* It uses only a shared memory for communication. */
#include <stdio.h>
#include <stdbool.h>
#include <pthread.h>
/* The counter threads will increment */
static unsigned int c;
/* 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>
@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
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)
version: '2'
services:
web:
image: odoo:12.0
depends_on:
- db
ports:
- "8069:8069"
volumes:
- odoo-web-data:/var/lib/odoo
@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
@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