Skip to content

Instantly share code, notes, and snippets.

Avatar

Iñaki Ucar Enchufa2

View GitHub Profile
@Enchufa2
Enchufa2 / pong.R
Last active Jul 24, 2022
Pong in R
View pong.R
# remotes::install_github("coolbutuseless/eventloop")
Pong <- R6::R6Class(
"pong",
public = list(
initialize = function(width=10, height=7, speed=0.02) {
require(grid)
private$width <- width
private$height <- height
@Enchufa2
Enchufa2 / git-remove.sh
Last active Sep 17, 2021
Remove and purge old mistakes and/or unwanted big files from git history
View git-remove.sh
#!/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 / collatz.c
Created Jul 30, 2021
Collatz's conjecture + GMP games
View collatz.c
#include <stdio.h>
#include <gmp.h>
int main() {
mpz_t x, y, odd_or_even;
mpz_init(x);
mpz_init(y);
mpz_init(odd_or_even);
unsigned long int i, p;
@Enchufa2
Enchufa2 / sim.py
Last active Nov 1, 2020
Simple simulation core in Python and M/M/1 queueing example
View sim.py
#!/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 Sep 24, 2020
This snippet monitors your R packages' CRAN Package Check Results page and notifies you by email if there are any changes.
View cchecks-rules.R
#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))
@Enchufa2
Enchufa2 / cloudsend.sh
Created Dec 16, 2019 — forked from markusstraub/cloudsend.sh
Send files to Nextcloud/Owncloud shared folder using curl
View cloudsend.sh
#!/usr/bin/env bash
############################################################
#
# cloudsend.sh
#
# Uses curl to send files to a shared
# Nextcloud/Owncloud folder
#
# Usage: ./cloudsend.sh <file> <folderLink>
View .vimrc
let mapleader=","
set laststatus=2
set colorcolumn=81
highlight ColorColumn ctermbg=8
set number
set cursorline
set wildmenu
set showmatch
View init.coffee
# 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 / yield.c
Created May 2, 2018
Very simple 'yield' demo in C for DES
View yield.c
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <math.h>
#include <time.h>
typedef struct process {
double *now;
double (*run)(struct process *);
jmp_buf buf;
@Enchufa2
Enchufa2 / loadhdf5data.R
Created May 9, 2017
Load a Python/pandas data frame from an HDF5 file into R
View loadhdf5data.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")