Skip to content

Instantly share code, notes, and snippets.

@nathanhoel
nathanhoel / logger.js
Last active December 14, 2016 20:01
Halite node.js logger module
const loggerOn = 0;
var winston = null;
try {
winston = require('winston');
winston.remove(winston.transports.Console);
winston.add(
winston.transports.File,
{
filename: 'match.log',
<!DOCTYPE html>
<html lang="en">
<script type="text/javascript">
document.write(unescape("%3Cscript src='//munchkin.marketo.net/munchkin.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script>Munchkin.init('103-MWY-702');</script>
<head>
<meta charset="UTF-8">
<title>Title</title>
@nathanhoel
nathanhoel / chef_converge_variable_scope.rb
Created March 24, 2016 15:09
Chef evaluation timing and variable scope within ruby_block resources
the_test = 1
Chef::Log.info("The test is #{the_test}")
ruby_block "first" do
block do
Chef::Log.info("(first block) The test is #{the_test}")
the_test = 2
end
end
ruby_block "second" do
@nathanhoel
nathanhoel / notifies_and_subscriptions_timing.rb
Created March 24, 2016 15:05
Chef notification and subscription ordering
# These resources will essentially run in this order.
# You must understand how the converge step in chef works before this will make sense.
# Even if you defined these resources in another order, this will still print the
# statements in order (FIRST, SECOND, THIRD, ...)
# The :before timers always occur before the resource doing the notifying/subscribed to.
# The :immediate/:immediately timers always occur after the resource doing the notifying/subscribed to.
# When there are notifications and subscriptions with the same timing on a resource
# notifications will fire before subscriptions.
@nathanhoel
nathanhoel / chef_attribute_converge.rb
Created March 24, 2016 14:58 — forked from arangamani/chef_attribute_converge.rb
Dynamically update attribute of a Chef resource during converge phase (Node variable assignment in Compile vs Converge)
# 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