This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |