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
def flatten_structure(path, structure) | |
results = {} | |
if structure.is_a? Hash | |
structure.each_pair do |name, value| | |
new_path = "#{path}_#{name}".gsub(/\-|\//, '_') | |
results.merge! flatten_structure(new_path, value) | |
end | |
elsif structure.is_a? Array | |
structure.each_with_index do |value, index| |
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
root@master:/etc/puppetlabs/facter/facts.d # cat foo.sh | |
#! /bin/sh | |
FACT=$(facter hostname) | |
echo "foo=${FACT}" | |
root@master:/etc/puppetlabs/facter/facts.d # chmod +x foo.sh | |
root@master:/etc/puppetlabs/facter/facts.d # facter ipaddress | |
<hangs and explodes> |
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
[root@default ~]# ip addr | |
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN | |
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | |
inet 127.0.0.1/8 scope host lo | |
inet6 ::1/128 scope host | |
valid_lft forever preferred_lft forever | |
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 | |
link/ether 08:00:27:0f:d2:76 brd ff:ff:ff:ff:ff:ff | |
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 | |
inet6 fe80::a00:27ff:fe0f:d276/64 scope link |
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
#!/usr/bin/env ruby | |
require 'benchmark' | |
require 'childprocess' | |
require 'systemu' | |
argv = %w[git rev-parse HEAD^{commit}] | |
args = argv.join(" ") | |
COUNT = 100 |
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
describe 'a big laser' do | |
it 'can cut through steel' | |
it 'can shoot your eye out' | |
describe 'when being used for evil' do | |
it 'glows in an ominous fashion' | |
it 'crackles loudly when firing' | |
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
sed -i.bak -e \ | |
":BEGIN | |
/\"[^\"']*[^\\]*\$[[:alnum:]_:].*\"/ \ | |
s/\(\"[^\"]*\)\$\([[:alnum:]_:][[:alnum:]_:]*\)\([^\"]*\"\)/\1$\{\2\}\3/ | |
t BEGIN" $manifest |
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
sed -e '1i\ | |
user literarybot foo foo literarybot' -e 'i2\ | |
nick literarybot' -e '3i\ | |
join #example' -ne '/^[[:space:]]*$/d' -ne 's/^/PRIVMSG #example :/p' < input.txt| while read line; do sleep 1; echo $line; done | nc irc.freenode.net 6667 |
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
#!/usr/bin/env ruby | |
require 'fileutils' | |
require 'open-uri' | |
def get_links | |
image_urls = [] | |
# Download latest page | |
puts "Downloading #{$apod_url}" | |
open($apod_url) do |stream| |
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
#!/bin/sh | |
# | |
# Attempts to add braces around quoted interpolated strings in puppet. | |
# | |
# Caveats | |
# | |
# This is a lot of sed and duct tape. It is not very smart. It's probably the | |
# most horrible regex I've ever written. | |
# I'm sorry. |
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
tell application "iTerm" | |
set _term to (make new terminal) | |
tell _term | |
launch session "Default" | |
activate | |
end tell | |
end tell |