Skip to content

Instantly share code, notes, and snippets.

View codebudo's full-sized avatar

Sebastian Mikkel Wilson codebudo

View GitHub Profile
@codebudo
codebudo / servo_loop.ino
Created February 6, 2019 16:46
Receive signal from RC receiver and proxy to servo.
#include <EnableInterrupt.h>
#include "./ServoTimer2.h"
const int CH_1_PIN = 9;
const int CH_1_PIN_OUT = 3;
const int DEADZONE = 20;
volatile int pwmValue;
volatile unsigned long prevTime = 0;
@codebudo
codebudo / pwm_interrupt.ino
Created February 6, 2019 00:34
Calculating PWM timing using interrupts.
#include <EnableInterrupt.h>
const int CH_1_PIN = 9;
volatile int pwmValue;
volatile unsigned long prevTime = 0;
void setup() {
Serial.begin(9600);
enableInterrupt(CH_1_PIN, rising, RISING);
@codebudo
codebudo / PWM_input_test.ino
Created February 5, 2019 17:42
Sample multiple PWM signals. This is a counterexample. Don't do this.
const int CH_1_PIN = 9;
const int CH_2_PIN = 10;
const int CH_3_PIN = 11;
char buf [64];
void setup() {
Serial.begin(9600);
}
@codebudo
codebudo / lanes.py
Created February 1, 2019 20:24
Simple lane detection on a single image
import cv2
import numpy as np
def canny_image(image):
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
blur = cv2.GaussianBlur(gray, (5,5), 0)
canny = cv2.Canny(blur, 50, 150) # TODO change values based on light levels
return canny
def region_of_interest(image):
@codebudo
codebudo / videocap.py
Created February 1, 2019 19:53
RasPi camera video capture
from picamera.array import PiRGBArray
from picamera import PiCamera
import cv2
# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()
camera.resolution = (1280, 720)
camera.framerate = 10
rawCapture = PiRGBArray(camera, size=(1280, 720))
const request = require('request-promise');
const twilio = require('twilio');
const log = console.log; // switch to winston or something
// Your Account SID from www.twilio.com/console
let accountSid = process.env.TWILIO_SID;
// Your Auth Token from www.twilio.com/console
let authToken = process.env.TWILIO_AUTH_TOKEN;
@codebudo
codebudo / alteredAtRest.js
Last active March 24, 2018 21:38
It's possible to alter encrypted data if you know something about the underlying plaintext.
var crypto = require('crypto');
var iv = Buffer.from('0000000000000000000000==', 'base64');
var key = Buffer.from('ffffffffffffffffffffffffffffffff');
// aes-256-gcm or aes-256-ctr
var encrypt = crypto.createCipheriv('aes-256-ctr', key, iv);
var decrypt = crypto.createDecipheriv('aes-256-ctr', key, iv);
var plaintext = 'hello world';
@codebudo
codebudo / .screenrc
Created April 1, 2016 16:48
GNU Screen settings to reduce finger yoga. ctl-o as the activation key and hide the status bar, startup message, and visual bell.
startup_message off
term screen
#deflogin off
escape ^Oo
vbell off
defscrollback 10000
bind h prev
bind C hardcopy
bell_msg ""
shell -$SHELL
@codebudo
codebudo / .bash_profile
Created October 24, 2012 20:49
Bash profile for fancy prompt
# fancy prompt
COLOR_NONE="\[\e[0m\]"
BLACK_BOLD="\[\e[30;1m\]"
RED_BOLD="\[\e[31;1m\]"
GREEN_BOLD="\[\e[32;1m\]"
BROWN_BOLD="\[\e[33;1m\]"
BLUE_BOLD="\[\e[34;1m\]"
PINK_BOLD="\[\e[35;1m\]"
CYAN_BOLD="\[\e[36;1m\]"