Skip to content

Instantly share code, notes, and snippets.

View dmikushin's full-sized avatar
🤓

Dmitry Mikushin dmikushin

🤓
View GitHub Profile
@dmikushin
dmikushin / bzr2git.sh
Created November 8, 2024 10:38
Simple Bzr to Git repository converter
#!/bin/bash
for rev in $(bzr log | grep '^revno:' | awk '{print $2}' | tac); do
bzr revert -r $rev
committer=$(bzr log -v -r$rev | grep "committer:.*" | sed "s/committer:\s*//g")
timestamp=$(bzr log -v -r$rev | grep "timestamp:.*" | sed "s/timestamp:\s*//g")
commit_message=$(bzr log -v -r$rev | sed -ne "N;s/message:\s*\n/message:/;P;D" | grep "message:.*" | sed "s/message:\s*//g")
git add .
git commit --author="$committer" --date="$timestamp" -m "$commit_message"
done
@dmikushin
dmikushin / Makefile
Created October 22, 2024 09:26
OpenMP status tests
all: test1 test2 test3
test1: openmp_check_enabled.c
gcc $< -o $@ && ./test1
test2: openmp_check_enabled.c
gcc -fopenmp $< -o $@ && ./test2
test3: openmp_check_enabled.c
gcc -fopenmp $< -o $@ && OMP_NUM_THREADS=1 ./test3
@dmikushin
dmikushin / matrix_as_graph.ipynb
Created January 29, 2024 16:48 — forked from V0XNIHILI/matrix_as_graph.ipynb
Matrix multiplication in graph form
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dmikushin
dmikushin / cppminify.py
Created January 2, 2024 12:24
Minify C++ code
import re
import sys
def minify_cpp_code(code):
# Remove comments:
# Turn single-line comments into multi-line comments
code = re.sub(re.compile(r'//(.*?)\n'), '/*\\1*/', code)
# Remove multi-line comments
code = re.sub(re.compile(r'/\*.*?\*/', re.DOTALL), '', code)
# Preprocessing directives must remain on separate lines.
@dmikushin
dmikushin / README.md
Created December 18, 2023 09:43
Example of using .branchtargets in PTX

Example of using .branchtargets in PTX

This code snippet demonstrates how to jump to a label by its index with brx.idx instruction.

Unlike the regular if (a == 2) { ... } else { ... } code (as well as switch (...) { ... }), the brx.idx solution avoids multiple setp.ne.s32 comparisons.

Building

> make
@dmikushin
dmikushin / match_nested.py
Created December 4, 2023 14:34
A simple python program showing how to use regular expressions to write a paren-matching recursive parser.
"""
A simple python program showing how to use regular
expressions to write a paren-matching recursive parser.
This parser recognises items enclosed by parens, brackets,
braces and <> symbols, but is adaptable to any set of
open/close patterns. This is where the re package greatly
assists in parsing.
Published by Gene Olson at
@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 ***"