Skip to content

Instantly share code, notes, and snippets.

View Alex-Swann's full-sized avatar

Alex Swann Alex-Swann

  • London
View GitHub Profile
@Alex-Swann
Alex-Swann / morse_code_dictionary.rb
Created March 10, 2016 10:28 — forked from mikedamage/morse_code_dictionary.rb
Morse code dictionary as a Ruby Hash object
morse_dict = Hash.new({
"a" => ".-",
"b" => "-...",
"c" => "-.-.",
"d" => "-..",
"e" => ".",
"f" => "..-.",
"g" => "--.",
"h" => "....",
"i" => "..",
class Tree
def initialize (name, year)
@name = name
@age = 0
@height = 0
@year = year.to_i
@init_year = year.to_i
puts "Your #{@name.capitalize} tree has started to grow."
$morse_dict = Hash[
"a" => ".-",
"b" => "-...",
"c" => "-.-.",
"d" => "-..",
"e" => ".",
"f" => "..-.",
"g" => "--.",
"h" => "....",
"i" => "..",
@Alex-Swann
Alex-Swann / total_inc_dec.rb
Created March 20, 2016 20:07
Counts total number of increasing/decreasing numbers to powers of 10
require 'benchmark'
def total_nums x
return 0 if x == nil
return 1 if x == 0
1.upto(10 ** x).count do |i|
s = i.to_s.chars
t = s.sort
s == t || s == t.reverse
@Alex-Swann
Alex-Swann / sudoku_checker.rb
Last active March 23, 2016 17:59
Sudoku Puzzle Checker
def validSolution(board)
arr = []
board.transpose.map{|x| x.sort}.each{|x| x.each{|i| arr << i}}
arr2 = []
board.map{|x| x.sort}.each{|x| x.each{|i| arr2 << i}}
arr3 = []
board_subgrid = []
r = 0
def solve(minemap, miner, exit)
@minemap = minemap
@miner = miner
arr = [[miner['x'],miner['y']]]
@arr = arr
hash = Hash[ [[1,0],[0,1],[-1,0],[0,-1]].zip ['down','right','up','left'] ]
def go_step?(a,b)
@miner['x']+a < @minemap.size &&
@miner['x']+a >= 0 &&
@Alex-Swann
Alex-Swann / fix_exfat_drive.md
Created June 14, 2018 19:13 — forked from scottopell/fix_exfat_drive.md
Fix corrupted exFAT disk macOS/OSX

exFAT support on macOS seems to have some bugs because my external drives with exFAT formatting will randomly get corrupted.

Disk Utility is unable to repair this at first, but the fix is this:

  1. Use diskutil list to find the right drive id.
  2. You want the id under the IDENTIFIER column, it should look like disk1s1
  3. Run sudo fsck_exfat -d <id from above>. eg sudo fsck_exfat -d disk1s3
  4. -d is debug so you'll see all your files output as they're processed.
  5. Answer YES if it gives you the prompt Main boot region needs to be updated. Yes/No?
@Alex-Swann
Alex-Swann / ccms_payload_attribute_finder.rb
Created November 26, 2020 15:26 — forked from stephenrichards/ccms_payload_attribute_finder.rb
Print a list of all attributes in the CCMS payload
module CCMS
class PayloadParser
def initialize
@doc = File.open(Rails.root.join('ccms_integration/example_payloads/PassportedSingleProceedingNonMolDelegated.xml')) { |f| Nokogiri::XML(f).remove_namespaces! }
end
def run
puts ">>>>>>>>> #{__FILE__}:#{__LINE__} <<<<<<<<<<\n"
x = @doc.xpath('//Attributes//Attribute//Attribute')
@Alex-Swann
Alex-Swann / vpn.sh
Created May 15, 2021 18:38
A bash script for managing OpenVPN profiles on the Home Office ACP Hub
#!/bin/bash
export PATH=$(brew --prefix openvpn)/sbin:$PATH
PROFILES=( kube-platform acp-prod jira-confluence )
PROFILES_LABELS=( 'Kube Platform' 'ACP Prod' 'JIRA' )
# Renders a text based list of options that can be selected by the
# user using up, down and enter keys and returns the chosen option.
#