Skip to content

Instantly share code, notes, and snippets.

View digiltd's full-sized avatar

Sam Turner digiltd

View GitHub Profile
$ /usr/libexec/PlistBuddy -c "Set :variables:server \"ABC-XYZ\"" info.plist
@digiltd
digiltd / index.php
Last active July 1, 2016 15:33
Random background image selected from a folder containing an unknown amount of images
<?php
$files = glob('images/*.*');
$file = array_rand($files);
?>
<html>
<head>
<style type="text/css">
body {
background-size: cover;
@digiltd
digiltd / finder-window-count.applescript
Last active November 3, 2022 13:23
Count the amount of finder windows
property finderwindownumber : 1
tell application "Finder"
set TotalNumberOfFinderWindows to (count of (every window where visible is true))
if TotalNumberOfFinderWindows is greater than 0 then
tell application "Finder"
select window finderwindownumber
activate
set finderwindownumber to finderwindownumber + 1
if finderwindownumber is greater than TotalNumberOfFinderWindows then
set finderwindownumber to 1
@digiltd
digiltd / insert-subpages.php
Last active May 13, 2016 10:29
Kirby - Getting content from subpages
<?php foreach($page->children() as $section): ?>
<h1><?php echo $section->title()->html() ?></h1>
<?php echo $section->text()->kirbytext() ?>
<?php endforeach ?>
#!/usr/bin/env bash
# Script to toggle ad-blocking on/off. Save in /usr/local/bin
# Source https://pi-hole.net/forums/topic/quickly-enabledisable-pi-hole-from-your-phone/
# Toggle with $ pihole-toggle.sh
list=/etc/pihole/gravity.list
if [[ -f $list ]];then
mv $list $list.off
@digiltd
digiltd / play-random-sound.applescript
Last active March 11, 2016 01:44
Play random file from a folder of files
property soundsDirectory : POSIX file "/Users/digiltd/Dropbox/folder-full-of-sound-files/" as alias
tell application "System Events" to ¬
set soundFile to get POSIX path of (some item of soundsDirectory as alias)
do shell script "afplay " & quoted form of soundFile
@digiltd
digiltd / speak-the-time.applescript
Created March 11, 2016 01:34
Get and then speak the current time and date
(*
Speaks the date and time of day
Copyright 2008 Apple Inc. All rights reserved.
You may incorporate this Apple sample code into your program(s) without
restriction. This Apple sample code has been provided "AS IS" and the
responsibility for its operation is yours. You are not permitted to
redistribute this Apple sample code as "Apple sample code" after having
made changes. If you're going to redistribute the code, we require
@digiltd
digiltd / detect-displays.applescript
Last active March 11, 2016 01:33
Detect displays with a not very elegant AppleScript macro
tell application "System Preferences"
activate
reveal pane "com.apple.preference.displays"
end tell
delay 0.5
tell application "System Events"
tell process "System Preferences"
try --don't even consider not using a try block!
@digiltd
digiltd / open-nvALT-note-in-Marked-2.applescript
Last active January 24, 2016 16:33
Open the current note in nvALT in Marked 2
tell application "System Events" to tell process "nvALT"
set p to value of text field 1 of group 1 of toolbar 1 of window 1
set homeDir to (path to home folder from user domain as Unicode text)
-- replace "Dropbox:_SYNC:nValt:" with your notes folder and change ".markdown" if needed
set f to (homeDir & "Dropbox:_SYNC:nValt:" & p & ".markdown") as alias
end tell
tell application "Marked 2"
open f
activate
end tell
@digiltd
digiltd / remotebuddy-get-tunnelblick-configurations.applescript
Last active January 24, 2016 16:34
Display Tunnelblick configuration in RemoteBuddy
set remotebuddy_list to {}
tell application "Tunnelblick"
set vpn_list to get name of configurations
end tell
repeat with i from 1 to count of vpn_list
set ind_configuration to item i of vpn_list
set end of remotebuddy_list to i
set end of remotebuddy_list to ind_configuration