Skip to content

Instantly share code, notes, and snippets.

@0x4C4A
0x4C4A / joplinBulletListGenerator.py
Created February 11, 2021 19:57
Joplin / Markdown yearly bullet list template generator
import sys
import calendar
if len(sys.argv) != 2:
print("Expecting year to be input!")
sys.exit(1)
year = int(sys.argv[1])
weekNum = 1
@0x4C4A
0x4C4A / cecho
Last active May 20, 2020 13:26 — forked from eahrold/cecho
Color Read / Color Echo in bash
#!/bin/bash
colorread(){
case "$1" in
red|alert) local COLOR=$(printf "\\e[1;31m");;
green|attention) local COLOR=$(printf "\\e[1;32m");;
yellow|warn) local COLOR=$(printf "\\e[1;33m");;
blue|question) local COLOR=$(printf "\\e[1;34m");;
purple|info) local COLOR=$(printf "\\e[1;35m");;
cyan|notice) local COLOR=$(printf "\\e[1;36m");;
@0x4C4A
0x4C4A / google-sheets-interpolate.gs
Last active April 3, 2022 19:55
Interpolation function for google sheets
// Based on http://www.jamesphoughton.com/2012/10/10/linear-interpolation-with-dates-in.html
// Added some extra error checks, refactored a bit
// #####################
// How To Use
// 1. In google sheets, open Tools -> Script Editor
// 2. Copy this code in the Script Editor
// 3. Save
// 4. Enjoy using this as you would any other function in the sheet (the app will show that it doesn't know this function, but if you typed it correctly it will work)
// Example cell content: =interpolate(A2:A15, B2:B15, 13)
// #####################
@0x4C4A
0x4C4A / nextafter.js
Last active February 24, 2020 08:43
nextafter implemented in vanilla js without dependancies
// nextafter implemented in vanilla js without dependancies
// No license, use as you wish.
function nextafter(from, to){
if(isNaN(from) || isNaN(to))
return NaN;
if(from === to)
return to;
@0x4C4A
0x4C4A / displaySwitch.sh
Created August 31, 2017 19:35
Simple script to switch display configs with xrandr and restore multiscreen wallpaper with nitrogen
#!/bin/bash
if [ "$1" = "projector" ]; then
xrandr --output DP-1 --off
xrandr --output DP-3 --off
xrandr --output DP-5 --off
xrandr --output HDMI-0 --auto
elif [ "$1" = "screens" ]; then
xrandr --output HDMI-0 --off
xrandr --output DP-3 --auto --primary
@0x4C4A
0x4C4A / epsonProjectorOnOff.py
Created August 31, 2017 19:34
Python script to turn an Epson projector on or off via it's network cgi interface
#!/usr/bin/python3
import requests
import re
import time
import sys
projectorAddress = 'http://192.168.1.87'
username = 'EPSONWEB'
password = 'admin'
@0x4C4A
0x4C4A / open-with-sublime.nemo_action
Created June 15, 2017 17:32
Place in /usr/share/nemo/actions/ to enjoy an "Open with sublime" option in all your left click file menus.
[Nemo Action]
Name=Open with Sublime
Exec=subl %F
Extensions=any
Icon-Name=sublimetext
Quote=double
Selection=Any
@0x4C4A
0x4C4A / Auto-connect + auto-re-pair with BluetoothAudio
Last active April 16, 2017 12:48
A script to re-pair with a bluetooth audio receiver, when it's been paired to another device. I use this, to pair/auto-connect on boot.
#!/usr/bin/expect -f
# Runs bluetoothctl and attempts to connect with bluetooth device
# If connection fails, tries to unpair, pair and then connect again
# My specific device apparently can't be paired to multiple hosts, so it needs this
# Change this to whatever your device's bluetooth ID is
set ID "BC:FD:5B:00:14:28"
spawn "bluetoothctl"
@0x4C4A
0x4C4A / Mikrotik mass flash config for fixed IP devs
Created January 12, 2017 12:00
Mikrotik settings to route multiple devices with same ip (for mass flashing of fixed ip devices)
# Taken from (huge thanks to Sob) http://forum.mikrotik.com/viewtopic.php?t=107142#p532709
# This is for two ports only, however can be altered for whatever number the router has
/ip address
add address=192.168.1.11/24 interface=ether1 network=192.168.1.0
add address=192.168.1.12/24 interface=ether1 network=192.168.1.0
add address=192.168.0.1 interface=ether2 network=192.168.0.1
add address=192.168.0.1 interface=ether3 network=192.168.0.1
/ip firewall mangle
add action=mark-connection chain=prerouting dst-address=192.168.1.11 new-connection-mark=port1
@0x4C4A
0x4C4A / RTUCourseNameLookup.py
Created March 13, 2016 20:12
Retrieves course names from Riga Technical University course registry when given an array of valid course codes
### This script retrieves the RTU course names corresponding to the RTU course codes
### Works as of 13.03.16.
### Coded by Linards Jukmanis - 0x4C4A.com
# Needs python, urllib2, cookielib and regular expressions
import urllib2
import cookielib
import re
# Input your course codes