Skip to content

Instantly share code, notes, and snippets.

View Enchufa2's full-sized avatar

Iñaki Ucar Enchufa2

View GitHub Profile
@Enchufa2
Enchufa2 / dropbox-downloader.py
Created November 30, 2013 10:53
Dropbox recursive downloader
#!/usr/bin/env python
# coding=UTF8
# Author: Iñaki Ucar <i.ucar@enchufa2.es>
# Description: Dropbox recursive downloader
import os, sys
from urllib2 import urlopen, unquote
from bs4 import BeautifulSoup
from subprocess import call
@Enchufa2
Enchufa2 / Fancontrol-hv2.c
Last active March 2, 2018 09:45
Fancontrol via Hardware PWM for RaspberryPi
/*
Fancontrol via Hardware PWM for Raspian
Author: 2h4u
Date: 19.01.2013
Version 2:
Now with dynamic PWM regulation!
*/
#include <stdio.h>
### Keybase proof
I hereby claim:
* I am Enchufa2 on github.
* I am enchufa2 (https://keybase.io/enchufa2) on keybase.
* I have a public key whose fingerprint is F432 0B54 CF67 6936 3D02 0832 7EE8 1A3F 563B 3315
To claim this, I am signing this object:
@Enchufa2
Enchufa2 / sim.py
Last active March 13, 2023 11:43
Simple simulation core in Python and M/M/1 queueing example
#!/usr/bin/env python2
# coding=UTF8
# Author: Iñaki Ucar <i.ucar86@gmail.com>
# Description: Simple simulation core in Python and M/M/1 queueing example
from heapq import heappop, heappush
class Simulator(object):
"""Simulation environment"""
@Enchufa2
Enchufa2 / cchecks-rules.R
Last active September 24, 2020 16:58
This snippet monitors your R packages' CRAN Package Check Results page and notifies you by email if there are any changes.
#remotes::install_github("ropensci/cchecks")
library(cchecks)
myaddress <- whoami::email_address()
# cchn_register(myaddress)
pkgs <- cch_maintainers(sub("@", "_at_", myaddress))$data$packages
msgs <- c("warn", "error")
rules <- lapply(pkgs$package, function(pkg) list(package=pkg))
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@Enchufa2
Enchufa2 / chirp.m
Created March 29, 2016 19:42
Simulation of the chirp echo created in the staircases of Mesoamerican pyramids
clap = audioread('clap.wav');
fs = 96e3; % sampling frequency
N = 40; % steps
ssize = 0.15; % step size
delay = ssize * 2 / 340;
samples = round(delay * fs);
stairs = zeros(samples * N + length(clap) + N, N);
for i = 1:N
samples = samples + 1;
indexes = (i-1)*samples+1 : length(clap)+(i-1)*samples;
@Enchufa2
Enchufa2 / get_wikipedia_events.py
Last active November 26, 2016 22:21
Download all events, births and deaths from Wikipedia
#!/usr/bin/env python3
# coding=UTF8
# Author: Iñaki Ucar <i.ucar86@gmail.com>
# Description: Download all events, births and deaths from Wikipedia
import sys, requests, locale
from datetime import date, timedelta as td
from pypandoc import convert # <3
MAX_TITLES = 50
@Enchufa2
Enchufa2 / git-remove.sh
Last active September 17, 2021 12:10
Remove and purge old mistakes and/or unwanted big files from git history
#!/bin/bash
# Remove and purge old mistakes and/or unwanted big files from git history
# author: Iñaki Ucar <i.ucar86@gmail.com>
# based on: http://blog.ostermiller.org/git-remove-from-history
if [ "$#" -ne 2 ]; then
echo "usage: $0 <repo-URL> <pattern>"
exit 1
fi
@Enchufa2
Enchufa2 / loadhdf5data.R
Created May 9, 2017 15:52
Load a Python/pandas data frame from an HDF5 file into R
#' @param h5File HDF5 file path
#' @param dataset data frame path in the HDF5 file
#' @examples
#' df <- loadhdf5data("/path/to/file.hdf5", "/path/to/dataset")
#'
loadhdf5data <- function(h5File, dataset) {
require(h5) # available on CRAN
f <- h5file(h5File)
nblocks <- h5attr(f[dataset], "nblocks")