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 / .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:
@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 / SVLibSVM.java
Last active August 14, 2020 13:43 — forked from DavidWiesner/SVLibSVM.java
Access support vector in LibSVM and Weka
import weka.classifiers.functions.LibSVM;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.SelectedTag;
import libsvm.svm_model;
import java.io.BufferedReader;
import java.io.FileReader;
import java.lang.reflect.Field;
from psychopy import visual, core, event
win = visual.Window([400,400])
win.flip()
while True:
keys = event.getKeys()
if 'q' in keys:
core.quit()
@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