Skip to content

Instantly share code, notes, and snippets.

View krpors's full-sized avatar
🇺🇦

Kevin Pors krpors

🇺🇦
View GitHub Profile
@krpors
krpors / main.nim
Created November 20, 2023 21:43
Nim c ffi
# This is just an example to get you started. A typical binary package
# uses this file as the main entry point of the application.
import std/posix
type
Winsize* = object
ws_row*: cushort
ws_col*: cushort
ws_xpixel*: cushort
@krpors
krpors / webcamcruft.sh
Last active October 20, 2022 07:48
Overlay image with webcam using v4l2loopback
#!/usr/bin/env bash
#sudo rmmod v4l2loopback
#sudo modprobe v4l2loopback devices=1 card_label="KEV CAM"
# -vf "drawtext=fontfile=/home/krpors/Development/qualogy/qualogy-revealjs/dist/theme/fonts/source-sans-pro/source-sans-pro-semibolditalic.ttf:text='Tijn sux':fontcolor=white:fontsize=48:box=1:[email protected]:boxborderw=5:x=(w-text_w)/2:y=(h-text_h)/2" \
# pix_fmt yuv420p is required for firefox etc!
ffmpeg \
-i /dev/video0 \
import time
import board
from rainbowio import colorwheel
import neopixel
import random
import touchio
OFF = (0, 0, 0)
RED = (255, 0, 0)
@krpors
krpors / BouncyCastleCertificateGenerator.java
Created September 21, 2021 10:10 — forked from vivekkr12/BouncyCastleCertificateGenerator.java
Generate root X509Certificate, Sign a Certificate from the root certificate by generating a CSR (Certificate Signing Request) and save the certificates to a keystore using BouncyCastle 1.5x
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.BasicConstraints;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.KeyUsage;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.cert.X509v3CertificateBuilder;
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
@krpors
krpors / cycle.sh
Last active May 30, 2020 08:30
inotifywait for cargo
#!/usr/bin/env bash
# Clear the screen, run the initial command in the background immediately,
# and then get the PID. We need that to kill it later (if the program is a
# server/daemon or the like).
${*} &
pid=$!
# Now run inotifywait and only act on certain events, recursively.
# Kill the previous PID (if applicable). Will output an error if the
@krpors
krpors / pix.c
Created July 31, 2018 20:36
segfault with SDL2.0
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <inttypes.h>
#include <time.h>
#include <SDL.h>
@krpors
krpors / expansion.txt
Created November 14, 2016 12:30
Malloc decrease 'report' by using sort of geometric expansion
before:
==27562== Memcheck, a memory error detector
==27562== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==27562== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==27562== Command: ./hx hx
==27562==
==27562==
==27562== HEAP SUMMARY:
==27562== in use at exit: 0 bytes in 0 blocks
@krpors
krpors / gist:7199782
Created October 28, 2013 16:12
Multicast heartbeats etc.
package main
import (
"flag"
"fmt"
"net"
"os"
"time"
)
@krpors
krpors / gist:5354043
Created April 10, 2013 12:08
Calling MessageBoxW in Go
package main
import (
"fmt"
"syscall"
"unsafe"
)
func main() {
fmt.Println("Done!")