Skip to content

Instantly share code, notes, and snippets.

View gaqzi's full-sized avatar

Björn Andersson gaqzi

View GitHub Profile
@gaqzi
gaqzi / 01-README.md
Created April 15, 2024 09:43
Mute/unmute the current system microphone using AppleScript

To use this in Alfred create a new workflow and then create a new action Run Script and specify osascript (Javascript) and paste in the below script.

See global-microphone-muteunmute-shortcuts for more context.

@gaqzi
gaqzi / 01-README.md
Last active April 15, 2024 09:40
Open the current playing song on Spotify on Genius.com

To use this in Alfred create a new workflow and then create a new action Run NSAppleScript and paste in the below script.

Note: If you want to run this on the CLI you can remove the on alfred_script(q) and end alfred_script and add #!/usr/bin/env osascript as the first line to run it from the CLI.

See http://sanitarium.se/blog/2024/04/15/day-to-day-automation-using-alfred/#spotify-controller for more context.

There are a couple of different things going on in the pipeline to open the browser:

  • sed -E 's|([ ]+)|-|g'
  • Replace spaces with -
@gaqzi
gaqzi / 1-README.md
Created October 22, 2021 00:35
Control Spotify using AppleScript
@gaqzi
gaqzi / mock_traceback.go
Last active March 17, 2021 17:40
A first pass on something to make stretchr/mock outputs easier to deal with
// Tracebacker implements the methods required to satisfy stretchr/mock's Test() interface
// Usage:
// my := new(MockMy)
// my.Test(&Tracebacker(t)
type Tracebacker struct {
t *testing.T
}
func (t *Tracebacker) Logf(format string, args ...interface{}) {
t.t.Logf(format, args...)
@gaqzi
gaqzi / git-merge-train
Created March 5, 2021 03:24
A script to help merge multiple branches based off each other. For dealing with slow reviews but still trying to make small behavior or structural change PRs.
#!/bin/bash
: ${DRY_RUN:=true}
if [ $# -lt 2 ]; then
echo "Usage: git merge-train <first branch> <branch based on first branch> [... branches based on previous]"
exit 0
fi
if [ "${DRY_RUN}" != 'false' ]; then
@gaqzi
gaqzi / json_pp_stream.py
Last active March 5, 2021 15:32
To pretty-print logs of JSON. Can be used like: `docker-compose logs -f myapp | json_pp_stream.py`. Made a Go version as well: https://github.com/gaqzi/log-viewer/
#!/usr/bin/env python3
import json
import sys
try:
from pygments import highlight, lexers, formatters
def json_formatter(line: str) -> str:
return highlight(line, lexers.JsonLexer(), formatters.TerminalFormatter())
SELECT mmsi_positions_archive.id AS mmsi_positions_archive_id,
mmsi_positions_archive.position_id AS mmsi_positions_archive_position_id,
mmsi_positions_archive.previous_id AS mmsi_positions_archive_previous_id,
mmsi_positions_archive.mmsi AS mmsi_positions_archive_mmsi,
mmsi_positions_archive.collection_type AS mmsi_positions_archive_collection_type,
mmsi_positions_archive.accuracy AS mmsi_positions_archive_accuracy,
mmsi_positions_archive.course AS mmsi_positions_archive_course,
mmsi_positions_archive.heading AS mmsi_positions_archive_heading,
mmsi_positions_archive.maneuver AS mmsi_positions_archive_maneuver,
mmsi_positions_archive.rate_of_turn AS mmsi_positions_archive_rate_of_turn,
package com.example;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
@gaqzi
gaqzi / gfm-formatter.py
Last active June 3, 2022 04:20
A way to re-use the GitHub syntax highlighter for your own site. Send it through their API, use their stylesheet and done.
#!/usr/bin/env python
# Takes the path to a local file and formats it using GitHub's raw Markdown API,
# then converts the returned HTML to their table format.
from pathlib import Path
from sys import argv
import requests # $ pip install requests
defmodule PingPonger do
def loop do
receive do
{:pong, sender} ->
IO.puts("Pong!")
send(sender, {:ping, self})
{:ping, sender} ->
IO.puts("Ping?")
send(sender, {:pong, self})
:exit ->