Skip to content

Instantly share code, notes, and snippets.

@withakay
withakay / bjorklund.js
Created October 14, 2011 10:10
Bjorklund algorithm in JavaScript
/*
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.
@withakay
withakay / gist:1339307
Created November 4, 2011 13:28
Update with inner join (SQL Server)
UPDATE t1
SET col = t2.col
FROM Table1 t1
INNER JOIN Table2 AS t2 ON t1.ID = t2.ID
@withakay
withakay / gist:2507784
Created April 27, 2012 09:30
.ssh set permissions
// 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 / beatport-discog.rb
Last active August 29, 2015 14:27
Get your discography from beatport
#!/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")
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
# 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)
<?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>[email protected]</email>
#!/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
@withakay
withakay / README.md
Last active July 5, 2018 10:24 — forked from ringe/README.md
KVM QCOW2 Live backup

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

@withakay
withakay / update-authorised-keys.sh
Created December 11, 2017 22:52
Update authorized keys on remote server using known_hosts
#!/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"