Skip to content

Instantly share code, notes, and snippets.

View urjaman's full-sized avatar
💭
Too employed (as a machinist) for coding work lol

Urja Rannikko urjaman

💭
Too employed (as a machinist) for coding work lol
View GitHub Profile
@urjaman
urjaman / my_gitweb.patch
Created June 16, 2018 12:40
Gitweb for FastCGI + README display + project links link to treee
--- gitweb.cgi 2018-05-30 00:26:43.000000000 +0300
+++ my_gitweb.cgi 2018-06-16 15:26:41.207212864 +0300
@@ -24,6 +24,23 @@
binmode STDOUT, ':utf8';
+
+use CGI::Fast (-utf8);
+use FCGI ();
+use Encode ();
@urjaman
urjaman / loop disassembly
Created August 24, 2017 07:33
avr gcc doesnt know things ...
1596: e5 b9 out 0x05, r30 ; 5
1598: 70 81 ld r23, Z
159a: 70 93 f1 00 sts 0x00F1, r23 ; 0x8000f1 <__TEXT_REGION_LENGTH__+0x7e00f1>
159e: 91 50 subi r25, 0x01 ; 1
15a0: 31 96 adiw r30, 0x01 ; 1
15a2: 91 11 cpse r25, r1
15a4: f8 cf rjmp .-16 ; 0x1596 <main+0x3d6>
@urjaman
urjaman / dwmdate.c
Created March 13, 2017 10:25
a small clock for dwm...
/* MIT/X Consortium License
© 2017 Urja Rannikko <urjaman at gmail dot com>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
SPI erase check acceleration
----------------------------
SEND: [CMD] [1* len1] [1* len2] [3* len3] [1* compare_data] [len1 * send_data]
Send len1 bytes, then skip len2 bytes,
then read len3 bytes, check that each of them
matches data.
RECEIVE: [ACK] [3* offset]
@urjaman
urjaman / boston.kmap
Created June 13, 2015 14:32
Jolla boston.qmap equivalent kmap
# us.map
keymaps 0-2,4-6,8-9,12
alt_is_meta
strings as usual
keycode 1 = Escape
keycode 2 = one exclam
keycode 3 = two at at nul nul
keycode 4 = three numbersign
control keycode 4 = Escape
#!/bin/sh
sleep 420 # TODO: Make configurable autohibernate timeout
while true; do
sleep 30 # Poll frequency
current_now="$(cat /sys/class/power_supply/bq27500-0/current_now)"
if [ $current_now -gt 0 ]; then
#echo "charging"
continue
fi
grep -q ' On' /sys/devices/platform/soc-audio/PCM1773/dapm_widget
@urjaman
urjaman / gist:6902736
Last active December 25, 2015 02:29
Thoughts...
Goofy example we need to implement remotely (to be coded inside flashrom, sent to the programmer device):
uint8_t remote_function(uint24_t address, uint8_t data[], uint24_t len) {
uint24_t temp;
for (temp=0;temp<len;temp++) {
WRITE(ADDR1,B1);
WRITE(ADDR2,B2);
WRITE(ADDR3,B3);
WRITE(address+temp, data[temp])
uint8_t t2 = READ(ADDR4) & 0x40;
uint24_t t3 = 0xFFFFFF;
@urjaman
urjaman / gist:6461505
Last active December 22, 2015 10:49 — forked from Cloudef/gist:6460989
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main(int argc, char **argv) {
long int numbers[5] = { 0 };
long int highest = 0;
if (argc < 2 || strlen(argv[1]) < 5) {
fprintf(stderr, "5 digits minimum input string must be given\n");