Skip to content

Instantly share code, notes, and snippets.

@skull-squadron
skull-squadron / make-relative-bin.sh
Last active March 18, 2023 02:36
Linux utility: Remove hard-coded absolute library paths and set a single DT_RUNPATH
#!/usr/bin/env bash
set -euo pipefail
TGT="$1"
NEW_RUNPATH="${2:-\$ORIGIN/../lib}"
_patchelf() {
(set -x; patchelf "$@")
}
@skull-squadron
skull-squadron / winget-upgrade-all.ps1
Last active March 15, 2023 03:50
Windows Workaround a bug in winget that prevents upgrade --all from working
$output = winget upgrade | Out-String
$lines = $output.Split([Environment]::NewLine)
$hdrLine = 0
while (-not $lines[$hdrLine].StartsWith("Name")) {
$hdrLine++
}
$idIdx = $lines[$hdrLine].IndexOf("Id")
@skull-squadron
skull-squadron / reading-list.md
Last active February 21, 2023 17:46
Language design reading list
@skull-squadron
skull-squadron / google.crt
Last active April 9, 2017 17:24
Am I smoking crack or does VERIFY_PEER plain not work on 1.8.7 and 1.9.3?
#!/usr/bin/env ruby
require 'openssl'
require 'uri'
require 'net/http'
url = URI.parse 'https://rubygems.org/'
http = Net::HTTP.new url.host, url.port
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.read_timeout = 20
@skull-squadron
skull-squadron / gist:5021854
Created February 23, 2013 23:34
list all installed package groups on el redhat / fedora
yum grouplist | sed -n '1,/^Installed Groups:/d;/^Available Groups:/q;s/^ *//g;p'
@skull-squadron
skull-squadron / iso_from_files_and_folders.sh
Last active December 12, 2015 02:59
turn files and folders into an iso (put this into an applescript)
vol_name="`basename \\"$1\\"`"
iso="$vol_name.iso"
counter=1
while [ -e "$iso" ]; do
counter=$[counter+1]
iso="$vol_name $counter.iso"
done
hdiutil makehybrid -iso -joliet -o "$iso" "$@"
@skull-squadron
skull-squadron / New Folder From Selection.applescript
Last active December 12, 2015 01:08
New Folder From Selection (Service that works with 1+ files instead of 2+)
on run {input, parameters}
tell application "Finder"
set thePath to first item of input
set {dispName, nameExt, isHidden} to the {displayed name, name extension, extension hidden} of thePath
if isHidden or nameExt is equal to "" then
dispName
else
@skull-squadron
skull-squadron / gist:2038710
Created March 14, 2012 19:05
ansi 256 color swatch sample in ruby
#!/usr/bin/env ruby
#
# Usage: 256swatch [-b [foreground [test pattern]]]
#
# option description default
# -----------------------------------------------------------
#
# -b print background swatches instead normal
#
# foreground force foreground (decimal) normal
@skull-squadron
skull-squadron / fix_rvm_permissions.sh
Created March 13, 2012 22:50
fix rvm permissions
#!/bin/sh
find ~/.rvm -type d -print0 | xargs -0L1 chmod 0755
find ~/.rvm -type f -print0 | xargs -0L1 chmod 0644
find ~/.rvm -type f -print0 | xargs -0L1 file | grep ' exec' | cut -d: -f1 | tee /dev/stderr | xargs -L1 chmod 0755
@skull-squadron
skull-squadron / require_profiling__custom_require.rb
Created March 12, 2012 19:18
hacking up custom_require to show library load times. (HINT: This is silly, use a debugger!)
# Usage: MRI put at the top of custom_require.rb
#
# ~/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
# This is crappy/untested proof-of-concept code, do not use it in production. It will fail.
# Unlikely to be threadsafe either.
# Don't run this on anything you care about.
# No warranties, express or implied. GPL v3 license.
if ENV['RBDEBUG_REQUIRE'] && !ENV['RBDEBUG_HIDE']