Skip to content

Instantly share code, notes, and snippets.

View casallas's full-sized avatar

Juan Sebastián Casallas casallas

  • Iowa State University, Arts et Métiers ParisTech
  • Chalon-sur-Saône, France
View GitHub Profile
@casallas
casallas / helloandroid.md
Created May 11, 2015 21:21
HelloAndroid

If you get the following error

The following classes could not be instantiated: - android.support.v7.internal.widget.ActionBarOverlayLayout

Then set res/values/styles.xml to:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
@casallas
casallas / rep_rowR.md
Last active September 21, 2020 21:03
Repeating rows in R
@casallas
casallas / knitr_xcolor_output.log
Last active August 29, 2015 14:17
knitr_xcolor_output
> knitr::knit("xcolor_error.Rnw")
processing file: xcolor_error.Rnw
|...................... | 33%
ordinary text without R code
|........................................... | 67%
label: unnamed-chunk-1 (with options)
List of 1
@casallas
casallas / det_test_font_tex.md
Created March 25, 2015 15:16
Detecting and testing font in LaTeX
@casallas
casallas / under_subs.md
Created March 24, 2015 21:18
Underlined subscript LaTeX

For some reason the following generates some errors in LaTeX (even though the output is correct)

$S_\underline{0}$

My solution was to enclose the underline statement within \mathrm

$S_\mathrm{\underline{0}}$
@casallas
casallas / sentence_case.tex
Created March 20, 2015 05:12
Convert string to sentence case in LaTeX
\usepackage{stringstrings} % \capitalize, \caselower
\newcommand{\sentencecase}[1]{\caselower[e]{#1}\capitalize{\thestring}}
@casallas
casallas / pub-bib.md
Last active September 6, 2021 20:47
Publishing clean bibtex files

These tricks require BibTool, which can be installed using homebrew.

To extract only the used fields call bibtool -x on a .aux file, e.g.

bibtool -x doc.aux -o output.bib

To delete fields that you don't want to share, e.g. notes and file locations,

bibtool -- "delete.field {annote}" -i input.bib -o output.bib
@casallas
casallas / iipp.R
Last active August 29, 2015 14:13
||++ for R
# return a if a is defined and not null, otherwise return b
`%|%` <- function(a, b){
try({
if(!is.null(eval(substitute(a))))
return(a)
}, silent=TRUE);
b
}
# assign b to a if a is undefined or null, compare to ruby's ||=
@casallas
casallas / rexex_ex.md
Last active August 29, 2015 14:13
ag/ack/atom regex example

Suppose you want to change the following

original new
a \ttimes b -> =
a \\ttimes b -> =
a_2 \ttimes b -> a_2 \btimes b
a_2 \\ttimes b -> a_2 \\btimes b
a_{2} \ttimes b -> a_{2} \btimes b
a_{2} \\ttimes b -&gt; a_{2} \\btimes b
@casallas
casallas / pipe_qplot_benchmark.R
Created December 31, 2014 04:06
A small benchmark to compare the 'ans' and 'with' forms of 'freduce'
library(microbenchmark) # microbenchmark
library(pryr) # mem_used
library(ggplot2) # qplot
devtools::dev_mode(T)
benchmark_pipe_qplot <- function(x){
library(magrittr)
print(mem_used())
cat("------\n")