Skip to content

Instantly share code, notes, and snippets.

View deanishe's full-sized avatar

Dean Jackson deanishe

View GitHub Profile
@deanishe
deanishe / alfred_alacritty_plugin.applescript
Created September 5, 2020 14:38
Alfred plugin to run terminal commands in Alacritty
on alacritty_win()
set _running to (application "Alacritty" is running)
tell application "Alacritty" to activate
tell application "System Events"
repeat while (name of first application process whose frontmost is true) is not "alacritty"
delay 0.05
end repeat
set _alacritty to first application process whose frontmost is true
-- If Alacritty was running, create a new window to run command
@deanishe
deanishe / tag.py
Created April 27, 2017 23:02
Tag, untag and filter by tag on macOS
#!/usr/bin/env python
# encoding: utf-8
# vim: ft=python
#
# tag.py
#
# Copyright (c) 2015 Dean Jackson <deanishe@deanishe.net>
#
# MIT Licence. See http://opensource.org/licenses/MIT
#
@deanishe
deanishe / text_table.py
Created December 26, 2016 09:39
Simple table printer for shell output
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2016 Dean Jackson <deanishe@deanishe.net>
#
# MIT Licence. See http://opensource.org/licenses/MIT
#
# Created on 2016-12-19
#
@deanishe
deanishe / aptparse.zsh
Created November 1, 2016 10:45
Extract installed package names from apt-get output
#!/usr/bin/env zsh
pkgs=()
packages() {
while read ln; do
echo -n "$( echo $ln | cut -d " " -f2 ) "
done
}
@deanishe
deanishe / MoveMouse.js
Created August 21, 2016 12:13
JXA: Move mouse to centre of frontmost window
ObjC.import('stdlib')
ObjC.import('CoreGraphics');
// Move mouse cursor to specified position
function moveMouse(x, y) {
var pos = $.CGPointMake(x, y);
var event = $.CGEventCreateMouseEvent(null, $.kCGEventMouseMoved, pos, $.kCGMouseButtonLeft);
$.CGEventPost($.kCGHIDEventTap, event);
}
@deanishe
deanishe / rename_workflow.py
Last active December 20, 2022 14:05
Rename Alfred workflow folders after their Bundle IDs
#!/usr/bin/python
# encoding: utf-8
#
# rename_workflow
#
# Copyright (c) 2015 Dean Jackson <deanishe@deanishe.net>
#
# MIT Licence. See http://opensource.org/licenses/MIT
#
# Created on 2015-08-02
@deanishe
deanishe / packal.py
Last active April 28, 2019 18:48
Packal.org Python API library
#!/usr/bin/python
# encoding: utf-8
#
# Copyright © 2015 deanishe@deanishe.net
#
# MIT Licence. See http://opensource.org/licenses/MIT
#
# Created on 2015-10-10
#
@deanishe
deanishe / anki.py
Last active August 29, 2015 14:19
Demonstration of Alfred Script Filter interaction model for entering flash cards
#!/usr/bin/python
# encoding: utf-8
#
# Copyright © 2015 Dean Jackson <deanishe@deanishe.net>
#
# MIT Licence. See http://opensource.org/licenses/MIT
#
# Created on 2015-04-20
#
@deanishe
deanishe / youtube-to-quicktime.sh
Created March 2, 2015 20:00
Open Current YouTube Video in QuickTime Player (or whatever)
#!/bin/bash -e
# Instead of watching YouTube videos in your browser, stream them in
# QuickTime Player (or VLC/MPlayer etc.)
#
# youtube-dl supports hundreds of websites, so it will probably work
# for a lot of video sites.
# See https://rg3.github.io/youtube-dl/
# Get URL of current tab in browser
@deanishe
deanishe / toggle-alfred-theme.bash
Last active August 24, 2020 03:08
Automatically toggle Alfred dark/light themes at sunset/sunrise. You need to edit the location settings before use.
#!/bin/bash -e
# Wrapper for the toggle_alfred_theme.py script at
# https://gist.github.com/deanishe/ce442c3a768adedc9c39
# (where this script also comes from)
#
# The purpose of this wrapper is to enable you to update the Python script
# without having to edit the script to change the settings each time. You keep
# them in here instead, and this script should hopefully prove dumb enough
# to require little updating...