Skip to content

Instantly share code, notes, and snippets.

@dmazzer
dmazzer / mount_rpisdimg.sh
Last active December 14, 2020 17:29
mount rpi-sdimg
# source: https://raspberrypi.stackexchange.com/questions/13137/how-can-i-mount-a-raspberry-pi-linux-distro-image
IMAGE_FILE="YOUR IMAGE FILE GOES HERE"
TMP=$(mktemp -d)
LOOP=$(sudo losetup --show -fP "${IMAGE_FILE}")
sudo mount ${LOOP}p2 $TMP
sudo mount ${LOOP}p1 $TMP/boot/
# do stuff to ${TMP}/ which is rpi filesystem
@dmazzer
dmazzer / readme.md
Created April 30, 2019 09:50 — forked from endolith/readme.md
THD+N calculator

Unfortunately, there are 2 versions of this. The other is here: https://github.com/endolith/waveform-analyzer I intend to either completely combine them or completely separate them, eventually.

Somewhat crude THD+N calculator in Python

Measures the total harmonic distortion plus noise (THD+N) for a given input signal, by guessing the fundamental frequency (finding the peak in the FFT), and notching it out in the frequency domain. This is a THDR

@dmazzer
dmazzer / osc_client.py
Last active April 11, 2019 23:45
Open Sound Controller client/server with Python-OSC
from pythonosc.udp_client import SimpleUDPClient
ip = "127.0.0.1"
port = 8000
client = SimpleUDPClient(ip, port) # Create client
client.send_message("/some/address", 123) # Send float message
client.send_message("/some/address", [1, 2., "hello"]) # Send message with int, float and string
client.send_message("/3/rotary1", 0.5) # Send message with int, float and string
@dmazzer
dmazzer / FFTW3.c
Last active September 5, 2018 23:46
FFTW3 example.
#include <complex.h>
#include <fftw3.h>
#include <stdio.h>
int main(void)
{
int N = 8;
double *in;
fftw_complex *d_out;
double *i_out;
@dmazzer
dmazzer / mount_env.sh
Created July 12, 2018 22:05
unionfs script work with PyCharm and Clion on same project structure
#!/bin/bash
#
# Daniel Mazzer (2018)
#
# Source: Source files
# Idea_x: PyCharm and Clion .idea folders
# Mount_x: Mounting points to point IDEs workspace
SOURCE=src
IDEA_P=project_p
@dmazzer
dmazzer / DataTransfer.java
Created October 6, 2017 01:02 — forked from visualskyrim/DataTransfer.java
Simple Flink job streaming data from Kafka to local files.
import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.streaming.api.CheckpointingMode;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.CheckpointConfig;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.fs.bucketing.BucketingSink;
import org.apache.flink.streaming.connectors.fs.bucketing.DateTimeBucketer;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer08;
import org.apache.flink.streaming.util.serialization.SimpleStringSchema;
# http://docs.mongoengine.org/tutorial.html
from mongoengine import *
db = connect('tumblelog')
db.drop_database('tumblelog')
##################
@dmazzer
dmazzer / port_forward_ipv4_ipv6.sh
Last active May 2, 2024 14:32
Forwarding IPv4 Ports to IPv6 Hosts
#!/bin/bash
# UDP:
socat UDP4-LISTEN:5683,fork,su=nobody UDP6:[aaaa::212:4b00:615:a1f7]:5683
# TCP:
socat TCP4-LISTEN:22,fork,su=nobody TCP6:[2a01:198:79d:1::8]:22
# UDP, IPv6
socat UDP6-LISTEN:5683,fork,su=nobody UDP6:[aaaa::212:4b00:615:a1f7]:5683
@dmazzer
dmazzer / index.html
Created January 6, 2016 00:46 — forked from anonymous/index.html
SVG Examples // source https://jsbin.com/kunesu
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<meta charset="utf-8">
<link href='https://fonts.googleapis.com/css?family=Quicksand' rel='stylesheet' type='text/css'>
<title>SVG Examples</title>
<style id="jsbin-css">
.textStyle1 {
font-size: 1em;