Skip to content

Instantly share code, notes, and snippets.

View bluSch's full-sized avatar

Brandon Schlueter bluSch

View GitHub Profile
@bluSch
bluSch / Exercise_58_HTTP_Handlers.go
Created September 17, 2012 22:35
Solutions for tour.golang exercises
package main
import (
"net/http"
"fmt"
)
type String string
type Struct struct {
[28] pry(main)> o = {:opsworks => { :layers => { :php => { :instances => { :leb => {:private_ip => "1.1.1.1"}}}}}}
=> {:opsworks=>{:layers=>{:php=>{:instances=>{:leb=>{:private_ip=>"1.1.1.1"}}}}}}
[29] pry(main)> o[:opsworks][:layers].each do |layer|
[29] pry(main)* layer[:instances].each do |instance|
[29] pry(main)* puts instance[:private_ip]
[29] pry(main)* end
[29] pry(main)* end
TypeError: can't convert Symbol into Integer
from (pry):64:in `[]'
@bluSch
bluSch / Windows Key rebindings
Last active September 2, 2021 13:21
Windows Key rebindings
# To use these, copy one section beginning with 'Windows Registry' and down to the next Comment
# in a .reg file and execute it on windows. Capslock to ctrl worked for me on Windows 7,
# and these should work on most versions of windows.
# Turn capslock into ctrl
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
@bluSch
bluSch / create_path.rb
Last active August 29, 2015 13:56
Create all directories in a path with chef
# This function is equivalent to `execute "mkdir -p #{path}"`
# path is the path to be created, and can only be absolute without tweaking this
require 'pathname'
def create_path path
split_path = Pathname(path).each_filename.to_a
split_path.each_with_index.map do | _, index |
partial_path = File.join(File::SEPARATOR, split_path.slice(0, index + 1))
directory partial_path
end
end
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.
@bluSch
bluSch / require_relative snippet.rb
Created April 30, 2014 21:03
add require_relative to ruby 1.8
unless Kernel.respond_to?(:require_relative)
module Kernel
def require_relative(path)
require File.join(File.dirname(caller[0]), path.to_str)
end
end
end
@bluSch
bluSch / gist:0193dd257cd2277cd2af
Last active August 29, 2015 14:01
change for php version
# in php/recipes/package.rb
node['php']['packages'].each do |pkg|
if pkg.instance?(Hash)
package pkg['name'] do
action :install
version pkg['version']
end
else
package pkg do
action :install