Skip to content

Instantly share code, notes, and snippets.

View pbosetti's full-sized avatar
:octocat:

Paolo Bosetti pbosetti

:octocat:
View GitHub Profile
@pbosetti
pbosetti / mruby-bug.rb
Last active August 29, 2015 13:57
This script replicates a weird bug in mruby
#!/usr/bin/env mruby
# Dataset, Container and self.dataset are a minimal set of prerequisites that
# we extrapolated from our application, in order to replicate the bug
class Container
attr_accessor :key_converter, :match
attr_reader :hsh
def initialize
@hsh= Hash.new
@pbosetti
pbosetti / timeout.c
Created June 4, 2014 13:39
Simple timeout implementation using SIGALRM
//
// main.c
// timeout
//
// Created by Paolo Bosetti on 04/06/14.
// Copyright (c) 2014 UniTN. All rights reserved.
//
#include <stdio.h>
#include <signal.h>
@pbosetti
pbosetti / setup.sh
Last active August 29, 2015 14:13
Base debian setup
#!/bin/bash
RUBY_BASE=2.2
RUBY_TGZ=ruby-2.2.0
echo
echo "************************************"
echo "Updating package list"
if ! sudo apt-get update; then
echo "Could not update package list"
exit $?
@pbosetti
pbosetti / gist:4e6ebf5077ceaa8cc8ec
Last active August 29, 2015 14:18
Dependencies for Mechatronix package on Linux Debian

Dependencies for Mechatronix package on Linux Debian

Before installing the Mechatronix package, install the following dependencies:

sudo apt-get install libyaml-0-2 libyaml-dev
sudo apt-get install libreadline6 libreadline6-dev libreadline-dev readline-common
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install libblas3 libblas-dev libopenblas-base libopenblas-dev
sudo apt-get install liblapack3 liblapack-dev
# -*- encoding: utf-8 -*-
# Stub for gemspec
Gem::Specification.new do |s|
s.name = %q{GEMNAME}
s.version = "GEMVERSION"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Paolo Bosetti"]
s.date = %q{2009-05-04}
@pbosetti
pbosetti / EEPROM_hack.cpp
Created June 29, 2009 14:30
Pair of functions to read and write values of any type in Arduino's EEPROM memory.
/*
Functions to write and restore value of any type in Arduino's EEPROM
*/
#include <EEPROM.h>
// Functions
template <class T> int EEPROM_write(int ee, const T& value)
{
byte const *p = reinterpret_cast<byte const *>(&value);
int i;
#include <MsTimer2.h>
#include <EEPROM.h>
// Serial data rate
#define BAUD 115200
// Version number
#define CODEID "Sampler.1"
// Constants
@pbosetti
pbosetti / fft.rb
Created September 7, 2009 18:18
Adds a method to Array to compute the 1-D radix-2 fast Fourier Transform
#!/usr/bin/env ruby
# Adds a method to Array to compute the 1-D radix-2 fast Fourier Transform
#
# Created by Paolo Bosetti on 2009-09-07.
# Copyright (c) 2009 University of Trento. All rights reserved.
#
require "mathn"
require "complex"
include Math
@pbosetti
pbosetti / entities.rb
Created September 11, 2009 09:12
ASCII encoder
#!/usr/bin/env ruby
# entities.rb
#
# Created by Paolo Bosetti on 2009-09-11.
# Copyright (c) 2009 University of Trento. All rights reserved.
#
$KCODE = 'U'
OUT_DIR = "Converted"
if ARGV.size == 0
@pbosetti
pbosetti / FFT.c
Created October 9, 2009 14:42
Small Ruby C extension to compute the FFT of an Array of power of 2 elements (Float).
/*
fft extension to Array class.
(C) Paolo Bosetti 2009 - University of Trento
Credits to fft.c
(c) Douglas L. Jones
University of Illinois at Urbana-Champaign
January 19, 1992
*/
#include "ruby.h"
#include <math.h>