Skip to content

Instantly share code, notes, and snippets.

@withakay
withakay / update-authorised-keys.sh
Created Dec 11, 2017
Update authorized keys on remote server using known_hosts
View update-authorised-keys.sh
#!/usr/bin/env bash
# Before running remember to generate a new key and update this script with the name (currently id_rsa_4096.pub)
awk -F'[ ,:]' '/^[0-9a-zA-Z]/{sub(/\[/,"",$1); sub(/\]/,"",$1); print $1}' ~/.ssh/known_hosts | uniq > _hosts
# A script to push a key to the only argument, a remote server.
while read h; do
echo "$h"
@withakay
withakay / README.md
Last active Jul 5, 2018 — forked from ringe/README.md
KVM QCOW2 Live backup
View README.md

Live backup of KVM virtual machines

This script will let you make backups of live VMs running on KVM, using libvirt.

The backup job will suspend the VM for the time it takes to copy the RAM to disk.

Credits: Luca Lazzeroni

Edited to detect and check the image format is qcow2 using qemu-img, rather than rely on the file extension being .qcow2

View clonegroups.sh
#!/usr/bin/env bash
# A quick and dirty script to add one users groups to another
# Tested on Ubuntu 16.04
if [[ -z "$1" || -z "$2" ]]; then
echo "USAGE:"
echo " ./clonegroups.sh <source_user> <dest_user>"
exit 0;
fi
View atom.xml
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example Feed</title>
<subtitle>Insert witty or insightful remark here</subtitle>
<link href="http://example.org/"></link>
<updated>2003-12-13T18:30:02Z</updated>
<author>
<name>John Doe</name>
<email>johndoe@example.com</email>
View sslfix.ps1
# Copyright 2014, Alexander Hass
# http://www.hass.de/content/setup-your-iis-ssl-perfect-forward-secrecy-and-tls-12
#
# Version 1.4
# - RC4 has been disabled.
# Version 1.3
# - MD5 has been disabled.
# Version 1.2
# - Re-factored code style and output
# Version 1.1 - SSLv3 has been disabled. (Poodle attack protection)
View gist:c6630751a7e27cb6531e
Dropbox command-line interface
commands:
Note: use dropbox help <command> to view usage for a specific command.
status get current status of the dropboxd
throttle set bandwidth limits for Dropbox
help provide help
puburl get public url of a file in your dropbox's public folder
@withakay
withakay / beatport-discog.rb
Last active Aug 29, 2015
Get your discography from beatport
View beatport-discog.rb
#!/usr/bin/env ruby
require "rubygems"
require "json"
require "net/http"
require "uri"
artist = "TR20"
uri = URI.parse("http://www.federicogiust.com/beatportapi/beatport_api.php?facets=performerName:#{artist}&sortBy=publishDate%20desc&perPage=150&url=releases")
@withakay
withakay / gist:2507784
Created Apr 27, 2012
.ssh set permissions
View gist:2507784
// commands to run for your own user from you home directory after you have copied over the authorized_keys file
sudo chmod 600 ~/.ssh/authorized_keys
sudo chmod 700 ~/.ssh
sudo chown my_user_name:my_group_name ~/.ssh/authorized_keys
sudo chown my_user_name:my_group_name ~/.ssh
// commands to run for other users after copying over the authorized_keys file for that user
sudo chmod 600 ../some_other_user/.ssh/authorized_keys
@withakay
withakay / gist:1339307
Created Nov 4, 2011
Update with inner join (SQL Server)
View gist:1339307
UPDATE t1
SET col = t2.col
FROM Table1 t1
INNER JOIN Table2 AS t2 ON t1.ID = t2.ID
@withakay
withakay / bjorklund.js
Created Oct 14, 2011
Bjorklund algorithm in JavaScript
View bjorklund.js
/*
An implementation of the Bjorklund algorithm in JavaScript
Inspired by the paper 'The Euclidean Algorithm Generates Traditional Musical Rhythms'
by Godfried Toussaint

This is a port of the original algorithm by E. Bjorklund which I
found in the paper 'The Theory of Rep-Rate Pattern Generation in the SNS Timing Systems' by
E. Bjorklund.