Skip to content

Instantly share code, notes, and snippets.

View mikbuch's full-sized avatar
🔋
Positive energy!

Mikolaj Buchwald mikbuch

🔋
Positive energy!
View GitHub Profile
@mikbuch
mikbuch / mass_rename.sh
Last active April 1, 2019 07:02
Rename several file based on the substring each of them contains.
#!/bin/bash
# Takes all files within current directory and replaces one substring with
# another. This functionality is missing from standard linux shell (maybe
# it is possible to achieve with some complex awk command with regex, but
# I'd prefer to have a plain command for this).
#
#
# e.g. files:
#
int button1 = 11;
int button2 = 12;
int led1 = 7;
int led2 = 6;
void setup() {
Serial.begin(9600);
pinMode(button1, INPUT);
pinMode(led1, OUTPUT);
pinMode(button2, INPUT);
import serial
# Source: https://pyserial.readthedocs.io/en/latest/shortintro.html#opening-serial-ports
# Additional info:
# * you have to install pyserial in order for this code to work, command `sudo pip install serial`
# * run this script with sudo: `sudo python read_serial.py`
with serial.Serial('/dev/ttyUSB0', 9600, timeout=1) as ser:
while True:
# read a '\n' terminated line
@mikbuch
mikbuch / .zshrc
Created February 16, 2019 23:08
My zsh configuration file: antigen + oh-my-zsh + clean theme
source ~/antigen.zsh
# Load the oh-my-zsh's library.
antigen use oh-my-zsh
# Bundles from the default repo (robbyrussell's oh-my-zsh).
antigen bundle git
antigen bundle heroku
antigen bundle pip
antigen bundle lein
@mikbuch
mikbuch / print-resultset.java
Last active November 18, 2020 04:07 — forked from jimjam88/print-resultset.java
Print an ResultSet to the console (STDOUT)
// Imports required
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
/**
* Print a result set to system out.
*
* @param rs The ResultSet to print
* @throws SQLException If there is a problem reading the ResultSet
@mikbuch
mikbuch / workbench_volume_to_surface-multiple_files.py
Last active December 6, 2019 17:02
Script to automatize mapping neuroimaging data from volumes (NIfTI) to brain surface (workbench).
import os
import re
import subprocess as sp
import argparse
'''
Script to automatize mapping neuroimaging data from volumes (NIfTI) to brain
surface (workbench). This script is dedicated for multiple files. The simplified
version of this script, for single NIfTI file is available here:
https://gist.github.com/mikbuch/fb28aef0f77c7c7aeeff92a61b109d16