- ice_nine: Deep freeze ruby objects
- Values: Simple immutable value objects for ruby
- immutable_attributes: specify attributes within an ActiveRecord model that can be set but not modified
- hamster: Efficient, Immutable, Thread-Safe Collection classes for Ruby
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/bash | |
# | |
# Author:: Joshua Timberman <joshua@opscode.com> | |
# | |
# Copyright (c) 2013, Opscode, Inc. <legal@opscode.com> | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# |
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
# | |
# Author:: Joshua Timberman <joshua@opscode.com> | |
# | |
# Copyright (c) 2013, Opscode, Inc. <legal@opscode.com> | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 |
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
require 'nokogiri' | |
require 'restclient' | |
Nokogiri::HTML(RestClient.get('https://github.com/opscode-cookbooks/')). | |
css('ul.repolist h3 a').collect{|n| n.attribute('href').value}.each do |s| | |
system "git clone http://github.com#{s}" | |
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
# In Chef, when a resource is defined all its variables are evaluated during | |
# compile time and the execution of the resource takes place in converge phase. | |
# So if the value of a particular attribute is changed in converge | |
# (and not in compile) the resource will be executed with the old value. | |
# Example problem: | |
# Let's consider this situation where there are two steps involved in a recipe | |
# Step 1 is a Ruby block that changes a node attribute. Rubyblocks get executed | |
# in converge phase | |
# Step 2 is a Chef resource that makes use of the node attribute that was |
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
# the entire concept of building a dsl means defining domain terms on an | |
# object, it's so much simpler to start with the dsl itself being a blank | |
# slate that simply relays certain methods to a scope | |
# | |
class DSL | |
instance_methods.each do |m| | |
undef_method m unless m[%r/\A__|\Aobject_id\Z/] | |
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
IPTABLES="/sbin/iptables" | |
### block all Asian/APNIC IPs (includes NZ, AU) | |
$IPTABLES -A bad_stuff -s 58.0.0.0/8 -j DROP | |
$IPTABLES -A bad_stuff -s 59.0.0.0/8 -j DROP | |
$IPTABLES -A bad_stuff -s 60.0.0.0/8 -j DROP | |
$IPTABLES -A bad_stuff -s 61.0.0.0/8 -j DROP | |
$IPTABLES -A bad_stuff -s 110.0.0.0/8 -j DROP | |
$IPTABLES -A bad_stuff -s 111.0.0.0/8 -j DROP | |
$IPTABLES -A bad_stuff -s 112.0.0.0/8 -j DROP |
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 | |
# Copyright 2012 Opscode <legal@opscode.com> | |
# | |
# Licensed to the Apache Software Foundation (ASF) under one | |
# or more contributor license agreements. See the NOTICE file | |
# distributed with this work for additional information | |
# regarding copyright ownership. The ASF licenses this file | |
# to you under the Apache License, Version 2.0 (the | |
# "License"); you may not use this file except in compliance | |
# with the License. You may obtain a copy of the License at |
This is a little trick I use to spin up the packages instalation on Debian/Ubuntu boxes in Vagrant.
I add a simple function that checks if a directory named something similar to ~/.vagrant.d/cache/apt/opscode-ubuntu-12.04/partial
(it may have another path in Windows or MacOS) and create the directory if it doesn't already exist.
def local_cache(basebox_name)
cache_dir = Vagrant::Environment.new.home_path.join('cache', 'apt', basebox_name)
partial_dir = cache_dir.join('partial')
partial_dir.mkdir unless partial_dir.exist?
cache_dir
Locate the section for your github remote in the .git/config
file. It looks like this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:joyent/node.git
Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: