Skip to content

Instantly share code, notes, and snippets.

@kirkins
kirkins / .emacs
Created August 12, 2017 21:30
Emacs remote connection
;; from https://stackoverflow.com/a/20633678/773263
(defun connect-codio ()
(interactive)
(dired "/codio@forwarding.codio.com#50219:/"))
@kirkins
kirkins / .emacs
Created August 14, 2017 18:22
emacs org mode setup
(require 'org)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done 'time)
(setq org-agenda-files (list "~/org/work.org"))
@kirkins
kirkins / emoji.sh
Created August 21, 2017 18:12
Get all emoji
#!/usr/bin/env bash
#
# Get a list of all Unicode emoji in version 6.0
wget -O output.txt http://www.unicode.org/Public/emoji/6.0/emoji-data.txt
sed -i '/^#/ d' output.txt # Remove comments
sed -i 's/.*(//' output.txt # Remove columns not needed
sed -i 's|[(),]||g' output.txt # Remove brackets
sed -i 's/\(.*[^ ]\)[ ]*\(.*\)/\2 \1/' output.txt # Move first column to last
daemon off;
worker_processes auto;
error_log /var/log/nginx/error.log debug;
events {
worker_connections 1024;
}
@kirkins
kirkins / get.py
Created September 3, 2017 19:16
A script that downloads banned youtube videos shared by a twitter user
#!/usr/bin/env python
#
# A python that fetches the 200 latest tweets from a user
# then downloads any youtube video linked to.
#
# User can be changed with the variable below
user="YoutubeSandbox"
import re
@kirkins
kirkins / scan.sh
Last active September 16, 2019 18:26
Second version of script to turn nmcli into a json object
#!/usr/bin/env bash
#
# Scan availible wifi networks
# https://unix.stackexchange.com/questions/399222/jq-parse-colon-separated-value-pairs
# TODO see if you can pipe this directly into jq
nmcli_output=$(nmcli --mode multiline dev wifi)
# set all variables from nmcli
network=$(echo "$nmcli_output" | grep SSID: \
@kirkins
kirkins / scan.sh
Last active October 19, 2017 21:50
First version of nmcli_output to json
#!/usr/bin/env bash
#
# Scan availible wifi networks
# https://unix.stackexchange.com/questions/399222/jq-parse-colon-separated-value-pairs
nmcli_output=$(nmcli dev wifi | sed '$ d' | sed '1d')
#TODO use multi-line version of nmcli to better parse
# function for parsing nmcli output
@kirkins
kirkins / wifi.sh
Created October 27, 2017 17:22
Scan wifi without nmcli
#!/usr/bin/env bash
#
# Scan availible wifi networks
wifi=$(ifconfig -a | grep wl | cut -d' ' -f1)
ifconfig $wifi up
scan=$(iwlist $wifi scan)
essid=$(echo "$scan" | grep ESSID | cut -f2 -d":" | tr -d '"')
encryption=$(echo "$scan" | grep "Encryption key" | cut -f2 -d":")
@kirkins
kirkins / .bashrc
Last active November 15, 2017 18:08
Script that will try ssh until is succeeds
tryssh()
{
until ssh $1; do
sleep 5
done
}
@kirkins
kirkins / .bashrc
Last active November 18, 2017 23:42
Hue commands for .bashrc
# Add credentials and IP
# Use: hue <light_number/room_number> <brightness>
hue_user=
hue_ip=
hue() {
curl -d "{\"bri\":$2 }" -X PUT $hue_ip/api/$hue_user/lights/$1/state
}