Skip to content

Instantly share code, notes, and snippets.

🐯
Rawrrr.

J. R. Schmid sixtyfive

🐯
Rawrrr.
Block or report user

Report or block sixtyfive

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
@sixtyfive
sixtyfive / ocrpdf.rb
Last active Nov 17, 2019
Script that uses Tesseract, Poppler and ImageMagick utilities to OCR a PDF consisting of mere images and make it searchable
View ocrpdf.rb
#!/usr/bin/env ruby
main_lang = ARGV[0]
input_pdf = ARGV[1]
temp_dir = 'temp'
if main_lang && input_pdf
`mkdir -p #{temp_dir}`
print "Splitting PDF into separate pages... "
`pdfseparate "#{input_pdf}" #{temp_dir}/page_%d.pdf`
View happydivali.ino
#include <ShiftRegister74HC595.h>
int numberOfShiftRegisters = 2;
int numberOfCapacitorsToPop = 16;
int serialDataPin = 0;
int clockPin = 1;
int latchPin = 2;
int outputEnablePin = 3;
ShiftRegister74HC595 sr (numberOfShiftRegisters, serialDataPin, clockPin, latchPin);
View tpl0501.ino
#include <SPI.h>
#define PIN_LED GPIO_NUM_4
#define PIN_VREF GPIO_NUM_25
#define PIN_MOSI GPIO_NUM_23
#define PIN_CLOCK GPIO_NUM_18
#define PIN_GAIN_EN GPIO_NUM_12
#define PIN_OFFSET_EN GPIO_NUM_14
void StartSPI()
View pulsecounter.ino
// PULSE_PIN, LED_BUILTIN
// WIFI_SSID, WIFI_PASSWORD
// MQTT_SERVER, MQTT_PORT
// MQTT_META_TOPIC, MQTT_TOTAL_TOPIC, MQTT_LASTMIN_TOPIC
#include "config.h"
#include <EspMQTTClient.h>
EspMQTTClient client(
WIFI_SSID, WIFI_PASSWORD,
@sixtyfive
sixtyfive / esp32_adc_to_voltage.ino
Created Aug 26, 2019
Some experiments on how to deal with the ESP32's ADC in Arduino IDE code
View esp32_adc_to_voltage.ino
float v_supply = 3.29; // measured: 3.29
int adc_pin = 4;
int adc_bits = 12;
/* effective range of measurement:
* ADC_0db: 100-950mV (+-23mV)
* ADC_2_5db: 100-1250mV (+-30mV)
* ADC_6db: 150-1750mV (+-40mV)
* ADC_11db: 150-2450mV (+-60mV) - default value
*/
adc_attenuation_t adc_attn = ADC_0db;
@sixtyfive
sixtyfive / apk-installed-sizes.sh
Last active Jul 1, 2019
List installed Alpine Linux packages together with their installed sizes in human-friendly format
View apk-installed-sizes.sh
#!/bin/bash
# there's a tool called numfmt which does the bytes thing for you
# numfmt can also absorb stdin, so the entire thing could just be
# `apk info |
# numfmt --to=iec | # (might need --invalid=ignore and --field=...)
# awk -v OFS="\t" '... {print size, pkg}'
# or you can use awk to do the bytes stuff and use `apk info | awk ...'
bytesToHuman() {
b=${1:-0}; d=''; s=0; S=(Bytes {K,M,G,T,P,E,Z,Y}iB)
@sixtyfive
sixtyfive / Rakefile
Last active May 28, 2019
Two variants of doing the same thing (also cf. https://rubular.com/r/WHXrCmrKPfQMAx)
View Rakefile
REGEX = /([ -]+)\[{2}([^\]]*)\]\([^\]]*\]\(([^\)]*)\)/
SUBST = '\1[\2](\3)'
task :fix_toc_regex do
string = STDIN.read
puts string.gsub(REGEX, SUBST)
end
task :fix_toc_loop_plus_regex do
unless STDIN.tty?
@sixtyfive
sixtyfive / module_access.rb
Last active May 21, 2019
For future reference
View module_access.rb
#!/usr/bin/env ruby
module MyModule
module MyHelper
module_function def helpermethod
puts "helpermethod"
end
end
private_constant :MyHelper
@sixtyfive
sixtyfive / update-signal-desktop.sh
Created Jan 22, 2019
Simple bash script to download the latest version of Signal Desktop
View update-signal-desktop.sh
#!/bin/bash
# Public domain. Use and abuse and tell me if you make it prettier,
# like, add a "--prefix" option or figure out where to put .desktop
# files or link the binary to...
echo -n "Looking up latest version, "
verurl="https://github.com/signalapp/Signal-Desktop/releases"
pkgver=$(curl -s "${verurl}" | grep "/signalapp/Signal-Desktop/releases/tag/" -m 1 | grep -oP '[\d\.]*')
View breathe.ino
#include <math.h>
unsigned const int led_count = 5;
int led_pin[led_count] = {10, 9, 6, 5, 3};
const unsigned int min_val = 25; // never go dark completely
const unsigned int max_val = 255; // don't kill the LEDs (atm there are no resistors)
void setup()
{
Serial.begin(9600);
You can’t perform that action at this time.