Skip to content

Instantly share code, notes, and snippets.

View frogstarr78's full-sized avatar

Scott Noel-Hemming frogstarr78

View GitHub Profile
@frogstarr78
frogstarr78 / HashLikeSmallTalkConditionals.rb
Created April 10, 2010 08:24
Ruby Hashes emulating Smalltalk Conditionals
#!/usr/bin/env ruby
module HashLikeSmalltalkConditionals
class ::Object
def nil? hash
hash[:if_false].call
self
end
end
@frogstarr78
frogstarr78 / MethodsLikeSmalltalkConditionals.rb
Created April 10, 2010 08:28
Ruby Methods emulating Smalltalk Conditionals
module MethodsLikeSmalltalkConditionals
module Kernel
def is_true
Proc.new { yield }
end
def is_false
Proc.new { yield }
end
end
@frogstarr78
frogstarr78 / git-spawn-repo-from-commit_hash
Created April 23, 2010 06:54
Start a new repository based on the commit hash of another repository
#!/bin/bash
# Copyright (c) 2009 Frogstarr78 Software
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
@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) } }
@frogstarr78
frogstarr78 / open.py
Created November 10, 2015 23:26 — forked from thiago-vieira/open.py
natural open struct in python
class Class:
pass
x = Class()
x.something = 42
print(x.something) # 42
62,66c62,68
< $cacheObj = json_decode($cacheFile);
< if(isset($cacheObj->$user)){
< return $cacheObj->$user;
< }else{
< throw new Exception("User does not exist in cache_keys. Try regenerating the cache.");
---
> if ( $cacheFile ) {
> $cacheObj = json_decode($cacheFile);
> if(isset($cacheObj->$user)){
@frogstarr78
frogstarr78 / mount_qcow2.md
Created October 30, 2020 07:08 — forked from shamil/mount_qcow2.md
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
- hosts: localhost
gather_facts: no
vars:
site: example.com
user: bob
scheme: https
env_path: "{{ playbook_dir }}/tmp/environment"
ansible_connection: local
tasks:
- name: Create /etc/environment