Skip to content

Instantly share code, notes, and snippets.

@ruxi
ruxi / nbmerge.py
Created November 10, 2016 19:47 — forked from fperez/nbmerge.py
Merge/concatenate multiple IPython notebooks into one.
#!/usr/bin/env python
# Note, updated version of
# https://github.com/ipython/ipython-in-depth/blob/master/tools/nbmerge.py
"""
usage:
python nbmerge.py A.ipynb B.ipynb C.ipynb > merged.ipynb
"""
import io
@ruxi
ruxi / bobp-python.md
Created November 10, 2016 22:15 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@ruxi
ruxi / pyaffy issue #10 .ipynb
Created November 28, 2016 21:37
pyaffy issue 10
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ruxi
ruxi / typeguard issue.ipynb
Created December 2, 2016 20:42
typeguard NamedTuple support
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ruxi
ruxi / download_file.py
Last active February 3, 2024 18:56
python download_file with progressbar using request and tqdm
#!/usr/bin/env python
__author__ = "github.com/ruxi"
__license__ = "MIT"
import requests
import tqdm # progress bar
import os.path
def download_file(url, filename=False, verbose = False):
"""
Download file with progressbar
# Rename all *.fasta to *.sra
for f in *.fasta; do
mv -- "$f" "${f%.fasta}.sra"
done
@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'
@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.
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
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():