Skip to content

Instantly share code, notes, and snippets.

View un1tz3r0's full-sized avatar
😵
Distracted

Victor Condino un1tz3r0

😵
Distracted
View GitHub Profile
@un1tz3r0
un1tz3r0 / journal-reactor.py
Created May 8, 2024 20:46 — forked from leoluk/journal-reactor.py
Example code that demonstrates how to listen to journald using Python 3 + asyncio.
#!/usr/bin/python3 -u
import asyncio
import sh
from systemd import journal
from systemd.daemon import notify
GATEWAY_IP = "192.168.10.1"
@un1tz3r0
un1tz3r0 / exec_notify.py
Created February 17, 2022 18:16 — forked from drdaeman/exec_notify.py
Listening to Netlink process events on x86_64 Linux systems (kludgy)
#!/usr/bin/env python
import socket
import os
import struct
if getattr(socket, "NETLINK_CONNECTOR", None) is None:
socket.NETLINK_CONNECTOR = 11
CN_IDX_PROC = 1
@un1tz3r0
un1tz3r0 / for_each_args.cpp
Created May 20, 2021 10:48 — forked from elbeno/for_each_args.cpp
Functions that work over their arguments
//------------------------------------------------------------------------------
// A function that will apply a function to each argument
#include <initializer_list>
#include <utility>
template <typename F, typename... Ts>
void for_each_arg(F&& f, Ts&&... ts)
{
using I = std::initializer_list<int>;
(void) I { (std::forward<F>(f)(std::forward<Ts>(ts)), 0)... };
@un1tz3r0
un1tz3r0 / catmullFitter.js
Created February 17, 2021 23:48 — forked from nicholaswmin/catmull-rom.js
Catmull Rom Fitting Algorithm in Javascript through a series of X/Y Points
/**
* Interpolates a Catmull-Rom Spline through a series of x/y points
* Converts the CR Spline to Cubic Beziers for use with SVG items
*
* If 'alpha' is 0.5 then the 'Centripetal' variant is used
* If 'alpha' is 1 then the 'Chordal' variant is used
*
*
* @param {Array} data - Array of points, each point in object literal holding x/y values
* @return {String} d - SVG string with cubic bezier curves representing the Catmull-Rom Spline
@un1tz3r0
un1tz3r0 / bookmarklet.js
Created April 10, 2019 06:10 — forked from ctesta01/bookmarklet.js
take me to a random url – a js bookmarklet
javascript:(function(){var links = [
"https://en.wikipedia.org/wiki/Special:Random",
"https://en.wikipedia.org/wiki/Portal:Current_events",
"http://mathworld.wolfram.com/",
"http://functions.wolfram.com/",
"https://en.wikipedia.org/wiki/Portal:Contents/Outlines",
"https://en.wikipedia.org/wiki/Glossary_of_areas_of_mathematics",
"http://mathworld.wolfram.com/classroom/",
"https://en.wikipedia.org/wiki/Lists_of_mathematics_topics",
"https://en.wikipedia.org/wiki/Mathematics_Subject_Classification#First-level_areas",
@un1tz3r0
un1tz3r0 / main.py
Created April 7, 2019 04:58 — forked from gear11/main.py
Simple Python proxy server based on Flask and Requests. See: http:/python-proxy-server/gear11.com/2013/12/python-proxy-server/
"""
A simple proxy server. Usage:
http://hostname:port/p/(URL to be proxied, minus protocol)
For example:
http://localhost:8080/p/www.google.com
"""
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 30 18:55:13 2014
Just intonation classes for music theory experiments in Python
"""
from __future__ import division, print_function
from fractions import gcd as _gcd
from fractions import Fraction
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
import numpy as np
from math import pi, log
import pylab
from scipy import fft, ifft
from scipy.optimize import curve_fit
i = 10000
x = np.linspace(0, 3.5 * pi, i)
y = (0.3*np.sin(x) + np.sin(1.3 * x) + 0.9 * np.sin(4.2 * x) + 0.06 *
np.random.randn(i))