Skip to content

Instantly share code, notes, and snippets.

View rinze's full-sized avatar

José María Mateos rinze

View GitHub Profile
@rinze
rinze / Dockerfile-poc
Last active September 23, 2022 20:10
Files for kaniko issue #2261
FROM ubuntu:18.04
RUN apt-get update \
&& apt-get dist-upgrade -y \
&& apt-get install -y wget gcc g++ redis supervisor libgl1 sudo \
vim less htop \
webp libwebp-dev \
&& apt-get clean
RUN sudo sed -i '/^bind/s/bind.*/bind 0.0.0.0/' /etc/redis/redis.conf
@rinze
rinze / plot_map.R
Created April 18, 2020 16:11
Plot code for https://rinzewind.org/blog-es/2020/donde-estamos.html Not pretty, but it does its job.
library(ggplot2)
theme_set(theme_bw(12))
data1 <- data.frame(location = c(rep(0, 10), 1:100, rep(100, 200), 100:1, rep(0, 10)),
style = 1)
#data1$style[(nrow(data1)-30):nrow(data1)] <- 2
data1$idx <- 1:nrow(data1)
plt1 <- ggplot(data1) + geom_line(aes(x = idx, y = location,
linetype = factor(style)),
@rinze
rinze / python_environment_setup.md
Created September 24, 2018 17:43 — forked from Geoyi/python_environment_setup.md
Setting up your python development environment (with pyenv, virtualenv, and virtualenvwrapper)

Overview

When you're working on multiple coding projects, you might want a couple different version of Python and/or modules installed. That way you can keep each project in its own sandbox instead of trying to juggle multiple projects (each with different dependencies) on your system's version of Python. This intermediate guide covers one way to handle multiple Python versions and Python environments on your own (i.e., without a package manager like conda). See the Using the workflow section to view the end result.

Use cases

  1. Working on 2+ projects that each have their own dependencies; e.g., a Python 2.7 project and a Python 3.6 project, or developing a module that needs to work across multiple versions of Python. It's not reasonable to uninstall/reinstall modules every time you want to switch environments.
  2. If you want to execute code on the cloud, you can set up a Python environment that mirrors the relevant
library(readr)
library(dplyr)
library(ggplot2)
get_first_digit <- function(x) {
return(substr(x, 1, 1))
}
votes <- read_csv("https://github.com/Prooffreader/election_2016_data/raw/master/data/presidential_general_election_2016_by_county.csv")
@rinze
rinze / lineas_rojas.R
Created December 21, 2015 21:37
Generador automático de líneas rojas para partidos políticos.
library(ggplot2)
NLINEAS <- 20
coords <- data.frame(x1 = runif(NLINEAS, 0, 10),
x2 = runif(NLINEAS, 0, 10),
y1 = runif(NLINEAS, 0, 10),
y2 = runif(NLINEAS, 0, 10))
plt1 <- ggplot(coords) + geom_segment(aes(x = x1, xend = x2,
@rinze
rinze / loo_cv_comparison.R
Last active August 29, 2015 14:25
Just a little reminder: be careful not to use leave-one-out with a perfectly balanced problem
library(C50)
# Test data
group <- c(rep('groupA', 10), rep('groupB', 10))
data <- data.frame(group = group, var = c(rep(0, 10), rep(0, 10)))
# Leave-one-out
probs <- lapply(1:nrow(data), function(i) {
train <- data[-i, ]
test <- data[i, ]
@rinze
rinze / build_dataset.py
Last active January 15, 2019 10:51
Parser para los archivos .DAT del Ministerio del Interior y el archivo de códigos de municipios del INE y código en R para gráficas simples.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import csv
import codecs
import cStringIO
import os
from collections import namedtuple
def getParties(parties_file):
### Keybase proof
I hereby claim:
* I am rinze on github.
* I am rinzewind (https://keybase.io/rinzewind) on keybase.
* I have a public key whose fingerprint is 67AF C4B2 E15C 4F4C 67BD 5F58 5ADF 9021 2630 80EC
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am rinze on github.
  • I am rinzewind (https://keybase.io/rinzewind) on keybase.
  • I have a public key whose fingerprint is C7F0 E413 1FFF 47C6 A2A7 F76B F4FE 866D 2948 FA19

To claim this, I am signing this object:

localpath <- "/home/chema/tmp/kaggle/digits/"
if (Sys.info()["sysname"] == "Windows")
localpath <- "C:/temp/kaggle/digits"
testFile <- file.path(localpath, "test.Rda")
trainFile <- file.path(localpath, "train.Rda")
if(!file.exists(testFile) && !file.exists(trainFile)) {
testCSV <- file.path(localpath, "test.csv")
trainCSV <- file.path(localpath, "train.csv")