This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 `[]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"fmt" | |
) | |
type String string | |
type Struct struct { |