Skip to content

Instantly share code, notes, and snippets.

View Gipetto's full-sized avatar
💩
Doing the day-to-day.

Shawn Parker Gipetto

💩
Doing the day-to-day.
View GitHub Profile
@Gipetto
Gipetto / focusStealingMonitor.py
Last active September 24, 2025 22:00
Monitor MacOS for focus state changes.
#!/usr/bin/env python3
# Detect when window focus changes
#
# Tested with MacOS Sequoia 15.7
#
# Install requirements:
# pip3 install pyobjc-core pyobjc-framework-Cocoa
from AppKit import NSWorkspace
@Gipetto
Gipetto / generatePassword.ts
Created September 24, 2025 21:12
Random password generation in js/ts
const arrayShuffle = (input: string[]): string[] => {
let i = input.length;
const arr: string[] = [...input];
while (i != 0) {
const ri = Math.floor(Math.random() * i);
i--;
[arr[i], arr[ri]] = [arr[ri], arr[i]];
}
@Gipetto
Gipetto / gist:348c46500ff4e4c4ea51892b3d0e5839
Created December 12, 2018 01:54
Pihole Firewall black holes that should be part of Pihole itself...
iptables -A INPUT -p tcp --destination-port 443 -j REJECT --reject-with tcp-reset
iptables -A INPUT -p udp --destination-port 80 -j REJECT --reject-with icmp-port-unreachable
iptables -A INPUT -p udp --destination-port 443 -j REJECT --reject-with icmp-port-unreachable
ip6tables -A INPUT -p tcp --destination-port 443 -j REJECT --reject-with tcp-reset
ip6tables -A INPUT -p udp --destination-port 80 -j REJECT --reject-with icmp6-port-unreachable
ip6tables -A INPUT -p udp --destination-port 443 -j REJECT --reject-with icmp6-port-unreachable
iptables-save > /etc/iptables/rules.v4
ip6tables-save > /etc/iptables/rules.v6
@Gipetto
Gipetto / fax-to-email.js
Last active June 17, 2020 14:57
Single function Twilio Fax handling
/**
* !! Requires a SendGrid account & API Key.
* Sign up for the FREE account and create an API key.
* If you're receiving more than 100 faxes a day you
* shouldn't be entertaining the idea of a script like this...
*
* In the Function Instance view:
* - Paste this entire script
* - Set the url path for your Function to: /fax-to-email
*
@Gipetto
Gipetto / purchased-tracks-with-purchaser.py
Created October 31, 2017 03:06
Get a list of purchased tracks from your iTunes library that includes the purchaser. Not accurate for newer iTunes files (I couldn't find the purchaser with mutagen code)
#!/usr/bin/env python3
from plistlib import *
import mutagen as m
import urllib.parse
import pprint
import sys
import csv
import os
@Gipetto
Gipetto / chromeapp.sh
Last active December 17, 2015 09:09
Launch a new, clean and distinct instance of Google Chrome that cannot sync and does not do the first-run dance.
#! /bin/bash
set -e
[ -z $1 ] && dir='/tmp/foo' || dir=$1
chromedev="/Applications/Google Chrome Dev.app"
runChromeDev() {
(
@Gipetto
Gipetto / gist:4704578
Last active December 12, 2015 03:08
"Fix" postfix on OS X 10.8
#! /bin/bash
if [[ $EUID -ne 0 ]]; then
echo 'This script must be run as root'
exit 1
fi
launchctl unload -w /System/Library/LaunchDaemons/org.postfix.master.plist
mkdir -p /Library/Server/Mail/Data/spool/maildrop
/usr/sbin/postfix set-permissions
@Gipetto
Gipetto / gist:2989520
Created June 25, 2012 16:13
Allow shortcodes to be validated as proper numbers in OpenVBX. This is theoretical and untested.
<?php
/**
* Allow Shortcodes to be validated as normal phone numbers in OpenVBX
*
* Open the file `OpenVBX/libraries/PhoneNumber.php` and replace the function
* `PhoneNumbers::normalizePhoneNumbertoE164` with the function definition below.
* Then replace the `$shortcodes` array members with a list of numbers to
* be considered valid shortcodes.
*/
@Gipetto
Gipetto / gist:1925295
Created February 27, 2012 16:45
Proxy configuration for OpenVBX & Twilio-PHP api library
<?php
// template for setting CURL proxy options for OpenVBX
// add the configuration lines below to the file
// `OpenVBX/libraries/OpenVBX.php` on line 375 with the
// config below and then enter the values for your Proxy
// proxy type
$_proxy_type = 'HTTP'; // proxy type
// The address of your proxy server
@Gipetto
Gipetto / gist:1904153
Last active October 1, 2015 02:38
Alternate OpenVBX nginx server config. Slightly different than the sample included with OpenVBX right now and working on my nginx 0.8.54 + PHP 5.3.5 install
server {
listen 80;
server_name openvbx.tld;
access_log /var/www/logs/access.log;
error_log /var/www/logs/error.log;
location /(favicon.ico|robots.txt) {
access_log off;
log_not_found off;
error_page 404 /404;