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 / 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
@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 / .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
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
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 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:
#
@mikbuch
mikbuch / mediation_analysis.R
Last active April 19, 2019 21:31
WTAD task
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 June 17, 2019 21:01
Packages that are required in order to run JupyterHub
# 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:
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 July 30, 2022 11:30
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".
// 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").
*