Skip to content

Instantly share code, notes, and snippets.

View pepijndevos's full-sized avatar

Pepijn de Vos pepijndevos

View GitHub Profile
@pepijndevos
pepijndevos / sgp30_influx.py
Created April 9, 2020 08:38
Send info from a DHT11 and SGP30 to an Influxdb
import time
import board
import busio
import adafruit_sgp30
import adafruit_dht
from influxdb import InfluxDBClient
from math import exp
from queue import Queue
from threading import Thread, Event
@pepijndevos
pepijndevos / plot.py
Last active September 3, 2020 17:40
Plot reported cases since reaching 100 cases
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
#cutoff = 100
def flip(name):
df = pd.read_csv(name)
del df['Lat']
@pepijndevos
pepijndevos / logicgame.clj
Created October 16, 2019 20:37
A game of logic gates
(ns logicgame.core
(:use clojure.core.logic)
(:gen-class))
(defne ando [a b y]
([1 1 1])
([1 0 0])
([0 1 0])
([0 0 0]))
@pepijndevos
pepijndevos / jitter_PKGBUILD
Created October 3, 2019 09:49
Arch build scripts for GNU Poke
_pkgname=jitter
pkgname=$_pkgname-git
pkgver=r596.745ba29
pkgrel=1
pkgdesc="Jitter"
arch=('i686' 'x86_64')
url="http://ageinghacker.net/git/cgit.cgi/jitter"
license=('GPL')
depends=()
makedepends=('git')
import fileinput
width = 640//16
height = 480//16
lineno = 0
for line in fileinput.input():
if line.startswith("# vim:"): continue
if line.startswith("-"):
fill = height-(lineno%height)
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy.interpolate import interp1d
import ipdb
#ref The Finite-Difference Time Domain Method for Solving Maxwell’s Equations
size = 15
@pepijndevos
pepijndevos / tsp.adb
Last active April 21, 2019 19:45
Continuous Traveling Salesman Problem
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Containers.Vectors;
with Ada.Numerics.Discrete_Random;
with Ada.Numerics.Float_Random;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Numerics.Elementary_Functions;
procedure TSP is
@pepijndevos
pepijndevos / popcount.rs
Created April 20, 2019 07:56
Finds the bit permutation that gives the lowest maximum
use rand;
fn transpose(data: &[u64], col: usize) -> u64 {
return data.iter().fold(0, |acc, x| (acc<<1) | ((x >> col) & 1));
}
fn masked_lowest_popcount(mask: u64, data: Vec<u64>) -> (Vec<u64>, Vec<u64>) {
let mut lowest = u32::max_value();
let mut values: Vec<u64> = Vec::new();
let mut remainder: Vec<u64> = Vec::new();
#include <SPI.h>
#include "registers.h"
#define SEMI 1.059463
#define LED 20
#define BITS(val, ofst, wdt) (((val) & ((1<<wdt)-1)) << ofst)
void writeReg(byte addr, byte data) {
@pepijndevos
pepijndevos / parse.py
Created December 25, 2018 11:09
Parse Whatsapp chats
import re
import sys
import glob
import pandas as pd
import matplotlib.pyplot as plt
regex = """(?P<datetime>\d{1,2}\/\d{1,2}\/\d{1,4}, \d{1,2}:\d{1,2}( (?i)[ap]m)*) - (?P<name>.*(?::\s*\w+)*|[\w\s]+?)(?:\s+(?P<action>joined|left|was removed|changed the (?:subject to "\w+"|group's icon))|:\s(?P<message>(?:.+|\n(?!\d{1,2}\/\d{1,2}\/\d{1,4}, \d{1,2}:\d{1,2}( (?i)[ap]m)*))+))"""
files = sys.argv[1:]