Skip to content

Instantly share code, notes, and snippets.

@brulint
brulint / SimpleHTTPRequestOverWifi.uno.c
Last active September 20, 2024 15:13
Send a simple HTTP request over Wifi with ESP32
#include <WiFi.h>
#include <HTTPClient.h>
void setup() {
Serial.begin(115200);
while (!Serial) continue;
WiFi.begin("your SSID", "p4sswOrd");
@brulint
brulint / Blockchain.py
Created August 17, 2024 02:30
Trade wih Blockchain
import requests
url = 'https://api.blockchain.com/v3/exchange/'
# Public requests
requests.get(url + 'tickers/BTC-EUR').json()
# Private requests
api_key = 'YOUR API KEY'
order = {'clOrdId':1,'ordType': 'LIMIT', 'symbol': 'BTC-EUR', 'side': 'BUY', 'orderQty': 10, 'price': 100}
requests.post(url + 'orders', json = order, headers = {'X-API-Token': api}).json()
@brulint
brulint / kraken.py
Created August 17, 2024 02:29
Trade with Kraken
import urllib.parse
import hashlib
import hmac
import base64
import time
import requests
def sign(method, data={}):
key = '' # your API key
secret = '' # your API secret
@brulint
brulint / bitstamp.py
Created August 17, 2024 02:28
Trade with Bitstamp
import time
import hmac, hashlib
import requests
def sign():
user = '' # username @ Bitstamp
key = '' # API key
secret = '' # API secret
now = time.strftime("%s")
@brulint
brulint / mathjax.html
Created July 26, 2022 20:47
mathjax tab in head of html
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
@brulint
brulint / error.lisp
Last active August 23, 2020 16:07
error handling with common lisp
(define-condition my-error (condition)
((message :initarg :message :reader message)))
(handler-case (signal 'my-error :message "Damned! an error!")
(my-error (e) (warn "~s" (message e))))
@brulint
brulint / send-gmail-with-lisp.md
Last active September 5, 2023 16:23
Send gmail with common lisp cl-smtp

Autoriser les applications moins sécurisées

Dans Google, paramètres du compte, sécurité

use cl-smpt library

(ql:quickload :cl-smtp)
@brulint
brulint / sockets.md
Last active January 4, 2022 23:10
How to write a message in another terminal (with Common Lisp) ?
@brulint
brulint / rsi.lisp
Last active August 17, 2024 07:16
Relative Strength Index
;; use rolling-map and average (https://gist.github.com/brulint/c329d255746a7659cb01ba0305c1d2f0)
(defun rsi (n prices)
(let ((gain (let ((cumul 0))
(mapcar #'(lambda (x) (setq cumul (/ (+ (* cumul (1- n)) x) n)))
(cdr (rolling-map 2 #'(lambda (&rest list)
(if (apply #'< list) (abs (apply #'- list)) 0))
prices)))))
(loss (let ((cumul 0))
(mapcar #'(lambda (x) (setq cumul (/ (+ (* cumul (1- n)) x) n)))
@brulint
brulint / rolling-map.lisp
Last active June 4, 2020 13:33
function to calculate moving average, bollinger bands and so on
(defun rolling-map (n func list &optional (sequence '()) (return '()))
(cond ((eq list '()) return)
(t (setq sequence (append sequence (list (car list))))
(if (> (length sequence) n) (setq sequence (cdr sequence)))
(setq return (append return (list (apply func sequence))))
(rolling-map n func (cdr list) sequence return))))
(defun average (&rest list) (/ (apply '+ list) (length list)))
(rolling-map 3 'list '(1 1 2 3 5 8 13 21 34))