Skip to content

Instantly share code, notes, and snippets.

Avatar
🔋
Full of energy!

Mikolaj Buchwald mikbuch

🔋
Full of energy!
View GitHub Profile
@mikbuch
mikbuch / workbench_volume_to_surface-multiple_files.py
Last active Dec 6, 2019
Script to automatize mapping neuroimaging data from volumes (NIfTI) to brain surface (workbench).
View workbench_volume_to_surface-multiple_files.py
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
@mikbuch
mikbuch / print-resultset.java
Last active Nov 18, 2020 — forked from jimjam88/print-resultset.java
Print an ResultSet to the console (STDOUT)
View print-resultset.java
// 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 / .zshrc
Created Feb 16, 2019
My zsh configuration file: antigen + oh-my-zsh + clean theme
View .zshrc
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
View read_serial.py
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
View buttons_kogniliada.ino
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);
@mikbuch
mikbuch / mass_rename.sh
Last active Apr 1, 2019
Rename several file based on the substring each of them contains.
View mass_rename.sh
#!/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:
#
View mediation_analysis.R
message("\n")
message("############################################")
message("# Mediation analysis example #")
message("############################################")
message("\n")
message(" + Import packages\n")
library('mediation')
# For Sobel filter:
library('multilevel')
@mikbuch
mikbuch / JupyterHub_prerequisites.sh
Created Jun 17, 2019
Packages that are required in order to run JupyterHub
View JupyterHub_prerequisites.sh
# Standard system upgrade:
sudo apt-get update
sudo apt-get upgrade -y
# Nodejs installation on debian (source (here)[https://tecadmin.net/install-laatest-nodejs-npm-on-debian/]):
sudo apt-get install curl software-properties-common
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
sudo apt-get install -y nodejs nodejs-legacy
# Installing the Jupyter itself:
View workbench_volume_to_surface.py
import argparse
import re
import subprocess as sp
'''
Script to automatize mapping neuroimaging data from volumes (NIfTI) to brain
surface (workbench).
Edit data: 2021-04-28
Author: Mikolaj Buchwald, mikolaj.buchwald@gmail.com
@mikbuch
mikbuch / LEDControlServer.ino
Last active Jul 30, 2022
ESP8266 microchip is used to host a web server. This way we can control ESP's LED diode by turning it on or off with a web request, e.g., "http://192.168.0.16/switch".
View LEDControlServer.ino
// This script is avilable as gist:
// https://gist.github.com/mikbuch/212cfb7365703caf517aa83642d10d91
/* Requirements:
* * "esp8266" board installed.
*
* In order to install the board, go to:
* -- Tools => Board => Boards Manager => Install "esp8266"
* It also includes "Wemos" boards ("LOLIN").
*