Skip to content

Instantly share code, notes, and snippets.

View frogstarr78's full-sized avatar

Scott Noel-Hemming frogstarr78

View GitHub Profile
@shamil
shamil / mount_qcow2.md
Last active March 26, 2024 14:47
How to mount a qcow2 disk image

How to mount a qcow2 disk image

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

Step 1 - Enable NBD on the Host

modprobe nbd max_part=8
@thiago-vieira
thiago-vieira / open.py
Last active April 20, 2017 14:07
natural open struct in python
class Class:
pass
x = Class()
x.something = 42
print(x.something) # 42
@cdown
cdown / gist:1163649
Last active February 3, 2024 18:49
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@frogstarr78
frogstarr78 / Benchmark.rb
Created May 6, 2010 05:06
Attempt to use ruby to generate some functional constructs.
require 'benchmark'
require 'Functional'
Benchmark.bmbm 30 do |bm|
f = Functional.new
bm.report( "define fib 1" ) { f.define( :fib, 1 ) { 1 } }
bm.report( "define fib 2" ) { f.define( :fib, 2 ) { 1 } }
bm.report( "define fib Fixnum" ) { f.define( :fib, Fixnum ) {|n| fib(n-1) + fib(n-2) } }
@alainravet
alainravet / print_stacktrace.rb
Created January 24, 2009 21:12
How to print the stacktrace in Ruby
# How to print the stacktrace from anywhere :
# 1°
#------------------------------------------------------------------------------
module Kernel
def print_stacktrace
raise
rescue
puts $!.backtrace[1..-1].join("\n")
end