Skip to content

Instantly share code, notes, and snippets.

View fdavidcl's full-sized avatar

David Charte fdavidcl

View GitHub Profile
@fdavidcl
fdavidcl / interfaces.rb
Last active April 23, 2017 15:35
Implementation for Java-like Interfaces in Ruby
#!/usr/bin/env ruby
#encoding: utf-8
############ Interface code
class InterfaceClass < Module
private
def included(klass)
if klass != Object
@_implemented.each do |m|
if !klass.method_defined?(m)
#!/bin/bash
# David Charte, Ignacio Cordón y Mario Román
# Parámetros
# 1 - regla para encontrar los archivos a compilar
# 2 - argumento a pasar al programa
CFLAGS="-flto -fopenmp -fwhole-program -Wall -Wl,--no-as-needed"
CXXFLAGS="$CFLAGS -std=c++0x"
LDFLAGS="-lm -lrt"
@fdavidcl
fdavidcl / TODO
Created October 15, 2014 18:39
TODO
# .bash_aliases
# Usage:
# todo - Shows tasks
# todo "New task" - Adds task to TODO list
# todo do 2 - Deletes 2nd task
function todo() {
[[ $# -ge 1 ]] && (
[[ $# -ge 2 ]] && (
cp ~/.TODO ~/.TODO.old
@fdavidcl
fdavidcl / Makefile
Last active August 29, 2015 14:09
Makefile for Lex programs
###############################################################################
# Makefile
# Compiles Lex programs in C++
###############################################################################
SHELL = /bin/bash
BIN = .
SRC = $(wildcard *.l)
EXE = $(basename $(BIN)/$(SRC))
# The hasselhoff attack taken to a new level
# curl -L http://git.io/pxu2 | bash
TARGET=`echo ~`/hasselhoff.jpg
wget http://www.ljpaez.es/imagen/hasselhoff.jpg $TARGET
gsettings set org.gnome.desktop.background picture-uri file:///$TARGET
xmessage -center "you have been hasselhoffinated"
void Environment::Show(int w,int h) const
{
const static float trufa_level=50.0;
/* Formatting */
const static string RED = "\e[31m";
const static string GREEN = "\e[32m";
const static string ORNG = "\e[33m";
const static string BLUE = "\e[34m";
const static string BOLD = "\e[1m";
@fdavidcl
fdavidcl / Makefile
Last active August 29, 2015 14:19
Plantilla trabajo ISE
PDF=$(addsuffix .pdf, $(basename $(basename $(wildcard *.doc.md *.pres.md))))
default: $(PDF)
%.pdf: %.doc.md
pandoc --to latex --latex-engine xelatex -N -o $@ $< --filter pandoc-citeproc
%.pdf: %.pres.md
pandoc --to beamer --latex-engine xelatex -N -o $@ $<
@fdavidcl
fdavidcl / clt_dice.R
Last active September 29, 2015 21:02
Teorema Central del Límite: lanzando dados
# Guion para comprobación del Teorema Central del Límite:
#
# The central limit theorem (CLT) states that, given certain conditions,
# the arithmetic mean of a sufficiently large number of iterates of
# independent random variables, each with a well-defined expected value
# and well-defined variance, will be approximately normally distributed,
# regardless of the underlying distribution -- Wikipedia (https://en.wikipedia.org/wiki/Central_limit_theorem)
#
simular <- function(dados = 20, caras = 6, muestras = 1000) {
@fdavidcl
fdavidcl / rebuild_datasets.R
Created September 30, 2015 18:23
Rebuild mldr datasets
emotions <- mldr_from_dataframe(mldr::emotions$dataset, mldr::emotions$labels$index, "emotions")
birds <- mldr_from_dataframe(mldr::birds$dataset, mldr::birds$labels$index, "birds")
genbase <- mldr_from_dataframe(mldr::genbase$dataset, mldr::genbase$labels$index, "genbase")
save(emotions, file = "emotions.rda", compress = "xz")
save(birds, file = "birds.rda", compress = "xz")
save(genbase, file = "genbase.rda", compress = "xz")
@fdavidcl
fdavidcl / .bashrc
Created February 22, 2016 16:51
Catkin functions for bash on Arch Linux
# ...
catkin-setup() {
source /opt/ros/jade/setup.bash &> /dev/null
}
catkin-setup
catkin-make() {
catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python2 -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so $*
source devel/setup.bash