Skip to content

Instantly share code, notes, and snippets.

View MauroMombelli's full-sized avatar

Mauro Mombelli MauroMombelli

View GitHub Profile
import java.util.Random;
public class ZeroSeriesLength {
public static void main(String[] args) throws Exception {
int maxLength;
long nanoTime;
for (int i = 0; i < 100; i++) {
Random r = new Random();
int size = 10000;
@MauroMombelli
MauroMombelli / schedulerOverflowModularArithmetic
Last active August 29, 2015 14:04
playing with overflow (modular arithmetic) to create a scheduler witch support dinamic event period and unregular execution times
#include <stdio.h>
#include <stdint.h>
int main(int argv, char *args[]){
uint8_t tempo_attuale = 0;
uint8_t tempo_ultima_esecuzione = -1;//force overflow, or if first execution is at 0 it get all screwed up untill next overflow!
uint8_t periodo_in_esame;
/*le seguenti 3 variabili possono essere messe in una strutture a poi "arrayzzate" per avere più eventi indipendenti*/
uint8_t tempo_esecuzione = 0;
@MauroMombelli
MauroMombelli / test.java
Created October 10, 2014 13:12
java event write read to sinc
private HashMap<CacheKey, AtomicBoolean> waitNotify = new HashMap<>();
@Override
public void objectReaded(Object readObject, SuperSocket superSocket) {
if (readObject instanceof VersionedObject) {
VersionedObject vb = (VersionedObject) readObject;
synchronized (waitNotify) {
AtomicBoolean boolean1 = waitNotify.get(vb.getKey());
synchronized (boolean1) {
if (boolean1 != null) {
@MauroMombelli
MauroMombelli / gist:36bbe0025fb5d7722234
Created October 13, 2014 21:27
chibios 2.6 test usb error
9797.467508] usb 2-1: USB disconnect, device number 31
[ 9810.374551] usb 2-1: new full-speed USB device number 32 using xhci_hcd
[ 9810.487773] usb 2-1: device descriptor read/64, error -71
[ 9810.590916] xhci_hcd 0000:03:00.0: Setup ERROR: setup context command for slot 1.
[ 9810.590930] usb 2-1: hub failed to enable device, error -22
[ 9810.697435] usb 2-1: new full-speed USB device number 33 using xhci_hcd
[ 9810.810657] usb 2-1: device descriptor read/64, error -71
[ 9810.913783] xhci_hcd 0000:03:00.0: Setup ERROR: setup context command for slot 1.
[ 9810.913796] usb 2-1: hub failed to enable device, error -22
[ 9811.020320] usb 2-1: new full-speed USB device number 34 using xhci_hcd
@MauroMombelli
MauroMombelli / gist:57d6a3bfee258700fa6c
Created October 13, 2014 21:43
chibios 3.0 test usb error
[10743.328765] usb 2-1: new full-speed USB device number 2 using xhci_hcd
[10743.441982] usb 2-1: device descriptor read/64, error -71
[10743.545122] xhci_hcd 0000:03:00.0: Setup ERROR: setup context command for slot 1.
[10743.545135] usb 2-1: hub failed to enable device, error -22
[10743.651657] usb 2-1: new full-speed USB device number 3 using xhci_hcd
[10743.764868] usb 2-1: device descriptor read/64, error -71
[10743.868003] xhci_hcd 0000:03:00.0: Setup ERROR: setup context command for slot 1.
[10743.868016] usb 2-1: hub failed to enable device, error -22
[10743.974541] usb 2-1: new full-speed USB device number 4 using xhci_hcd
[10743.975721] usb 2-1: Device not responding to setup address.
@MauroMombelli
MauroMombelli / gist:cd9b5aac6d77a12fb421
Created November 27, 2014 19:49
How compile GMP for ARM
./configure --disable-shared --host=arm-none-eabi --build=x86_64-linux-gnu CFLAGS=--specs=rdimon.specs CC=arm-none-eabi-gcc AS=arm-none-eabi-as
@MauroMombelli
MauroMombelli / Scheduler
Created January 10, 2015 20:04
java basic scheduler
package lwjglTests.chart;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
public class Scheduler {
private long time = 0;
private SortedMap<Long, List<Container>> schedulationMap = new TreeMap<>();
@MauroMombelli
MauroMombelli / soft_mul.c
Last active June 4, 2016 11:58
Example of software multiplication between 2 double, NOT SAFE, NOT IEEE754 COMPLIANT, DON'T USE AND CRY
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
union double_to_uint64{
double value;
union{
uint64_t raw_double;
struct{
@MauroMombelli
MauroMombelli / Makefile
Last active September 18, 2016 13:56
This is a experimental makefile for CMSIS inclusion. STM32f303
CC=arm-none-eabi-gcc
CFLAGS= -Wall -Wextra -Wpedantic -Wformat -std=c11 -O0
LD=$(CC)
PROJECTNAME=Test_SPracingEVO
ODIR=build
LIBS= -I src -I lib/CMSIS -I lib/STM32F30x_StdPeriph_Driver/inc
function findTangentPoint(xR, yR, xW1, yW1, xW2, yW2 ){
if ( xW1 == xW2 ){
console.log("same x " +yR +" "+ yW1+" "+ yW2);
return new Point(xW1, constrain(yR, yW1, yW2) );
}
if ( yW1 == yW2 ){
console.log("same y " +xR +" "+ xW1+" "+ xW2);
return new Point(constrain(xR, xW1, xW2), yW1);
}