Skip to content

Instantly share code, notes, and snippets.

View sinewalker's full-sized avatar

Michael Lockhart sinewalker

View GitHub Profile
@sinewalker
sinewalker / knight-rider.rb
Created November 6, 2018 06:18
Knight Rider - Sonic Pi
#Knight Rider Main Theme
# by Stu Phillips, 1981
# Sonic Pi transcript, Mike Lockhart, 2018
# (missing Rtyhm Section: Buffer Capacity reached)
#motifs
define :kr0 do |n|
play_pattern_timed [n, :r, n+1, n, n, n+1, n, n], 0.25
@sinewalker
sinewalker / gist:1c8dcadfdf3df3f56a8c96bcd8b953ae
Created November 2, 2018 20:27
Chord Inversions over known scales
# Chord Inversions
# Coded by Adrian Cheater
# (in a single tweet)
# https://twitter.com/wpgFactoid/status/666692596605976576
# Mike Lockhart made a small mod to loop through all of Sonic Pi's built-in scales
# (73 of them for SP v3.1 !)
@sinewalker
sinewalker / windows-password.md
Last active September 17, 2018 03:03
Disable password expiry in Windows 7
  1. Start menu > Run
  2. wmic
  3. right-click; Run as Administrator
  4. UserAccount where PasswordExpires=TRUE set PasswordExpires=FALSE
  5. press Y for each account confirmation
@sinewalker
sinewalker / scsi-rescan.md
Created August 28, 2018 23:48
Rescan SCSI devices after changing on VM Host

Rescanning a Linux SCSI device after it is changed on a VM Host

Sometimes when you change the logical drive of a VM from the Host, the device size is not reflected in the Guest. So attempts to use the extra space with fdisk or the NVM tools will not "see" the extra disc.

This is because the Linux kernel doesn't notice it, because it's not looking. Linux usually only scans this at boot time. But you probably can't reboot a server if it's live, so what do you do?

To tell Linux to have another look now, you just need to poke it:

echo 1 > /sys/bus/scsi/devices/1:0:0:0/rescan
@sinewalker
sinewalker / doctorwho.rb
Last active August 14, 2018 17:57
Dr. Pi
# Dr. Who
# Transcribed by ear from different T.V. introductions, probably not
# entirely correct either; so it's my own arrangement.
#
# I wanted to hear if I could get some of the effects in too
#
# Mike Lockhart 2018-08-10
use_bpm 130
@sinewalker
sinewalker / ugrade-requests.html
Created August 1, 2018 08:02
Upgrade HTML mixed-content meta tag
<!doctype html>
<html>
<head>
<title>whatever</title>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<!-- rest of header:
<link rel="stylesheet" href="something.css">
<script src="somescript.js"/>
-->
@sinewalker
sinewalker / toggle-comment-sed.sh
Last active July 16, 2018 23:09
Comment / un-comment a line in a config file, matching a pattern, using sed
sed -i '/pattern/s/^/#/g' file #to comment out
sed -i '/pattern/s/^#//g' file #to uncomment
@sinewalker
sinewalker / ticktock.service
Created July 13, 2018 12:09
ticktock systemd service
[Unit]
Description=ticktock
AssertPathExists=/home/mjl
[Service]
WorkingDirectory=/home/mjl
#unbuffered:
ExecStart=/usr/bin/python -u /home/mjl/ticktock.py
#buffered:
#ExecStart=/home/mjl/ticktock.py
@sinewalker
sinewalker / ticktock.py
Created July 13, 2018 12:06
Python tick-tock
#!/usr/bin/env python
from time import sleep
from datetime import datetime
while True:
print(datetime.now())
sleep(1)
@sinewalker
sinewalker / git-merge-origin\master.md
Last active July 6, 2018 22:18
Merge remote origin/master into a new local repository

This little dance is needed to merge in the remote origin/master to a fresh local (one created without cloning the remote, such as by a tool like pass). I don't know if there is a better way?

You need to do this when

  • you have another application which can use git for storing data, and you need to fill it with history from a common remote, but the application doesn't support git clone, only git init type operations
  • you have a local repository with local changes that you want to keep, but still merge in the origin (although you could go the other way, I think?)

Use commands like these to merge in a remote to your local master, as the new origin: