Skip to content

Instantly share code, notes, and snippets.

@endzyme
endzyme / classes.rb
Created October 20, 2012 00:25 — forked from kalleth/classes.rb
hmm, polymorphism?
class DataCenter < ActiveRecord::Base
# has configuration_type, configuration_id attributes
def config
configuration_type.constantize.find(configuration_type)
end
def config=(config)
configuration_type = config.class.name
configuration_id = config.id
end
@endzyme
endzyme / newdiff.diff
Created November 11, 2012 06:42
new changes
diff --git a/.project b/.project
new file mode 100644
index 0000000..414c3ac
--- /dev/null
+++ b/.project
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>fog</name>
+ <comment></comment>
@endzyme
endzyme / NoMethodError
Created January 4, 2013 17:28
This was an error from using cancan and not using a column name
Started GET "/deployments/new" for 172.16.228.1 at 2013-01-03 09:17:13 -0700
Processing by DeploymentsController#new as HTML
User Load (0.1ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
Completed 500 Internal Server Error in 5ms
NoMethodError (undefined method `production?=' for #<Deployment:0x000000055e45e8>):
activemodel (3.2.8) lib/active_model/attribute_methods.rb:407:in `method_missing'
activerecord (3.2.8) lib/active_record/attribute_methods.rb:149:in `method_missing'
cancan (1.6.8) lib/cancan/controller_resource.rb:92:in `block in assign_attributes'
cancan (1.6.8) lib/cancan/controller_resource.rb:91:in `each'
@endzyme
endzyme / 1_activemqconfig.pp
Last active December 14, 2015 20:49
concat use for active mq configuration file populating static clustered known hosts. -- Updated for better handling of filtering. -- This method of Exported Resources with multiple filters will require PuppetDB running.
# When you build your ERB files you should split them up into header and footer around
# the dynamic area. Which also sucks. Wish there was a better way of getting stored
# configs out of puppet upon runtime.. Like maybe into variables.
class activemq::activemqconfig () {
include concat::setup
concat {'/usr/local/activemq/apache-activemq-5.5.1/conf/activemq.xml':
owner => 'activemq',
group => 'activemq',
mode => '0644',
@endzyme
endzyme / progress_bars.html.erb
Created April 30, 2013 16:35
Progress bars with twitter and state machines
<% items = @compute_resource.package.package_type.workflow %>
<% items.delete(:adding_to_network) if @compute_resource.load_balancers.empty? %>
<% count = items.count %>
<% state_index = items.index @compute_resource.machine_state.to_sym %>
<% state = @compute_resource.machine_state %>
<% found = false %>
<div class="row">
<% items.each do |e| %>
<div class="span2 pagination-centered">
<%= e.to_s.titleize %>
@endzyme
endzyme / f5_lb_soap_savon.md
Created June 11, 2013 01:01
F5 Load Balancer SOAP API Interactions with Savon

SOAP Calls

Get Heartbeat String

Connection

soap = 
  Savon.client do |s|
    s.wsdl "https://#{ipaddress}/iControl/iControlPortal.cgi?WSDL=LocalLB.Monitor"
    s.basic_auth [user, password]
    s.ssl_verify_mode :none
    s.endpoint "https://#{ipaddress}/iControl/iControlPortal.cgi"
@endzyme
endzyme / C:\Program Files (x86)\Puppet Labs\Puppet\facter\lib\facter\some_fact.rb
Created August 5, 2013 21:40
Custom Facts for Windows in Puppet on the local File System
Facter.add("some_fact") do
setcode do
"return some string"
end
end
#!/usr/bin/env ruby
require 'yaml'
exit_code = 0
if ARGV.length != 1
puts "Usage: ruby validate_ymls.rb directory_absolute_path"
exit!
end
@endzyme
endzyme / install_jenkins_plugins.sh
Last active March 21, 2016 21:23
A quick script to cycle through exsiting plugins in jenkins and install any new ones defined in the script.
#!/bin/bash
#
# Author: Nick Huanca
#
# Basic assumptions:
# - This script is run from cwd: /var/lib/jenkins/plugins
# - You have wget
#
# Known Issues:
# Any versions with "1.2-SNAPSHOT (private blah blah blah)" appended
#!/bin/bash
# Quick Dry Run Example Bash
dry=$1
function run () {
if [ ! -z "$dry" ]; then
echo "WOULD HAVE $@"
else
$@
fi
}