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 / array_test.rb
Created October 1, 2013 12:31
This Array is uncorrectly loaded into mruby. At index 127, the pair [127, 127] gets flattened.
ary = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25], [26, 26], [27, 27], [28, 28], [29, 29], [30, 30], [31, 31], [32, 32], [33, 33], [34, 34], [35, 35], [36, 36], [37, 37], [38, 38], [39, 39], [40, 40], [41, 41], [42, 42], [43, 43], [44, 44], [45, 45], [46, 46], [47, 47], [48, 48], [49, 49], [50, 50], [51, 51], [52, 52], [53, 53], [54, 54], [55, 55], [56, 56], [57, 57], [58, 58], [59, 59], [60, 60], [61, 61], [62, 62], [63, 63], [64, 64], [65, 65], [66, 66], [67, 67], [68, 68], [69, 69], [70, 70], [71, 71], [72, 72], [73, 73], [74, 74], [75, 75], [76, 76], [77, 77], [78, 78], [79, 79], [80, 80], [81, 81], [82, 82], [83, 83], [84, 84], [85, 85], [86, 86], [87, 87], [88, 88], [89, 89], [90, 90], [91, 91], [92, 92], [93, 93], [94, 94], [95, 95], [96, 96], [97, 97], [98, 98], [99, 99], [100, 100], [101, 101], [102, 102], [
#!/bin/sh
if [[ $EUID -ne 0 ]]; then
echo 1>&2
echo 1>&2
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" 1>&2
echo "! This script must be run as root! !" 1>&2
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" 1>&2
echo
exit 1
fi
@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
@pbosetti
pbosetti / mruby-play.c
Last active December 18, 2021 21:41
mruby gem example on how to use Data_Wrap_Struct for wrapping C structs into an mruby object
/***************************************************************************/
/* */
/* play.c - mruby testing */
/* Copyright (C) 2015 Paolo Bosetti and Matteo Ragni, */
/* paolo[dot]bosetti[at]unitn.it and matteo[dot]ragni[at]unitn.it */
/* Department of Industrial Engineering, University of Trento */
/* */
/* This library is free software. You can redistribute it and/or */
/* modify it under the terms of the GNU GENERAL PUBLIC LICENSE 2.0. */
/* */
@pbosetti
pbosetti / prepare.rb
Last active December 1, 2015 07:37
Trying to illustrate the reason for using local includes (i.e. #include "") rather than system includes (i.e. #include <>) within public headers for mruby.
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils
# This scripts tries to show why it is preferable to only use local include
# commands (#include "") within public headers of mruby when they include each
# other.
# To test it, first run this script with no arguments (it will stop on
# compilation), then with the `proposal` argument, which uses as mruby source
# the relative pull request.
# Note that the pull request does not alter in any way how users will have to
@pbosetti
pbosetti / segv_capture.c
Created February 11, 2016 11:25
Example on capturing and managing SIGSEGV in C99/Unix
//
// main.c
// segv_capture
//
// Created by Paolo Bosetti on 10/02/16.
// Copyright © 2016 UniTN. All rights reserved.
//
#include <setjmp.h>
#include <signal.h>
@pbosetti
pbosetti / .bash_profile
Last active March 1, 2016 09:30
Bash prompt configuration for git branch names
# ASCII COLOR SEQUENCES: \[\033[***m\] where *** is one of the following codes:
# Black 0;30 Dark Gray 1;30
# Blue 0;34 Light Blue 1;34
# Green 0;32 Light Green 1;32
# Cyan 0;36 Light Cyan 1;36
# Red 0;31 Light Red 1;31
# Purple 0;35 Light Purple 1;35
# Brown 0;33 Yellow 1;33
# Light Gray 0;37 White 1;37
HL_CLR="\[\033[1;32m\]"