Skip to content

Instantly share code, notes, and snippets.

Kasper Kamperman kasperkamperman

Block or report user

Report or block kasperkamperman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kasperkamperman
kasperkamperman / ReadPulseCooking.pde
Created Jun 13, 2019
Code in which I read serial data and write it to a CSV file. Used for a research project.
View ReadPulseCooking.pde
// ReadPulseCooking.pde
import processing.serial.*;
/*
http://pulsesensor.myshopify.com/
Uses a modified pulse sensor script in Arduino to update each 10ms
A different string is formulated with all the data
@kasperkamperman
kasperkamperman / callbucket_demo.php
Created Oct 18, 2018
This algorithm spreads out reoccurring (every n minutes) api calls over time, so server load is balanced. It's only the spreading out part.
View callbucket_demo.php
<pre>
<?php
ini_set('display_errors', '1');
ini_set('error_reporting', E_ALL);
/* This algorithm spreads out reoccurring (every n minutes) api calls over time, so server load
is balanced. It's only the spreading out part.
The whole system uses a database with 60 columns. Each croncall (if we assume one a minute) we read out the
@kasperkamperman
kasperkamperman / fixwrongutf8encoding.php
Created Jul 3, 2018
Function to fix ut8 special characters displayed as 2 characters (utf-8 interpreted as ISO-8859-1 or Windows-1252)
View fixwrongutf8encoding.php
<?php header('Content-Type: text/html; charset=utf-8'); ?>
<html>
<head>
<title>Fix wrong encoded UTF8 characters</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
</head>
<body>
<pre>
<?php
/* Problem description:
@kasperkamperman
kasperkamperman / dmxoutputdriver.ino
Last active Feb 4, 2018
Output DMX data on the Particle Photon. Transmission is done in the background with the DMA implementation. You can use any pin, so you are not restricted to the serial port. Counterpart is that it uses a lot of memory (4 bytes for every transmitted DMX bit).
View dmxoutputdriver.ino
/* Demo to create a DMX output on every pin of the Photon.
It send the information through DMA, so transmitting data won't cost you
extra CPU cycles. Counterpart of this method is that each bit occupies 32bits
(unt32_t) in memory. So almost half of the Photon's memory is used for the
data array.
You can choose to use continuousMode is DMX is transmitted on the maximum speed
of around 44 fps. You can't go faster (at least not if you use the whole buffer).
This code supports on pin, however without any additional memory cost you could
@kasperkamperman
kasperkamperman / postImageToAzure.pde
Created Jan 24, 2018
raw sketch to test Azure posting and feedback in Processing
View postImageToAzure.pde
// download HttpClient 4.5.5 from https://hc.apache.org/downloads.cgi
// Download Binary 4.5.5 zip: http://ftp.tudelft.nl/apache//httpcomponents/httpclient/binary/httpcomponents-client-4.5.5-bin.zip
// Create a folder named code as a subfolder from this sketch
// Copy all the files in the "lib" folder to the code folder.
// Microsoft Cognetive Services - FACE API
// Docs: https://docs.microsoft.com/en-us/azure/cognitive-services/face/quickstarts/java
// Thanks to: https://stackoverflow.com/questions/39541634/how-to-send-a-local-image-instead-of-url-to-microsoft-cognitive-face-api-using-j
@kasperkamperman
kasperkamperman / main.cpp
Last active Apr 14, 2019
DMA control of GPIO pins on Particle Photon STM32
View main.cpp
#include "Particle.h"
// RM0033 MANUAL - Table 23 / Figure 1 System architecture
// Photon is STM32F205
// Only DMA2 is connected with GPIO ports https://stackoverflow.com/questions/46613053/pwm-dma-to-a-whole-gpio
// GPIO BSSRL/BSSRH/BSSR http://hertaville.com/stm32f0-gpio-tutorial-part-1.html
// DMA_Mode_Circular https://github.com/monkbroc/particle-speaker
// Ulrich Radig OctoArtnetNode https://www.ulrichradig.de/home/index.php/dmx/8-kanal-art-net
// Thanks to Julien Vanier for the idea of BSRR manipulation.
@kasperkamperman
kasperkamperman / add_to_functions.php
Created Nov 8, 2017
add source url to image captions in Wordpress
View add_to_functions.php
// add source url to image captions
// --------------------------------
//
// add this to functions.php of your (child) theme
// original by Kaspars Dambis: https://kaspars.net/blog/wordpress/how-to-automatically-add-image-credit-or-source-url-to-photo-captions-in-wordpress
// modified by Kasper Kamperman: https://www.kasperkamperman.com/blog/source-link-captions-in-wordpress/
add_filter("attachment_fields_to_edit", "add_image_source_url", 10, 2);
function add_image_source_url($form_fields, $post) {
$form_fields["source_url"] = array(
View easingdemo.pde
/*
Demonstration of the "Penner" easing functions.
I've used the Ani library. However you could also copy-paste functions form the source code.
This example only uses the functions in the Ani library. The Ani library is really time focused. However
with the demo you see how you can add easing on all values between 0.0 - 1.0, and use it for example for
music visualisation.
- online previz demo http://easings.net/#
View easingDemo.pde
void setup() {
// tip FX2D looks really smooth on retina displays
// some things won't work in this mode, but most things do
size(640,320,FX2D);
}
void draw() {
background(196);
View rotate-shapes-example.pde
void setup()
{
size(500,500);
strokeWeight(2);
}
void draw()
{ background(128);
rotateRect(width/2,height/2,100,100,frameCount%360);
You can’t perform that action at this time.