Skip to content

Instantly share code, notes, and snippets.

View dmikushin's full-sized avatar
🤓

Dmitry Mikushin dmikushin

🤓
View GitHub Profile
@dmikushin
dmikushin / mkimage_neo3-freebsd.sh
Created April 20, 2023 11:18
Make a FreeBSD bootable sdcard for NanoPi Neo3
#!/bin/bash
#
# Make a FreeBSD bootable sdcard for NanoPi Neo3.
# The idea is to mix an official ROCK64 snapshot with U-Boot for Neo3 board from Armbian project.
# This script is based on the original forum post at
# https://forums.FreeBSD.org/threads/nanopi-neo-3-rockchip-rk3328.76449/post-493043
#
set -e
if [[ $UID != 0 ]]; then
@dmikushin
dmikushin / migrate1.pl
Created January 26, 2023 09:52
Submodules batch migration scripts
# Clone all branches individually
my(@branches) = (
"eskew",
"combinations",
"distributed",
"earnest",
"emax",
"engine-hpc",
"engine-trivial",
@dmikushin
dmikushin / raspberryPiImageAutoShrinker.sh
Created January 24, 2023 14:03 — forked from free5ty1e/raspberryPiImageAutoShrinker.sh
Updated Raspberry Pi image auto shrinker script will shrink the ext4 filesystem down so you can restore the image on a smaller card
#!/bin/bash
# Automatic Image file resizer
# Written by SirLagz
# Fixed 2016.04.17 by @ChrisPrimeish
strImgFile=$1
if [[ ! $(whoami) =~ "root" ]]; then
echo ""
echo "**********************************"
echo "*** This should be run as root ***"
@dmikushin
dmikushin / raspberryPiImageAutoShrinker.sh
Created January 24, 2023 14:03 — forked from free5ty1e/raspberryPiImageAutoShrinker.sh
Updated Raspberry Pi image auto shrinker script will shrink the ext4 filesystem down so you can restore the image on a smaller card
#!/bin/bash
# Automatic Image file resizer
# Written by SirLagz
# Fixed 2016.04.17 by @ChrisPrimeish
strImgFile=$1
if [[ ! $(whoami) =~ "root" ]]; then
echo ""
echo "**********************************"
echo "*** This should be run as root ***"
@dmikushin
dmikushin / android-select-device
Last active September 15, 2021 17:30 — forked from dtmilano/android-select-device
Script to select one connected device or emulator when running ADB
#!/bin/bash
#=====================================================================
# Selects an android device
# Copyright (C) 2012-2020 Diego Torres Milano. All rights reserved.
#
# See:
# - http://dtmilano.blogspot.ca/2013/01/android-select-device.html
# - http://dtmilano.blogspot.ca/2012/03/selecting-adb-device.html
# for details on usage.
#=====================================================================
@dmikushin
dmikushin / earnestrank.cpp
Last active July 2, 2021 09:52
C++ implementation of an algorithm proposed by Mike Earnest on math.stackexchange
// Given all possible combinations of K values, each no greater than M, and whose sum is exactly N
// (zeros and different orderings are accounted, that is 1 + 4 and 4 + 1 are different combinations),
// for the known combination, reconstruct back its index (the order of enumeration does not matter).
//
// C++ implementation of an algorithm proposed by Mike Earnest.
//
// Compile: g++-11 earnestrank.cpp -o earnestrank
// Run: ./earnestrank
//
//
@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;