Skip to content

Instantly share code, notes, and snippets.

View tlorens's full-sized avatar
🏠
Working from home

Timothy Lorens tlorens

🏠
Working from home
View GitHub Profile
@tlorens
tlorens / NeoPixelTurnSignals.ino
Last active February 26, 2023 17:02
NeoPixel Turn Signals Improved with Reverse Light
#include <Adafruit_NeoPixel.h>
/**
* NEO Pixel Turn signals.
* Author: Timothy Lorens <tlorens@cyberdyne.org>
* Date: 07/05/2018
*
* Simple sequential (sweeping) Turn signal logic with dim solid red run state lights
* along with white reverse light. AnalogRead() is used to determine if there's voltage
* on one of the analog pins. Since the blinker relay isn't consistent our loop should be
@tlorens
tlorens / gist:d6df0e1295082ccbbfb40689cae75e70
Created March 7, 2018 03:07 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@tlorens
tlorens / netio.go
Created October 30, 2017 20:43
Attempt at fetching byte by byte without pressing return.
package shckio
import (
"bufio"
"log"
)
func GetCh(rw *bufio.ReadWriter) byte {
ch, _ := rw.ReadByte()
log.Println(string(ch))
@tlorens
tlorens / uploaderController.php
Last active November 13, 2020 10:04
Guzzle 6 Large file uploads / Chunking
/**
* @Route("/chunks", name="chunks")
*/
public function sendFileAction()
{
$jar = new \GuzzleHttp\Cookie\SessionCookieJar('SESSION_STORAGE', true);
$handler = new CurlHandler();
$stack = HandlerStack::create($handler);
$client = new Client(['cookies'=>true, 'handler' => $stack]);
$filename = 'files/huge-1gig-file.jpg';
### Keybase proof
I hereby claim:
* I am tlorens on github.
* I am tlorens (https://keybase.io/tlorens) on keybase.
* I have a public key whose fingerprint is 78E1 09B9 CFC6 48DA 2194 D8F1 10CE 51D0 D808 CDE1
To claim this, I am signing this object:
@tlorens
tlorens / _24NeoPixelTurnSingals.ino
Created January 29, 2017 19:43
Arduino Code for "Larson Scan" Aka "Knight Rider" turn signals.
/**
* Author: Timothy Lorens <tlorens@cyberdyne.org>
* Date: Jan 2016
* Larson scan turn signal code for Arduino
*
*/
#include <Adafruit_NeoPixel.h>
#define LeftSignal A5
@tlorens
tlorens / lightshowpi_config.xml
Last active December 21, 2015 15:54
Proof of concept XML configuration file for LightShowPi
<config>
<channels>
<channel id="1" title="red candy canes" pin="1" mode="onoff" />
<channel id="2" title="snowman" pin="4" mode="onoff">
<frequencies>
<frequency>
<min>1000</min>
<max>3000</max>
</frequency>
@tlorens
tlorens / intro.ino
Created February 21, 2015 23:57
Arduino MIcro and SSD1306 OLED Display
#include <Metro.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 64)
@tlorens
tlorens / powermate.c
Created February 2, 2015 21:47
Android PowerMate Input Driver Modifications
/*
* A driver for the Griffin Technology, Inc. "PowerMate" USB controller dial.
*
* v1.1, (c)2002 William R Sowerbutts <will@sowerbutts.com>
*
* This device is a anodised aluminium knob which connects over USB. It can measure
* clockwise and anticlockwise rotation. The dial also acts as a pushbutton with
* a spring for automatic release. The base contains a pair of LEDs which illuminate
* the translucent base. It rotates without limit and reports its relative rotation
* back to the host when polled by the USB controller.
root@odroidu:/storage/sdcard0 # cat boot.ini
ODROID4412-UBOOT-CONFIG
setenv v_out "hdmi"
setenv fake_fb "true"
setenv fb_x_res "1280"
setenv fb_y_res "720"
setenv hdmi_phy_res "720"
setenv led_blink "1"
setenv bootcmd "movi read kernel 0 40008000;movi read rootfs 0 41000000 100000;bootm 40008000 41000000"
setenv bootargs "console=/dev/ttySAC1,115200n8 androidboot.console=ttySAC1 v_out=${v_out} fake_fb=${fake_fb} fb_x_res=${fb_x_r