Skip to content

Instantly share code, notes, and snippets.

@gzagatti
gzagatti / sh
Last active Nov 12, 2016
Installing Fiona and Basemap with Anaconda in Linux
View sh
# `Fiona` and `Basemap` have conflicting `libgdal` dependencies.
# To solve the issue the `libgdal` version has to be fixed to version `2.0.0=0`.
conda install -c conda-forge fiona=1.7.0
conda install gdal basemap libgdal=2.0.0=0
conda install krb5
conda install shapely
pip install geopandas
pip install rasterio
conda install -c conda-forge fiona=1.7.0
@gzagatti
gzagatti / gista.md
Last active Mar 14, 2017
Removing and Purging Files from Git History
View gista.md

Rewriting history in git

From Removing and purging files from git history

Remove directories added to .gitignore

To remove files which have been recently added to .gitignore.

git ls-files --ignored --exclude-standard | xargs git rm --cached
@gzagatti
gzagatti / docker_decktape.md
Last active May 5, 2017
Using decktape docker image on a Mac
View docker_decktape.md

Decktape offers a Docker image in order to run their presentation converter. If you want to convert a presentation from an instance running on localhost on a Mac, it is necessary to do some work around.

Decktape's Github Page suggests that we run the following command to save a presentation deployed locally:

>> docker run --rm --net=host -v `pwd`:/slides astefanutti/decktape http://localhost:8000 slides.pdf

However when running the docker from a Mac, Docker is actually running behind a virtual machine and has no access to the localhost. Thus the option --net=host leads to a connection refused error.

@gzagatti
gzagatti / testing_shell.sh
Last active Jun 9, 2017
'Testing exit values in the shell.'
View testing_shell.sh
failure() {
return 1
}
success() {
return 0
}
success
RET_SUCESS=$?
@gzagatti
gzagatti / selecting_dependencies_conda.sh
Created Aug 2, 2017
'Select all the dependencies of a conda package using jq.'
View selecting_dependencies_conda.sh
conda info --json r-essentials | jq -r ' ."r-essentials"[] | select(.version == "1.5.2" and .build == "r3.3.2_0") | .depends[] '
@gzagatti
gzagatti / uninstall_conda_package_and_dependencies.sh
Created Aug 2, 2017
Uninstall a conda package and its dependencies.
View uninstall_conda_package_and_dependencies.sh
conda info --json r-essentials | jq -r ' ."r-essentials"[] | select(.version == "1.5.2" and .build == "r3.3.2_0") | .depends[] ' | awk '{print $1;}' | grep -E '^r-' | xargs -J {} conda uninstall {}
@gzagatti
gzagatti / spss_to_csv.r
Created Aug 3, 2017
Converting a list of SPSS files (.sav) to CSV using magrittr
View spss_to_csv.r
library('magrittr')
library('memisc')
# get all .sav files from directory
files <- list.files('.', pattern='.sav$', recursive=FALSE)
# get the dataframes
dfs <- list.files('.', pattern='.sav$', recursive=FALSE) %>%
lapply(spss.system.file) %>%
lapply(as.data.set) %>%
@gzagatti
gzagatti / pyenv.md
Last active Jan 30, 2018
Installing python with pyenv
View pyenv.md

pyenv was failing to install python due the inexistence of the pyexpat library.

In order to solve this problem, I upgraded brew, installed and uninstalled openssl with brew and installed the HEAD version of pyenv.

Before installing the required python versions I exported the following flags:

CFLAGS="-I$(brew --prefix openssl)/include"
LDFLAGS="-L$(brew --prefix openssl)/lib"
@gzagatti
gzagatti / pr-assignee
Last active Feb 1, 2018
Find all pull-requests in Github assigned to user.
View pr-assignee
is:open is:pr assignee:<username>
@gzagatti
gzagatti / git_file_size.md
Last active Feb 1, 2018
'Finding Big Files From Git History'
View git_file_size.md

Source

Finding Big Files From Git History

On a recent grails project, we're using a git repo that was originally converted from a SVN repo with a ton of large binary objects in it (lots of jar files that really should come from an ivy/maven repo). The .git directory was over a gigabyte in size and this made it very cumbersome to clone and manipulate.

We decided to leverage git's history rewriting capabilities to make a much smaller repository (and kept our previous repo as a backup just in case).

Here are a few questions/answers that I figured out how to answer with git and some shell commands: