Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Swann Alex-Swann

View GitHub Profile
@Alex-Swann
Alex-Swann / vpn.sh
Created May 15, 2021
A bash script for managing OpenVPN profiles on the Home Office ACP Hub
View vpn.sh
#!/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.
#
@Alex-Swann
Alex-Swann / ccms_payload_attribute_finder.rb
Created Nov 26, 2020 — forked from stephenrichards/ccms_payload_attribute_finder.rb
Print a list of all attributes in the CCMS payload
View ccms_payload_attribute_finder.rb
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 / fix_exfat_drive.md
Created Jun 14, 2018 — forked from scottopell/fix_exfat_drive.md
Fix corrupted exFAT disk macOS/OSX
View fix_exfat_drive.md

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?
View escape_the_mine.rb
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 / sudoku_checker.rb
Last active Mar 23, 2016
Sudoku Puzzle Checker
View sudoku_checker.rb
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
@Alex-Swann
Alex-Swann / total_inc_dec.rb
Created Mar 20, 2016
Counts total number of increasing/decreasing numbers to powers of 10
View total_inc_dec.rb
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
View MORSE_DECODER.rb
$morse_dict = Hash[
"a" => ".-",
"b" => "-...",
"c" => "-.-.",
"d" => "-..",
"e" => ".",
"f" => "..-.",
"g" => "--.",
"h" => "....",
"i" => "..",
View orange_tree.rb
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."
@Alex-Swann
Alex-Swann / morse_code_dictionary.rb
Created Mar 10, 2016 — forked from mikedamage/morse_code_dictionary.rb
Morse code dictionary as a Ruby Hash object
View morse_code_dictionary.rb
morse_dict = Hash.new({
"a" => ".-",
"b" => "-...",
"c" => "-.-.",
"d" => "-..",
"e" => ".",
"f" => "..-.",
"g" => "--.",
"h" => "....",
"i" => "..",