Skip to content

Instantly share code, notes, and snippets.

View janpipek's full-sized avatar
🤔
...

Jan Pipek janpipek

🤔
...
View GitHub Profile
@janpipek
janpipek / sublime_load_package.py
Last active August 29, 2015 13:56
Load python package in sublime (version 2/3)
#!/usr/bin/env python
import sys
import pkgutil
import os
if len(sys.argv) != 2:
print("Usage: sublime_load.py <package-name>")
else:
package = sys.argv[1]
loader = pkgutil.find_loader(package)
@janpipek
janpipek / autoreload.py
Created July 29, 2014 13:29
autoreload in IPython
%load_ext autoreload
%aimport module_to_be_reload # Select modules to be reloaded
%autoreload 1 # Set that we want only the listed modules
@janpipek
janpipek / auto_git.rb
Last active August 29, 2015 14:05
Check git status before doing something and auto-tag
def ask
print "Do you want to continue? (y/N) "
answer = STDIN.gets.strip.downcase
if answer != "y"
return false
end
return true
end
def get_branch
@janpipek
janpipek / use_plat_linux.sh
Created August 31, 2014 10:28
Include platform-necessary Python modules to virtual env (Fedora)
add2virtualenv /usr/lib64/python2.7/plat-linux2/
@janpipek
janpipek / my_loadtxt.py
Last active August 29, 2015 14:06
Load numpy array from a long text file
def my_loadtxt(fname, columns=-1, delimiter=',', dtype='float32'):
with open(fname) as f:
if columns == -1:
line = f.readline()
columns = np.fromstring(line, sep=delimiter).shape[0]
f.seek(0)
rows = 0
for line in f:
rows += 1
f.seek(0)
@janpipek
janpipek / hdftree.py
Last active August 29, 2015 14:06
Quickly show HDF5 tree using pydons
#!/usr/bin/env python
import pydons
import sys
def _wrap_with(code):
def inner(text, bold=True):
c = code
if bold:
c = "1;%s" % c
return "\033[%sm%s\033[m" % (c, text) # '\033[m'
@janpipek
janpipek / small_case_file_names.rb
Created November 8, 2014 08:21
Turn all file names to small case
#!ruby
# Simple script to change all the file names in current directory to small case
require 'fileutils'
Dir.foreach(".") do |fn|
n = fn.downcase
if n != fn
FileUtils.mv(fn, n)
end
@janpipek
janpipek / anaconda.sh
Created November 11, 2014 08:35
"workon" for anaconda
function anaconda {
# Added by Anaconda 2.1.0 installer
export PATH="/opt/anaconda/bin:$PATH"
# Fix to use pure anaconda Qt
export QT_PLUGIN_PATH="/opt/anaconda/plugins"
}
function workon {
echo "Initializing anaconda..."
@janpipek
janpipek / run-all-notebooks.sh
Created November 22, 2014 13:34
Run all ipython notebooks in a directory
#!/bin/bash
# pip install runipy
find . -maxdepth 1 -name "*ipynb" -print0 | xargs -0 -n1 runipy
@janpipek
janpipek / normostrany.vba
Last active August 29, 2015 14:17
Makro pro zobrazení počtu normostran ve Wordu
Sub Normostrany()
Dim Title As String
Dim CharCount As Long
Dim Message As String
Dim Pages As Double
CharCount = ActiveDocument.BuiltInDocumentProperties("Number of characters (with spaces)")
Pages = CharCount / 1800#
Title = "Počet normostran"