Skip to content

Instantly share code, notes, and snippets.

@bitdivine
bitdivine / bluetooth-screen-lock
Last active August 12, 2022 06:49
Lock Apple Mac screen when bluetooth device, such as a phone, goes out of range
# MAC=xx-xx-xx-xx-xx-xx
MAX_IDLE=10
while true ; do
idle=$(/usr/sbin/ioreg -c IOHIDSystem | /usr/bin/awk '/HIDIdleTime/ {print int($NF/1000000000); exit}')
if (( idle < MAX_IDLE )) ; then
sleep $(( MAX_IDLE - idle + 1 ))
else
blueutil --inquiry 4 | grep -E "$MAC" || {
echo "Locking screen..."
pmset displaysleepnow
@bitdivine
bitdivine / install-terraform.sh
Last active September 10, 2017 10:05
Install the latest version of terraform
#!/bin/sh
set -eux
set -o pipefail
INSTALL_DIR="${INSTALL_DIR:-/opt/terraform/bin}"
# Get the version to install, degrading gracefully depending on which tools are installed:
test -n "${VERSION:-}" \
|| VERSION="$(curl https://releases.hashicorp.com/index.json | jmespath "terraform.versions.*.version" --output text | sort --version-sort | tail -n1)" \
|| VERSION="$(curl https://releases.hashicorp.com/terraform/ | grep terraform_ | sed 's/.*href.*>terraform_//g;s/<.*//g' | sort --version-sort | tail -n1)"
@mrdziuban
mrdziuban / scala_repl.rb
Last active March 6, 2018 07:18
Start a Scala REPL with the highest version of each jar in $HOME/.ivy2/cache on the classpath
#!/usr/bin/env ruby
################################################################################
# #
# Starts a Scala REPL with the highest version of each jar in #
# $HOME/.ivy2/cache on the classpath. #
# #
# See below for installation instructions #
# #
################################################################################
@bitdivine
bitdivine / aws-fingerprint.sh
Created March 14, 2017 05:20
Get the AWS ssh key fingerprint from a public key
openssl rsa -RSAPublicKey_in -in <(ssh-keygen -f ~/.ssh/id_rsa.pub -e -m PEM) -inform PEM -outform DER 2>/dev/null | openssl md5 -c | awk '{print $2}'
@bitdivine
bitdivine / inf_refresh_recursive.sql
Last active October 14, 2019 04:38
Refresh postgres materialized views recursively
-- Refresh materialized views recursively
-- DEPENDS:
-- List the tables that a view depends on.
-- Thanks to Dave: http://stackoverflow.com/questions/4229468/getting-a-list-of-tables-that-a-view-table-depends-on-in-postgresql
create or replace function inf_view_dependencies(v text)
returns table (kind text, name text) as $$
SELECT cl_d.relkind::text as kind
, cl_d.relname::text AS name
FROM pg_rewrite AS r
@bitdivine
bitdivine / shebang.sh
Created May 9, 2016 14:22
shebang arguments
#!/usr/bin/gawk {system("my command here " FILENAME); exit}
@roachhd
roachhd / README.md
Last active November 13, 2024 20:51
EMOJI cheatsheet 😛😳😗😓🙉😸🙈🙊😽💀💢💥✨💏👫👄👃👀👛👛🗼🔮🔮🎄🎅👻

EMOJI CHEAT SHEET

Emoji emoticons listed on this page are supported on Campfire, GitHub, Basecamp, Redbooth, Trac, Flowdock, Sprint.ly, Kandan, Textbox.io, Kippt, Redmine, JabbR, Trello, Hall, plug.dj, Qiita, Zendesk, Ruby China, Grove, Idobata, NodeBB Forums, Slack, Streamup, OrganisedMinds, Hackpad, Cryptbin, Kato, Reportedly, Cheerful Ghost, IRCCloud, Dashcube, MyVideoGameList, Subrosa, Sococo, Quip, And Bang, Bonusly, Discourse, Ello, and Twemoji Awesome. However some of the emoji codes are not super easy to remember, so here is a little cheat sheet. ✈ Got flash enabled? Click the emoji code and it will be copied to your clipboard.

People

:bowtie: 😄

@wacko
wacko / gist:5577187
Last active July 13, 2024 00:48
SSH between Mac OS X host and Virtual Box guest

On Mac OS (host):

Shutdown your VM and do:

VirtualBox > Settings > Network > Add (you will get vboxnet0)

On a terminal ifconfig will show you new interface vboxnet0

VM's Settings > System > check "Enable I/O APIC." VM's Settings > Network > Adapter 2 > host-only vboxnet0

@amokan
amokan / gist:3881064
Created October 12, 2012 19:36
jenkins-cli commands (v1.485)
build
Builds a job, and optionally waits until its completion.
cancel-quiet-down
Cancel the effect of the "quiet-down" command.
clear-queue
Clears the build queue
connect-node
Reconnect to a node
copy-job
Copies a job.
@kasparsd
kasparsd / wordpress-plugin-svn-to-git.md
Last active August 16, 2024 17:33
Using Git with Subversion Mirroring for WordPress Plugin Development