Skip to content

Instantly share code, notes, and snippets.

@Diegus83
Diegus83 / backup.sh
Last active August 24, 2019 22:58
Simple pihole backup via SCP
#!/bin/bash
####################################
#
# Backup via SCP
#
# Executes daily as defined by crontab -e
# 0 0 * * * bash /home/pi/scripts/backup.sh
#
# Don't forget to generate an ssh key and add it to the mac mini
@Diegus83
Diegus83 / move_the_mouse.sh
Created April 8, 2019 15:41
# move the mouse around to avoid the inactivity timeout on some websites
# move the mouse around to avoid the inactivity timeout on some websites
# https://github.com/facastagnini
# requires cliclick
# brew install cliclick
while true
do
  /usr/local/bin/cliclick "m:12,34"
  sleep 60
  /usr/local/bin/cliclick "m:120,34"
@Diegus83
Diegus83 / README.md
Last active August 24, 2020 23:54 — forked from carestad/README.md
TTML to SRT conversion. Written in PHP.

ttml2srt.php

This is a simple script for converting TTML subtitle files to SRT ones. Tested with TTML files on tv.nrk.no.

It assumes the data is structured like this:

<tt>
 <body>
  <div>
   <p>(...)</p>
@Diegus83
Diegus83 / radios.sh
Created September 16, 2019 23:53
Script para escuchar radios argnetinas desde la terminal
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Uso radios.sh nombre_radio"
echo "Requiere VLC (brew install vlc)"
echo "radios.sh --help para ver las radios disponibles"
else
echo "$(cat $0 | grep "#" | grep -m 1 -i $1 | cut -d" " -f2 | vlc -Idummy --quiet -)"
fi
@Diegus83
Diegus83 / sleep.json
Created September 23, 2019 21:05
Karabiner mod to sleep MacBook with external monitor
{
"title": "Diego",
"rules": [
{
"description": "Hold down left control to sleep",
"manipulators": [
{
"from": {
"key_code": "left_control",
"modifiers": {
@Diegus83
Diegus83 / findPID.py
Created December 10, 2019 14:55
Find which PID a dialog belongs to in macOS
#!/usr/bin/python2.7
#original source: https://superuser.com/questions/902869/how-to-identify-which-process-is-running-which-window-in-mac-os-x
import Quartz
import time
from Foundation import NSSet, NSMutableSet
def transformWindowData(data):
list1 = []
for v in data:
@Diegus83
Diegus83 / Disable SMBv3 server support in macOS
Last active September 7, 2020 15:08
Disable SMBv3 server support in macOS
Set your macOS server to deny SMB 3 connections
Validate negotiate requests are an SMB 3 feature that clients initiate. To prevent clients from making these requests, you can set your macOS server to accept only SMB 2 connections. A bit-field in server preferences controls Server Dialect. The keyword for this bit-field is ProtocolVersionMap. It uses only three bits:
Value Meaning
1 Support SMB 1
2 Support SMB 2
4 Support SMB 3
To support multiple dialects, combine bits.
@Diegus83
Diegus83 / Record System Audio
Last active January 5, 2021 14:31
How to do Quicktime screen recordings with system audio
brew cask install blackhole
#https://github.com/ExistentialAudio/BlackHole
Record System Audio
Setup Multi-output Device
In Audio Midi Setup->Audio Devices Right-click on the newly created Multi-output and select "Use This Device For Sound Output"
Open digital audio workstation (DAW) such as GarageBand or QuickTime and set input device to "BlackHole"
Set track to input from channel 1-2
Play audio from another application and monitor or record in your DAW.
@Diegus83
Diegus83 / conver font suicases.txt
Last active October 27, 2020 20:56
Convert font suitcases (resource forks) in modern macOS
First extract the suitcases to regular files with dataforks
-----------------------------------------------------------------
(Source: http://xahlee.info/UnixResource_dir/macosx.html)
(Source: http://fondu.sourceforge.net/)
(Source: https://stackoverflow.com/questions/7412462/using-os-9-resource-fork-fonts-in-css-with-font-face/64561713#64561713)
This is a very old file format where the font information is only contained in the resource fork, not the data fork, so the files seem empty to most modern apps.
First we can group them all in a single directory taking advantage of the find command, because find doesn't see the resource fork and consider the file empty, we create a new directory in the user home and copy all the suitcases there:
@Diegus83
Diegus83 / extract ssa subtitles.workflow
Last active November 5, 2020 16:20
macOS folder action to extract ssa subtitles from MKV files recursively as srt
# add a Run shell script module in automator, pass input as arguments. Set as a folder action on the appropiate folders.
for f in "$@"
do
if [ ${f: -4} == ".mkv" ]
then
/usr/local/bin/ffmpeg -hide_banner -y -loglevel quiet -i "$f" -map 0:s? "${f%.*}".en.srt
fi
done