Skip to content

Instantly share code, notes, and snippets.

View dmikushin's full-sized avatar
🤓

Dmitry Mikushin dmikushin

🤓
View GitHub Profile
@dmikushin
dmikushin / rootfs.cpio.scripts.local.patch
Created May 13, 2021 21:14
FriendlyElec NanoPi Duo2 make SD card readonly with temporary ramdisk overlay, in order to avoid filesystem corruption
--- a/scripts/local 2019-10-17 07:29:20.000000000 +0200
+++ b/scripts/local 2021-05-12 20:30:38.000000000 +0200
@@ -198,56 +198,10 @@
local_mount_overlay()
{
- # Test (mmc) block device
- [ -b "${USERDATA%p*}" ] && \
- [ -b "${USERDATA}" ] || return
-
@dmikushin
dmikushin / Makefile
Created March 23, 2021 12:19
CUDA device function address retrieval from a PTX jump table, which shows that the address is just a relative offset
all: jumptable
jumptable.cubin: jumptable.ptx
nvcc -arch=sm_61 $< -cubin
jumptable: jumptable.cu jumptable.cubin
nvcc -arch=sm_61 $< -o $@ -lcuda
clean:
rm -rf jumptable jumptable.cubin
@dmikushin
dmikushin / jupyter-create.sh
Created April 30, 2020 13:02
Jupyter deployment scripts
#!/bin/bash
echo "Creating Jupyter environment in" $(pwd)
python3 -m venv ./.venv
sh -c "source .venv/bin/activate && pip3 install --upgrade pip && pip3 install jupyter && ipython kernel install --user --name=.venv"
echo "Created Jupyter environment in" $(pwd)
@dmikushin
dmikushin / decode.pl
Created January 25, 2020 08:11
Batch-decode a list of *.MKV videos into *.WEBM (VP9) with deinterlace filter, using multiple parallel instances of FFmpeg
#!/usr/bin/perl -w
#
# Batch-decode a list of *.MKV videos into *.WEBM (VP9) with deinterlace filter,
# using multiple parallel instances of FFmpeg.
#
use threads;
# XXX The number of parallel threads to use.
my($nthreads) = 8;
@dmikushin
dmikushin / pthread_hook.c
Last active January 11, 2020 02:06
Assign threads to individual cores on Linux
// gcc pthread_hook.c -shared -o libpthread_hook.so
// LD_PRELOAD=./libpthread_hook.so ./test_app
#define _GNU_SOURCE
#include <sched.h> // cpu_set_t, CPU_SET
#include <dlfcn.h>
#include <errno.h> // EINVAL
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
Welcome to minicom 2.7.1
OPTIONS: I18n
Compiled on Aug 13 2017, 15:25:34.
Port /dev/ttyUSB0, 16:52:51
Press CTRL-A Z for help on special keys
DDR Version 1.15 20181010
In
@dmikushin
dmikushin / gist:5d762745573361d0c923d6aacc904ecb
Created January 7, 2020 07:37
NanoPI initrd boot failure
Welcome to Ubuntu 19.10!
[ 7.111555] systemd[1]: Failed to bump fs.file-max, ignoring: Invalid argument
[ 7.149252] systemd[1]: File /lib/systemd/system/systemd-journald.service:12 configures an IP firewall (IPAddressDeny=any), but the local system does not support BPF/cgroup.
[ 7.150764] systemd[1]: Proceeding WITHOUT firewalling in effect! (This warning is only shown for the first loaded unit using IP firewalling.)
[ 7.165346] systemd[1]: /lib/systemd/system/dbus.socket:4: ListenStream= references a path below legacy directory /var/run/, updating /var/run/dbus/system_bus_socket ��→ /r.
[ 7.194813] random: systemd: uninitialized urandom read (16 bytes read)
[ 7.195455] systemd[1]: Reached target Remote File Systems.
[ OK ] Reached target Remote File Systems.
[ 7.210891] random: systemd: uninitialized urandom read (16 bytes read)
@dmikushin
dmikushin / timing.h
Created October 12, 2019 18:51
Old-style high-resolution timing function that avoids problems of <chrono> https://stackoverflow.com/questions/37426832/what-are-the-uses-of-stdchronohigh-resolution-clock
#ifndef TIMING_H
#define TIMING_H
#if defined(_WIN32)
#define CLOCK_REALTIME_WIN32 0
#include <windows.h>
struct timespec_win32
{
@dmikushin
dmikushin / 0001-Make-Alpine-2.21-to-bounce-all-selected-messages.patch
Created September 13, 2017 00:29
Make Alpine 2.21 to bounce all selected messages
From b4a79a41f995b27038011f92f0da3c6852a8596c Mon Sep 17 00:00:00 2001
From: Dmitry Mikushin <dmitry@kernelgen.org>
Date: Wed, 13 Sep 2017 03:28:26 +0300
Subject: [PATCH] Make Alpine 2.21 to bounce all selected messages
---
alpine/mailcmd.c | 5 -----
alpine/reply.c | 12 ++++++------
2 files changed, 6 insertions(+), 11 deletions(-)
JNIEXPORT jobject JNICALL Java_..._getValue(
JNIEnv *env, jobject ...)
{
...
jobject resultObj = result.toJava().getObject();
return resultObj; // Not NULL!
}
// Log shows: