Skip to content

Instantly share code, notes, and snippets.

View arangamani's full-sized avatar
✍️
All we are doing is writing tomorrow's legacy software today

Kannan Manickam arangamani

✍️
All we are doing is writing tomorrow's legacy software today
View GitHub Profile
@arangamani
arangamani / chef_attribute_converge.rb
Last active February 20, 2023 02:44
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
@arangamani
arangamani / india_map.c
Created January 30, 2013 07:41
C code to print India Map
#include "stdio.h"
main()
{
int a,b,c;
int count = 1;
for (b = c = 10;
a = "- FIGURE?, UMKC,XYZHello Folks,\
TFy!QJu ROo TNn(ROo)SLq SLq ULo+\
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
if ARGV.size != 1
puts "This script only accepts a single parameter as organization."
puts "Usage: #{__FILE__.split("/").last} <organization>"
exit 1
end
@arangamani
arangamani / jsonlint
Last active January 7, 2016 02:45
A JSON lint tool using Ruby and "json" Rubygem
#!/usr/bin/env ruby
require "rubygems"
require "json"
if ARGV.size < 1
puts "Please provide a JSON file"
exit 1
end
class Chef
class Log
def self.warn(str); end
end
end
@arangamani
arangamani / test-kitchen_failure
Created March 7, 2014 18:21
test-kitchen failure
kitchen | [default] Setting the name of the VM...
kitchen | [default] Clearing any previously set forwarded ports...
kitchen | [default] Clearing any previously set network interfaces...
kitchen | [default] Preparing network interfaces based on configuration...
kitchen | [default] Forwarding ports...
kitchen | [default] -- 22 => 2222 (adapter 1)
kitchen | [default] Running 'pre-boot' VM customizations...
kitchen | [default] Booting VM...
kitchen | [default] Waiting for machine to boot. This may take a few minutes...
kitchen | [default] Machine booted and ready!
@arangamani
arangamani / example
Created March 7, 2014 18:26
log_level example
provisioner:
solo_rb:
log_level: warn
@arangamani
arangamani / chef_handler_example.rb
Last active August 29, 2015 13:57
Chef Handler Example Exception Handling
# attributes
default['cron']['service_name'] = 'cron'
# recipe
include_recipe 'chef_handler'
cookbook_file "#{node['chef_handler']['handler_path']}/blah.rb" do
source 'blah.rb'
action :create
end
@arangamani
arangamani / rs_swap_repo.rb
Last active August 29, 2015 13:58
Swapping repositories on RightScale ServerTemplate cookbooks
# This simlpe snippet explains how to swap the repository of all the cookbooks under
# a RightScale ServerTemplate
require 'right_api_client'
# Initialize the client with correct options.
client = RightApi::Client.new(options)
# Obtain the servertemplate resource where you want to swap the respository
st = client.server_templates.index(id: 123456)
@arangamani
arangamani / _types.h
Last active August 29, 2015 14:25
_types.h
/*-
* Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions