Skip to content

Instantly share code, notes, and snippets.

@eufat
eufat / simple-json-api.go
Created May 27, 2022 13:50 — forked from tomnomnom/simple-json-api.go
Simple JSON API Server in Go
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
// The `json:"whatever"` bit is a way to tell the JSON
input {
beats {
port => 5044
}
}
filter {
csv {
columns => ["method", "duration", "key", "timestamp"]
separator => ","
input {
beats {
port => 5044
}
}
## Add your filters / logstash plugins configuration here
filter {
csv {
columns => ["used_memory", "cpu_used_sys"]
input {
beats {
port => 5044
}
}
## Add your filters / logstash plugins configuration here
filter {
kv {}
################### Heartbeat Configuration Example #########################
# This file is an example configuration file highlighting only some common options.
# The heartbeat.reference.yml file in the same directory contains all the supported options
# with detailed comments. You can use it for reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/heartbeat/index.html
############################# Heartbeat ######################################
version: '2'
services:
elasticsearch:
build:
context: elasticsearch/
volumes:
- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
- /home/ubuntu/elasticdata:/usr/share/elasticsearch/data
input {
beats {
port => 5044
}
}
## Add your filters / logstash plugins configuration here
filter {
kv {}
}
@eufat
eufat / frisbee_trajectory.c
Last active April 25, 2017 06:29
Frisbee Trajectory for KRAI
#include <stdio.h>
#include <math.h>
int main(){
double x;
//The x position of the frisbee.
double y;
//The y position of the frisbee.
double vx;
//The x velocity of the frisbee.
float set_speed(float omega_input){
float omega_read_encoder = read_encoder_speed();
if (omega_input != omega_read_encoder){
if (omega_read_encoder > omega_input) mv++;
if (omega_read_encoder < omega_input) mv--;
}
motor_drive(mv)
}
unsigned long last_time;
float set_speed(float omega_input){
// time handler
unsigned long now = millis();
double timeChange = (double)(now - last_time);
// PID Setup
float omega_read_encoder = read_encoder_speed(); // set input or reading value
error = omega_input - omega_read_encoder; // error = setpoint - input