Skip to content

Instantly share code, notes, and snippets.

View sixtyfive's full-sized avatar
🐯
Rawrrr.

J. R. Schmid sixtyfive

🐯
Rawrrr.
View GitHub Profile
def colprint(aofas)
s=""; aofas.each{|i,c| s<<i; s<<(' '*(c-i.size+1)) if c>=i.size}; s
end
#include <stdio.h>
int main(void) {
unsigned int a = 5;
a -= (unsigned)10;
printf("%i\n", a); // -5 with amd64/gcc, but only by coincidence (undefined!)
printf("%u\n", a); // some really high number; UINTMAX - 5...
}
#!/bin/bash
GITHUBUSERNAME=""
for repo in $(cat repoURLs.txt); do
git clone $(echo $repo | sed s/LibrePCB-Libraries/$GITHUBUSERNAME/g)
dir=$(basename -s '.git' $repo)
for subdir in cmp cmpcat dev pkg pkgcat sym; do
mkdir -p $dir/$subdir
done
@sixtyfive
sixtyfive / newres.sh
Created May 19, 2020 10:32
Add new resolution and change to it right away
OUT=Virtual-1 X=2560 Y=1440 R=60 bash -c \
'MOD=${X}x${Y}_$R.00; xrandr --newmode $MOD $(cvt $X $Y $R | grep -v "#" | cut -d "\"" -f 3); xrandr --addmode $OUT $MOD; xrandr --output $OUT --mode $MOD'
@sixtyfive
sixtyfive / ocrpdf.rb
Last active November 17, 2019 17:01
Script that uses Tesseract, Poppler and ImageMagick utilities to OCR a PDF consisting of mere images and make it searchable
#!/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`
#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);
#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()
// 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 August 26, 2019 19:56
Some experiments on how to deal with the ESP32's ADC in Arduino IDE code
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 March 21, 2024 03:47
List installed Alpine Linux packages together with their installed sizes in human-friendly format
#!/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)