Skip to content

Instantly share code, notes, and snippets.

View alarrosa14's full-sized avatar

Alvaro Larrosa alarrosa14

View GitHub Profile
@alarrosa14
alarrosa14 / mandelbrot.c
Last active November 12, 2015 01:07
C fork based multiprocess mandelbrot algorithm implementation.
#include <sys/stat.h>
#include <fcntl.h>
#include <limits.h>
#include <sys/mman.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
@alarrosa14
alarrosa14 / mandelbrot_master.c
Last active November 12, 2015 01:07
PVM mandelbrot algorithm.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <pvm3.h>
int main() {
const double yMin = -1.0;
const double yMax = +1.0;
const double xMin = -2.0;
const double xMax = +0.5;
@alarrosa14
alarrosa14 / kmeans.c
Last active November 12, 2015 01:06
A sequential kmeans algorithm implementation.
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <float.h>
#include <stdio.h>
#define N 300000
#define K 100
#define TOLERANCE 0.00001
#define SEED 11
@alarrosa14
alarrosa14 / kmeans-posix.c
Last active November 12, 2015 01:07
A Kmeans implementation using posix threads. Generates a Octave script to plot the output.
#include <pthread.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <float.h>
#include <stdio.h>
#include <sys/types.h>
#define CANT_THREADS 8
@alarrosa14
alarrosa14 / kmeans-master.c
Created October 10, 2015 22:38
A master-slave implementation of kmeans algorithm using PVM3.
#include <pthread.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <float.h>
#include <stdio.h>
#include <sys/types.h>
#include <pvm3.h>
#define CANT_SLAVES 20
@alarrosa14
alarrosa14 / artnet_middleware.py
Last active August 2, 2022 13:30
A Python ArtNet packet receiver that broadcasts its payload.
import sys
from socket import (socket, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_REUSEADDR,
SO_BROADCAST)
from struct import pack, unpack
UDP_IP = "127.0.0.1"
UDP_PORT = 6454
@alarrosa14
alarrosa14 / mbed_sendero_synchronization_test.cpp
Created February 6, 2016 05:53
An app for the mBed that tests the Sendero ESP-8266 clock sinchronization.
#include "mbed.h"
InterruptIn device1(p11);
InterruptIn device2(p12);
InterruptIn device3(p13);
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
@alarrosa14
alarrosa14 / Meter.ino
Created May 31, 2016 01:11 — forked from dernster/Meter.ino
ESP Sync Meter
#include "Arduino.h"
// Include API-Headers
extern "C" {
#include "ets_sys.h"
#include "os_type.h"
#include "osapi.h"
#include "mem.h"
#include "user_interface.h"
#include "cont.h"
@alarrosa14
alarrosa14 / abbreviate.js
Last active August 2, 2018 12:41
Angular filter to abbreviate large numbers, optionally receiving the number of decimal places as parameter.
// Based in http://stackoverflow.com/a/2686098/4436816
//
// Usage examples:
// {{ 2134124 | abbreviate:2}} -> 2.13M
// {{ 2134124 | abbreviate }} -> 2M
// {{ 1000 | abbreviate }} -> 1K
myApp.filter('abbreviate', function() {
return function(number, decPlaces) {
@alarrosa14
alarrosa14 / scroll-listener.js
Created April 3, 2017 20:13
60FPS onscroll event listener
(function() {
var lastScrollY = 0;
var ticking = false;
var update = function() {
// do your stuff
ticking = false;
};
var requestTick = function() {