Skip to content

Instantly share code, notes, and snippets.

@aarmot
aarmot / gree-codes.sh
Last active August 17, 2023 12:55
Generate Gree heatpump IR codes to be used in LIRC
#!/bin/bash
# Generate Gree heat pump IR codes, according to
# https://forum.mysensors.org/uploads/files/1469565493670-gree.pdf
# How to use raw codes in LIRC see e.g.
# https://github.com/suikammd/AirConditioner-Homekit/
MSG_SPACE=20000
HDR_MARK=9000
HDR_SPACE=4500
@aarmot
aarmot / statfs
Created May 27, 2022 06:44
Get filesystem usage in C
#include <sys/vfs.h>
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char **argv) {
if (argc < 2) exit(EXIT_FAILURE);
struct statfs info;
if (statfs(argv[1], &info) == 0) {
printf("%s - block size: %ld,"
" total data blocks: %ld,"
@aarmot
aarmot / screenshots.sh
Created October 14, 2014 18:54
Take multiple screenshots from linux command line. Uses xdotool and scrot
#!/bin/sh
# Ubuntu:
# sudo apt-get install xdotool
while [ "$((i+=1))" != 100 ]; do
sleep 120
xdotool key F5
sleep 60
scrot
@aarmot
aarmot / bbb-customsetup.sh
Created December 29, 2013 17:19
BeagleBone Black Ubuntu custom setup
# To reduce eMMC wear remap write-intensive directories to memory fs
# Mount /tmp into tmpfs
sudo echo "tmpfs /tmp tmpfs defaults 0 0" >> /etc/fstab
sudo rm -rf /var/tmp && ln -s /tmp /var/tmp
# Mount /var/log into tmpfs
sudo cat > /etc/init/mount-log.conf <<EOT
@aarmot
aarmot / redir.lua
Created August 12, 2013 14:53
Primitive daemon, which listens on port 80 and replies with http redirect Requires luasocket and luadaemon
-- HTTP redirect daemon
local port = 80
local redir = "HTTP/1.0 301 Moved Permanently\nLocation: https://example.org/\n\n"
local socket = require("socket")
local daemon = require("daemon")
daemon.daemonize()
local server = assert(socket.bind("*", port))
@aarmot
aarmot / adblock
Last active September 7, 2016 18:04
Adblock skript for OpenWrt. Tested on Attitude Adjustment 12.09
#!/bin/sh /etc/rc.common
# Copy this skript to /etc/init.d/adblock and enable:
# chmod +x /etc/init.d/adblock
# /etc/init.d/adblock enable
START=90
ADS='http://pgl.yoyo.org/as/serverlist.php?hostformat=dnsmasq&showintro=0&mimetype=plaintext'
@aarmot
aarmot / 30-minidlna
Last active October 12, 2023 07:11
Hotplug2 script to automatically start minidlna every time the USB disk gets attached and stop minidlna when disk gets detached. Configuration parameters are at the top of script.
#!/bin/sh
# Hotlug2 script which starts minidlna when USB disk gets attached
# [email protected]
# Sharing: GPLv3 or later
# To handle minidlna startup through hotplug you should disable minidlna autostart
# /etc/init.d/minidlna disable
# and copy current script to /etc/hotplug.d/block/30-minidlna
@aarmot
aarmot / nas-install.sh
Last active December 16, 2015 01:49
OpenWRT NAS conf
#!/bin/sh
# Configure OpenWrt NAS
# Attached USB drive is accessible through
# 1. http://nasbox/A
# 2. CIFS - //nasbox/A
# 3. DLNA
# where "nasbox" is your router name and "A" represents one of the mountpoints below
@aarmot
aarmot / .SciTEUser.properties
Created February 19, 2013 23:13
SciTE properties for GNU assembler MSP430 source syntax highlighting. Copy the content to .SciTEUser.properties and modify to your liking.
# Show .s and .S asm sources in file open dialog
source.files=*.asm;*.c;*.cc;*.cpp;*.cxx;*.cs;*.h;*.hh;*.hxx;*.hpp;\
*.rc;*.rc2;*.def;*.java;*.js;*.py;*.pl;*.rb;*.cgi;*.lua;*.conf;\
Make*;make*;*.mak;*.properties;*.html;*.xml;*.iface;*.bat;\
*.s;*.S;*.dump;*.haml
# GNU asm file
file.patterns.gasm=*.s;*.S;*.dump
filter.gasm=GNU Assembler (asm)|$(file.patterns.gasm)|
lexer.$(file.patterns.gasm)=asm
@aarmot
aarmot / Makefile
Created January 23, 2013 11:27
Makefile for MSP430 development in Linux. Inspiration taken from http://sourceforge.net/apps/mediawiki/mspgcc/index.php?title=Example:Makefile
#
# Makefile for msp430
#
# 'make' builds everything
# 'make lst' generates assembly listings of each source
# 'make dump' generates assembler dump of target
# 'make burn' flashes target into launchpad
# 'make clean' deletes everything except source files and Makefile
#
# You need to set TARGET, MCU and SOURCES for your project.