Skip to content

Instantly share code, notes, and snippets.

View mrquincle's full-sized avatar
💭
Does it have LEDs?

Anne van Rossum mrquincle

💭
Does it have LEDs?
View GitHub Profile
@mrquincle
mrquincle / main.cpp
Last active November 22, 2021 17:04
Gist to explain DecreaseMember
/**
* Copy <cs_Math> from bluenet repository and if not present add to it the following function.
template<class T, class M, class U=int>
constexpr inline decltype(auto) DecreaseMember(T& obj, M member, U diff=1) {
obj.*member = SafeAdd(obj.*member, -diff);
return obj.*member;
}
* Compile with g++ -I. main.cpp -o main
@mrquincle
mrquincle / documentation.md
Last active August 3, 2021 14:56
Documentation
@mrquincle
mrquincle / whatsapp.md
Last active July 21, 2021 15:26
Whatsapp

Check different ways

API way:

API

Wa.me

Wa.me

@mrquincle
mrquincle / visualize.R
Created March 26, 2020 19:50
Visualize VI plot
#!/usr/bin/env Rscript
args = commandArgs(trailingOnly=TRUE)
# Make sure the data is properly formatted.
# It should be separated by tabs. It should start with non-white space.
# It should have two columns: x, y.
separator <- '\t'
library(ggplot2)
@mrquincle
mrquincle / help
Last active March 3, 2020 08:51
Help (shell)
Command line
Force argument: interface=${1:? "usage"}
Resize gnome-terminal: resize -s 50 140
Find file with wildcard: find . -name 'test*'
Untar --extract --file: tar xf archive.x.y.z -C directory
Unzip to directory: unzip archive.zip -d directory
Zip directory: zip archive.zip -r directory
Inline sed: sed -i '/Term/s/^/#/'
Process substitution: meld <(xxd file1) <(xxd file2) <(xxd file3)
Make Android screenshot: adb shell screencap -p | dos2unix > screen.png
@mrquincle
mrquincle / crc_table_gen_65536.c
Created February 7, 2020 11:04
Generate table with 65536 unique entries
#include <iostream>
#include <iomanip>
uint16_t crcTable[65536];
#define WIDTH (8 * sizeof(uint16_t))
#define TOPBIT (1 << (WIDTH - 1))
// Checked with https://www.lammertbies.nl/comm/info/crc-calculation
// It is CRC-CCITT (XModem)
@mrquincle
mrquincle / crc_table_gen.c
Created February 7, 2020 10:51
CRC-CCITT (XModem)
#include <iostream>
#include <iomanip>
uint16_t crcTable[256];
#define WIDTH (8 * sizeof(uint16_t))
#define TOPBIT (1 << (WIDTH - 1))
// Checked with https://www.lammertbies.nl/comm/info/crc-calculation
// It is CRC-CCITT (XModem)
@mrquincle
mrquincle / cubes_emd_latent_sweep.gif
Last active October 26, 2019 15:07
Results of noparama
cubes_emd_latent_sweep.gif
@mrquincle
mrquincle / dimming.md
Last active July 2, 2019 15:48
Crownstone dimming

The Crownstone dimming uses a trick to make sure the IGBTs are not turned on partly when the voltage at the input of the gate driver is not yet up to around 15V.

How this is done is to place a 8V2 Zener back-to-back with the 15V Zener to be able to generate a negative 8.2V (give or take a diode offset of 0.7V). Subsequently, there is a voltage divider R2, R4 which divides this by two. The voltage of around -4V is fed into a depletion mode n-mosfet. The latter will be conducting till its negative threshold has been reached (-2.8V typical). If this has been reached it will be off. At the moments before that it will regularly conduct and short the output of the IGBT driver.

[Circuit](https://www.falstad.com/circuit/circuitjs.html?cct=$+1+0.000005+14.235633750745258+70+5+50%0Aw+240+160+320+160+0%0Ar+240+288+416+288+0+576000%0Av+-144+224+-144+352+0+1+50+680+0+0+0.5%0Aw+160+400+16+400+0%0Aw+16+400+-80+400+0%0A34+zvoltage%5Cq15+0+1.7143528192810002e-7+0+2+15%0Az+160+272+160+160+2+zvoltage%5Cq15%0A34+zvoltage%5Cq8.

@mrquincle
mrquincle / insertion_sort.cu
Last active May 16, 2019 15:49
CUDA insertion sort
#include <stdio.h>
#include <stdlib.h>
#define N 16
__global__ void insertionsort(int n, const float *values, int *indices) {
int key_i, j;
for (int i = blockIdx.x; i < n; i += gridDim.x) {
key_i = indices[i];
j = i - 1;