Skip to content

Instantly share code, notes, and snippets.

@hube
hube / hash-diff.ps1
Last active June 7, 2020 02:36
Compare the files of two directories using content hashes
$referencePath = "a"
$differencePath = "b"
$lhs = Get-ChildItem -Recurse -File -Path $referencePath
$lhs_hashes = $lhs | Select-Object Name, FullName, Length, @{Name="Hash"; Expression={ Get-FileHash $_.FullName }}
$rhs = Get-ChildItem -Recurse -File -Path $differencePath
$rhs_hashes = $rhs | Select-Object Name, FullName, Length, @{Name="Hash"; Expression={ Get-FileHash $_.FullName }}
$diff = Compare-Object $lhs_hashes $rhs_hashes -property @("Name", "Hash")
@hube
hube / meta.rb
Last active July 13, 2017 07:38
Apple Music Metadata Matching Script (originally taken from https://cl.ly/C3kK)
#!/usr/bin/env ruby
# by @tapbot_paul
# Don't blame me if this nukes your metadata, formats your drive, kills your kids
# This script goes through any iCloud Matched songs in your iTunes library and tries to update the
# metadata from the iTunes Store
# Will run against entire library
# Known to work with Ruby 1.9.3-p551, macOS 10.12.5, iTunes 12.6.1.25
# install the required gems with the following commands
# sudo gem install json
# sudo gem install rb-appscript
#!/usr/bin/env bash
# Configure git to use diffmerge as the difftool and mergetool
git config --global difftool.prompt false
git config --global diff.tool diffmerge
git config --global difftool.diffmerge.cmd "/usr/local/bin/diffmerge --nosplash \"\$LOCAL\" \"\$REMOTE\""
git config --global merge.tool diffmerge

Keybase proof

I hereby claim:

  • I am hube on github.
  • I am hubert (https://keybase.io/hubert) on keybase.
  • I have a public key whose fingerprint is 65C8 FFD4 E91C D3EA AFEB F48E 0D3F 8C02 CCC9 02D3

To claim this, I am signing this object:

@hube
hube / 1-duck_typing.rb
Last active August 29, 2015 13:58
Demonstrates metaprogramming and reflection features in Ruby
# An example of duck typing using reflection
def greet(names)
if names.respond_to? :each
names.each do |name|
puts "Hello #{name}!"
end
else
puts "Hello #{names}!"
end
end
@hube
hube / ruby-intro.rb
Last active August 29, 2015 13:57
Intro Ruby Code
puts "Hello world!"
def say_hello
puts "Hello world!"
end
say_hello
class Greeter
def initialize(name)
@hube
hube / colors
Created July 15, 2012 18:04 — forked from twerth/colors
List colors in shell
#!/bin/bash
echo -e "\033[1;37mCOLOR_WHITE\t\033[0;30mCOLOR_BLACK"
echo -e "\033[0;34mCOLOR_BLUE\t\033[1;34mCOLOR_LIGHT_BLUE"
echo -e "\033[0;32mCOLOR_GREEN\t\033[1;32mCOLOR_LIGHT_GREEN"
echo -e "\033[0;36mCOLOR_CYAN\t\033[1;36mCOLOR_LIGHT_CYAN"
echo -e "\033[0;31mCOLOR_RED\t\033[1;31mCOLOR_LIGHT_RED"
echo -e "\033[0;35mCOLOR_PURPLE\t\033[1;35mCOLOR_LIGHT_PURPLE"
echo -e "\033[0;33mCOLOR_YELLOW\t\033[1;33mCOLOR_LIGHT_YELLOW"
echo -e "\033[1;30mCOLOR_GRAY\t\033[0;37mCOLOR_LIGHT_GRAY"