This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Simple configuration reloading | |
You may have noticed that while you're editing the config, it's a little bit annoying to have to keep choosing the Reload Config menu item every time you make a change. We can fix that by adding a keyboard shortcut to reload the config: | |
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "R", function() | |
hs.reload() | |
end) | |
hs.alert.show("Config loaded") | |
We have now bound ⌘+⌥+⌃+R to a function that will reload the config and display a simple alert banner on the screen for a couple of seconds. | |
One important detail to call out here is that hs.reload() destroys the current Lua interpreter and creates a new one. If we had any code after hs.reload() in this function, it would not be called. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Function to process input (file or stdin) | |
process_input() { | |
while IFS= read -r line; do | |
# Perform any processing here | |
echo "$line" | |
done | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Script to record and tag spotify tracks, by Lloyd Moore *) | |
(* Make sure you are already recording in Audio Hijack Pro with a session called 'spotifySession' *) | |
tell application "Spotify" | |
set currentTrack to (current track) | |
set trackName to (name of currentTrack) | |
tell application "Audio Hijack Pro" | |
set theSession to my getSession() | |
end tell | |
repeat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
USER=god | |
PASS=allyourbasearebelongtous | |
FILE=`echo "$1" | sed 's_\(https://\)\(.*\)\(secure\.\)\(.*\)\(/.*\)_\2\4\5_'` | |
FILE=`echo "$1" | sed 's_\(https://\)\(boost4-\)*\(.*\)\(secure\.\)\(.*\)\(/.*\)_\3\5\6_'` | |
CMD='curl -Y 12800 -y 5 -C - -O http://'$USER':'$PASS'@'$FILE | |
echo $CMD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import math | |
def query_age(dataset): | |
""" | |
A query function that returns records with age less than 26. | |
""" | |
return [record for record in dataset if record['age'] < 26] | |
def query_trust(dataset): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# branch/current <- Branch with commits | |
# branch/main <- Branch that should have been branched from | |
# branch/other <- Branch that was actually branched from | |
git checkout branch/main | |
git checkout -b branch/correct | |
git rebase --onto branch/correct branch/other branch/current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[kube-master] | |
${k8s_master_name} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_end_point(view_class, endpoint, url, pk='id', pk_type='int'): | |
view = view_class() | |
app.add_url_rule(url, defaults={id: None}, view_func=view.as_view, methods=['GET',]) | |
app.add_url_rule(url, view_func=view.as_view, methods=['POST',]) | |
url = '%s/<%s:%s>' % (url, pk_type, pk) | |
app.add_url_rule(url, view_func=view.as_view, methods=['GET', 'PUT', 'DELETE']) | |
def register_url(name): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Allows you to temporarily connect to an ec2 instance, using | |
# awscli to first push your own key to the instance, then using ssh | |
# to log in to the instance. | |
# Assumes a public key called ec2.pub and a private | |
# key called ec2. | |
# Usage ec2_connect.sh i-12345679abcdef <other-user> <other-file> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The smallest starting point is the alpine image | |
FROM golang:alpine as builder | |
RUN apk update && apk add git && add ca-certificates | |
RUN adduser -D -g '' appuser | |
COPY . $GOPATH/src/mypackage/myapp/ | |
WORKDIR $GOPATH/src/mypackage/myapp/ | |
RUN go get -d -v | |
RUN CGO_ENABLE=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/hello |
NewerOlder