Skip to content

Instantly share code, notes, and snippets.

@premek
premek / raspberry-camera-mirror.md
Last active Oct 29, 2020
Display raspberry camera video on HDMI screen using Raspberry OS Lite (no desktop, no X Window)
View raspberry-camera-mirror.md
  • sudo nano /boot/cmdline.txt and change console=tty1 to console=tty2
  • sudo nano /etc/rc.local and add /home/pi/autostart.sh &
cd
touch autostart.sh
chmod a+x autostart.sh
nano autostart.sh
View gemini-get-openssl.sh
# downloads a page from gemini server
(echo "gemini://gemini.circumlunar.space/docs/"; sleep 1) | openssl s_client -connect gemini.circumlunar.space:1965
@premek
premek / mv.sh
Last active Apr 17, 2021
Rename files in linux / bash using mv command without typing the full name two times
View mv.sh
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@premek
premek / dmx.ino
Created Jan 22, 2019
DMX USB, FastLED RGB LED stripe, OP-Z
View dmx.ino
#include <SoftwareSerial.h>
#include "DMXUSB.h"
#include <FastLED.h>
SoftwareSerial mySerial(10, 11); // RX, TX
#define LED_PIN LED_BUILTIN
#define DMXUSB_BAUDRATE 115200
#define NUM_LEDS 16
@premek
premek / mbank-sms.sh
Created Dec 1, 2018
A script to read SMSes via kdeconnect DBUS interface
View mbank-sms.sh
#!/usr/bin/env bash
DEV=`dbus-send --print-reply --dest=org.kde.kdeconnectd /modules/kdeconnect/devices org.freedesktop.DBus.Introspectable.Introspect | sed -n 's/.*node name="\(.*\)".*/\1/p'`
DATE=`date +'%d-%m-%Y'`
SMS="`dbus-send --print-reply --dest=org.kde.kdeconnectd /modules/kdeconnect/devices/$DEV org.kde.kdeconnect.device.conversations.activeConversations | grep -A3 "Operace ze dne $DATE" | sed 's/.*string "\|"$//'`"
echo $SMS
CODE=`echo $SMS | sed -ne 's/.* \([0-9]\{5,\}\) .*/\1/gp'`
View notification-translate.sh
#!/usr/bin/env bash
#
# translates any selection and displays the result in a notification.
# Install:
# - sudo apt install libnotify-bin xsel jq
# - you can copy this file to ~/bin, /usr/local/bin or somewhere and make it executable
# - configure a hotkey to execute it. You can use xbindkeys or your DE settings
in=$(xsel -o | sed "s/[\"'<>]//g")
notify-send --icon=info "$in" "$(wget -U "Mozilla/5.0" -qO - "http://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=en&dt=t&q=$in" |jq -r '.[0][0:]|.[]|.[1]')"
View xev-back-forward.txt
Outer window is 0x2800001, inner window is 0x2800002
ButtonPress event, serial 25, synthetic NO, window 0x2800001,
root 0xdf, subw 0x0, time 1502519276, (82,51), root:(884,310),
state 0x0, button 8, same_screen YES
ButtonRelease event, serial 25, synthetic NO, window 0x2800001,
root 0xdf, subw 0x0, time 1502519424, (82,51), root:(884,310),
state 0x0, button 8, same_screen YES
View sleep-at-work.sh
mpv https://www.youtube.com/watch?v=pF-3S-HTJSg -ao none -fullscreen -loop 0
View parser.lua
local lpeg = require "lpeg"
lpeg.locale(lpeg)
local S,C,Ct,Cc,Cg,Cb,Cf,Cmt,P,V =
lpeg.S, lpeg.C, lpeg.Ct, lpeg.Cc, lpeg.Cg, lpeg.Cb, lpeg.Cf, lpeg.Cmt,
lpeg.P, lpeg.V
local eof = -1
local sp = S" \t" ^0 + eof
local wh = S" \t\r\n" ^0 + eof
@premek
premek / AT
Created Apr 18, 2017
ESP8266 AT
View AT
AT+CWMODE=1
AT+CWJAP="SSID","secret"
AT+CIPSTART=1,"TCP","google.com",80
1,CONNECT
OK
AT+CIPSEND=1,9 (GET /)
OK
>
Recv 9 bytes
SEND OK