Skip to content

Instantly share code, notes, and snippets.

View macoj's full-sized avatar

Marcos Oliveira macoj

View GitHub Profile
@macoj
macoj / ipcluster.sh
Created May 21, 2018 10:42
setting which python to use with ipcluster
/usr/bin/python2.7 `which ipcluster` start -n 40
# or
/usr/bin/python3 `which ipcluster` start -n 40
@macoj
macoj / git_submodules.sh
Created May 21, 2018 10:32
git clone with the submodules
$ git clone --recurse-submodules https://github.com/macoj/rep
@macoj
macoj / compiling_graph_tool.md
Last active April 3, 2018 12:58
the long and winding road to compile boost + graph-tool

create a common directory for zlib and bzip2

mkdir common

build zlib

wget http://downloads.sourceforge.net/project/libpng/zlib/1.2.10/zlib-1.2.10.tar.xz
tar xaf zlib-1.2.10.tar.xz
cd zlib-1.2.10/
./configure
make test
@macoj
macoj / git_submodule.sh
Last active December 20, 2017 15:11
Updating submodule in git
# add a submodule in a repository:
git submodule add https://github.com/<user>/submodule_name
# update the submodule
cd submodule_name
git checkout master
git pull
cd ..
git add submodule_name
git commit -m "Updating submodule to latest"
@macoj
macoj / hello_twitter.py
Last active October 10, 2017 23:43
Just a hello to Twitter API
"""
this code is here: http://tinyurl.com/hello-network
Twitter libraries:
https://dev.twitter.com/overview/api/twitter-libraries
Twitter Python library:
https://github.com/sixohsix/twitter
$ sudo pip2.7 install twitter
@macoj
macoj / fonts_matplotlib.md
Created February 5, 2017 15:49
Fonts in matplotlib

Before fonts in matplotlib make you crazy again, remember:

  1. After installing a font in the system, you need to remove the cache:
~/.cache/matplotlib/fontList.cache
  1. If you using Ubuntu, you might need to install Vera
sudo apt-get install ttf-bitstream-vera 
@macoj
macoj / shade_color.md
Last active December 21, 2016 20:30
darker color, brighter color, same hue

Sometimes I want a color just brighter or darker:

def shade_color(hex_color, offset):
    new_color = hex_color
    if len(hex_color) in [6, 7]:
        if hex_color[0] == "#":
            hex_color = hex_color[1:]
        rgb_hex = np.array([float(int(hex_color[x:x+2], 16)) for x in [0, 2, 4]])
 rgb_hex /= 255.0
@macoj
macoj / bye_blurry.md
Last active November 23, 2016 23:11
Removing the blurry effect on embedded images in .svg when exporting to .pdf in InkScape (or similar)

Removing the blurry effect on embedded images in .svg when exporting to .pdf

Open the pdf generated and:

  1. Remove /Interpolate true from the pdf.

  2. Change /SMask 63 0 R to /SMask 13 0 R

@macoj
macoj / colorblind_palette.md
Last active November 23, 2016 18:45
colorblind palette

Colorblind palette!

Colors from From: Wong, Bang. "Points of view: Color blindness." Nature methods 8.6 (2011): 441-441. in RGB:

color_names = ["Black", "Orange", "Sky blue", "Bluish green", "Yellow", "Blue", "Vermillion", "Reddish purple"]
colors_colorblind_safe = [(0, 0, 0), (230, 159, 0), (86, 180, 233), (0, 158, 115), (240, 228, 66), (0, 114, 178), (213, 94, 0), (204, 121, 167)]
colors_colorblind_safe = ['#%02x%02x%02x' % (c[0], c[1], c[2]) for c in colors_colorblind_safe]
colors = dict(zip(color_names, colors_colorblind_safe))
three_colors = colors['Blue'], colors['Vermillion'], colors['Bluish green']
@macoj
macoj / symbols.tex
Created November 22, 2016 15:48
symbols of all types in latex
%http://www.ctan.org/tex-archive/info/symbols/comprehensive/symbols-a4.pdf
\usepackage{latexsym} % needs this to have on latex2e
$\bullet$