Skip to content

Instantly share code, notes, and snippets.

View macoj's full-sized avatar

Marcos Oliveira macoj

View GitHub Profile
@macoj
macoj / bold_figure.md
Last active June 5, 2020 14:32
Having a bold Fig. in figure caption in REVTex4-1

To have a Fig. 1. instead of Fig. 1. when using REVTex4-1, since caption does not work with this class.

\makeatletter
\renewcommand*{\fnum@figure}{{\normalfont\bfseries \figurename~\thefigure}}
\makeatother
@macoj
macoj / mac_home_key.md
Created March 9, 2019 12:23
mac home key

From https://damieng.com/blog/2015/04/24/make-home-end-keys-behave-like-windows-on-mac-os-x:

I’ve been using Mac OS X daily since 2001 when I purchased my Titanium PowerBook and I still can’t get used the home and end key behavior. If, like me, you want Home to send you to the start of the line and not to the top of the document then create a file called DefaultKeyBinding.dict in your ~/Library/KeyBindings folder (might need to create that folder too) with the following contents:

{
  "\UF729"  = moveToBeginningOfParagraph:; // home
  "\UF72B"  = moveToEndOfParagraph:; // end
 "$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
@macoj
macoj / scientific_notation.py
Created February 24, 2019 20:46
scientific notation matplotlib
ax.yaxis.set_major_formatter(ScalarFormatter(useMathText=True))
ax.ticklabel_format(style='sci', axis='y', scilimits=(0, 2))
@macoj
macoj / n_1.py
Created February 13, 2019 14:54
quick numpy array (n,) to (n,1)
np.arange(0, 10).reshape((-1, 1))
@macoj
macoj / pip.sh
Created February 9, 2019 13:19
pip with multiple python versions
$ python-3.6 -m pip install package
$ python-2.7 -m pip install package
@macoj
macoj / space_cite.tex
Created January 27, 2019 13:20
cite with space
\let\Oldcite\cite
\renewcommand{\cite}[1]{~\Oldcite{#1}}
@macoj
macoj / plos_one
Created December 4, 2018 17:09
PLOS One - number of papers over the years
1,254 results for everything:research 2007
2,735 results for everything:research 2008
4,437 results for everything:research 2009
6,765 results for everything:research 2010. On crime: 9
13,858 results for everything:research 2011. On crime: 17
23,575 results for everything:research 2012. On crime: 36
31,719 results for everything:research 2013. On crime: 62
30,247 results for everything:research 2014. On crime: 64
28,348 results for everything:research 2015. On crime: 88
22,211 results for everything:research 2016. On crime: 75
@macoj
macoj / csvt.md
Created October 1, 2018 12:26
including type in csv file

Use a .csvt with the same file name, including just one line about each column:

"Integer","Real","String"

or

"Integer(6)","Real(5.5)","String(22)"

www.gdal.org/ogr/drv_csv.html

@macoj
macoj / filter.sh
Created September 14, 2018 11:37
Filter some data based on some criteria with awk
#!/bin/bash
bb0=$1
bb1=$2
bb2=$3
bb3=$4
cat data.dat | awk -F '|' -v bb0="$bb0" -v bb1="$bb1" -v bb2="$bb2" -v bb3="$bb3" '$2 > bb0 && $2 < bb1 && $3 > bb2 && $3 < bb3 {print $0}'
@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