Skip to content

Instantly share code, notes, and snippets.

View ivanrad's full-sized avatar

ivanrad

  • Dublin, Ireland
View GitHub Profile
@ivanrad
ivanrad / mb.c
Created February 3, 2024 15:15
linknlink emotion modbus
// cc -Wall mb.c $(pkg-config --cflags --libs libmodbus)
//
#include <stdio.h>
#include <stdlib.h>
#include <modbus.h>
int main(int argc, char **argv) {
modbus_t *mb;
uint16_t motion, no_motion;
@ivanrad
ivanrad / rc
Created August 26, 2023 16:42
ssh rc
#!/usr/bin/env bash
if [ -S "$SSH_AUTH_SOCK" ]; then
ln -sf "$SSH_AUTH_SOCK" /tmp/ssh_auth_sock
fi
@ivanrad
ivanrad / git-co-authored
Created April 10, 2023 11:05
git: show only co-authored commits
#!/bin/sh
exec git log --grep='Co-authored-by' --format='%h %s %(trailers:key=Co-authored-by,separator=%x2C)'
@ivanrad
ivanrad / openvscode_server@.service
Created July 21, 2022 10:45
systemd unit file for OpenVSCode server
[Unit]
Description=openvscode_server
After=network.target
[Service]
Type=exec
ExecStart=/path/to/openvscode-server/bin/openvscode-server \
--host 127.0.0.1 \
--connection-token-file /path/to/.openvscode_serverrc \
--telemetry-level off
@ivanrad
ivanrad / growl.sh
Created July 19, 2022 23:09
growl style notifications using OSC 9
#!/usr/bin/env bash
if [ $# == 0 ]; then
msg=$(cat -)
else
msg="$@"
fi
if [ -n "$TMUX" ]; then
client_tty=$(tmux display-message -p '#{client_tty}')
@ivanrad
ivanrad / yank.sh
Created July 10, 2022 12:15
copy to clipboard using OSC 52 terminal sequence
#!/usr/bin/env bash
set -e
buf=$(cat "${@:--}" | base64 | tr -d '\n')
# OSC 52 term seq
seq="\033]52;c;${buf}\a"
if [ -n "${SSH_TTY}" ]; then
printf "$seq" > "${SSH_TTY}"
elif [ -n "${TMUX}" ]; then
client_tty=$(tmux display-message -p '#{client_tty}')
@ivanrad
ivanrad / fixhda.sh
Last active July 26, 2021 20:19
fixhda
#!/bin/sh
for i in /sys/bus/pci/devices/*; do
if [ -s "$i/label" ] && grep -q 'Sound' "$i/label"; then
echo 1 >> "$i/remove"
fi
done
echo 1 >> /sys/bus/pci/rescan
@ivanrad
ivanrad / lazy_loading_feature_test.html
Created May 11, 2019 09:15
lazy loading feature test
<!doctype html>
<body>
<script type='text/javascript'>
if ('loading' in HTMLImageElement.prototype) {
console.log('lazy loading supported...');
} else {
console.log('needs polyfill...');
}
</script>
</body>
[Unit]
Description=Console blank
[Service]
Type=oneshot
Environment=TERM=linux
StandardOutput=tty
TTYPath=/dev/console
ExecStart=/usr/bin/setterm -blank 2
@ivanrad
ivanrad / fix_font_smoothing.sh
Created September 28, 2018 21:36
Enable macOS Mojave font smoothing
#!/usr/bin/env bash
defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO