Skip to content

Instantly share code, notes, and snippets.

"""gitpath v2, modified
Copyright (c) 2017 github.com/ruxi
Copyright (c) 2015 Maximilian Nöthe
Licensed under the MIT
"""
import subprocess
import os.path
def gitpath(chdir = False):
"""change dirpath to git root directory, or use-rdefined path
@ruxi
ruxi / DictOptions2Combos.py
Last active September 26, 2017 07:08
combinations (tuple of dicts) from possible options (dict with lists)
#!/usr/bin/env python
"""
Author: https://github.com/ruxi
Date Created: Tuesday, 26 Sep 2017
last updated: Tuesday, 26 Sep 2017
Python Version: 3.6
"""
__author__ = "https://github.com/ruxi"
__date_created__ = "Tuesday, 26 Sep 2017"
sudo add-apt-repository ppa:santilli-gabriele/slic3r-prusa
sudo apt-get update
sudo apt install slic3r-prusa
# source
## http://shop.prusa3d.com/forum/original-prusa-i3-mk2-f23/ubuntu-ppa-for-slic3r-prusa-edition-t3042.html
0x0E62556027f7371DA69001b7331039A42D0EB63C
from contextlib import contextmanager
import sys, os
@contextmanager
def suppress_stdout():
"""
source: https://gist.github.com/djsmith42/3956189
usage:
print "You can see this"
with suppress_stdout():
from contextlib import contextmanager
import sys, os
@contextmanager
def suppress_stdout():
with open(os.devnull, "w") as devnull:
old_stdout = sys.stdout
sys.stdout = devnull
try:
yield
@ruxi
ruxi / import_notebook_as_module.ipynb
Last active March 21, 2017 20:34
How to import jupyter notebook V4 (ipynb) as a python module
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ruxi
ruxi / runbash.py
Last active February 20, 2017 05:28
invoke bash commands in python3.6
#!/usr/bin/env python
from __future__ import print_function
__author__ = 'github.com/ruxi'
__license__= 'MIT'
import sys
import os.path
import subprocess
def runbash(cmd, cwd=".", shell=True, logname="runbash.log", ioprint=True):
"""
cmd: bash command to run. example: 'ls -l'
# Rename all *.fasta to *.sra
for f in *.fasta; do
mv -- "$f" "${f%.fasta}.sra"
done