Skip to content

Instantly share code, notes, and snippets.

View humbdrag's full-sized avatar

Humbled Drugman humbdrag

View GitHub Profile
@humbdrag
humbdrag / medium_logging_pkg.py
Created January 12, 2022 02:47
[Medium] Python logging setup in package
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.NullHandler())
@humbdrag
humbdrag / medium_logging_app.py
Created January 12, 2022 02:49
[Medium] Python logging setup application
# Set up logging directory and create logging file.
os.makedirs(log_path, exist_ok=True)
log_file = os.path.join(log_path, f'{datetime.date.today()}.log')
if os.path.exists(log_file):
append_write = 'a' # append if already exists
else:
append_write = 'w' # make a new file if not
# Setup up logging configuration.
root_logger = logging.getLogger()
@humbdrag
humbdrag / eda_meg_setup.sh
Last active January 13, 2022 11:10
Setup for MEG EDA
# Create and activate virtual environment
# ...
# Install MNE with sample datasets and 2D plotting capability
pip install mne mne[data] matplotlib pandas
@humbdrag
humbdrag / load_sample_data.py
Created January 13, 2022 11:04
Load a sample MEG dataset
import os
import mne
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(
sample_data_folder, 'MEG', 'sample', 'sample_audvis_filt-0-40_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file)
@humbdrag
humbdrag / meg_raw_to_df.py
Last active January 13, 2022 11:27
Convert MNE MEG Raw to dataframe
all_data = raw.to_data_frame()
all_data
@humbdrag
humbdrag / meg_get_chs.py
Created January 13, 2022 11:37
Get channel information
import pandas as pd
pd.DataFrame(raw.info.get('chs'))
@humbdrag
humbdrag / fetch_remote_branch.sh
Created January 16, 2022 19:31
Fetch remote branch
git remote add csabella git@github.com:csabella/cpython.git
git fetch csabella
git switch -c bpo-12067 csabella/compare
@humbdrag
humbdrag / btc_core_cfg.conf
Last active January 17, 2022 21:58
bitcoin core config file
# server=1 tells Bitcoin-Qt and bitcoind to accept JSON-RPC commands
server=1
# Listen for RPC connections on this TCP port:
rpcport=8332
# You can use Bitcoin or bitcoind to send commands to Bitcoin/bitcoind
# running on another host using this option:
rpcconnect=127.0.0.1
@humbdrag
humbdrag / btc_gen_rpcauth.sh
Created January 17, 2022 22:18
generate rpcauth
git clone git@github.com:bitcoin/bitcoin.git
cd bitcoin/share/rpcauth
rpcauth.py [Your Username] [Your Password]
@humbdrag
humbdrag / btc_min_rpc.py
Created January 17, 2022 22:40
BTC Minimal RPC
import base64
import json
import random
import urllib.request
import urllib.error
import urllib.parse
# Define parameters for the RPC.
parameters = {
"host": "127.0.0.1",