Skip to content

Instantly share code, notes, and snippets.

@rbirnie
rbirnie / README.md
Last active August 18, 2018 14:58 — forked from rowanu/README.md
Hotness Widget for the Dashing dashboard from Shopify

Dashing Hotness Widget + change-rate

Are you dashing? Are you hot? Then you need the Dashing Hotness Widget! Forked from here: Source. See the original blog post for more details.

Important Unlike the original Hotness widget which used value, this widget uses current and last and can be a direct drop in replacement for the Number widget.

About

This widget is similar to standard Hotness widget but I've added the change-rate arrows from the basic Number widget. The entire widget changes colour based on the value displayed. It is designed to draw attention to

cd /usr/share/foreman
rails c
1.9.3-p484 :001 > a = Host.find_by_name 'hostname'
1.9.3-p484 :002 > a.interfaces
Nic::Base Load (1.2ms) SELECT `nics`.* FROM `nics` WHERE `nics`.`host_id` = 237
+----+-------------------+-------------+----------+------+---------+-----------+-----------+-------------------------+-------------------------+-------------------------+
| id | mac | ip | type | name | host_id | subnet_id | domain_id | attrs | created_at | updated_at |
+----+-------------------+-------------+----------+------+---------+-----------+-----------+-------------------------+-------------------------+-------------------------+
| 6 | 5c:f9:dd:f0:a7:50 | 10.199.11.8 | Nic::BMC | | 237 | | | {:username=>"root", ... | 2013-11-27 01:00:37 UTC | 2013-11-27 01:00:37 UTC |
+----+-------------------+-------------+----------+------+---------+-----------+-----------+-------------------------+-------------------------+-
@rbirnie
rbirnie / gist:7348574
Created November 7, 2013 03:37
Override macaddress fact to always be eth0
#!/usr/bin/ruby
# Eth0 is better than alphabetical.
require 'facter'
Facter.add(:macaddress) do
has_weight 10
setcode do
`facter macaddress_eth0`.strip
end

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@rbirnie
rbirnie / LDAP Error Key.md
Last active December 10, 2015 22:59
LDAP Result Log Key

tail -f /usr/share/foreman/log/production.log

Successful login: # Woot!

Started POST "/users/login" for 10.0.0.2 at Thu Jan 10 14:50:01 -0800 2013
Processing by UsersController#login as HTML
Parameters: {...}

Bad User Password:

@rbirnie
rbirnie / auth_source_ldap.rb
Last active December 9, 2015 23:59
updated auth_source_ldap.rb
# adding these to 60 & 61
# logger.debug "Result: #{ldap_con.get_operation_result.code}" if logger && logger.debug?
# logger.debug "Message: #{ldap_con.get_operation_result.message}" if logger && logger.debug?
# redMine - project management software
# Copyright (C) 2006 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
@rbirnie
rbirnie / fact_importer.rb
Last active October 13, 2015 21:58
fact_importer
#! /usr/bin/env ruby
#
# This scripts runs on remote puppetmasters that you wish to import their nodes facts into Foreman
# it uploads all of the new facts its encounter based on a control file which is stored in /tmp directory.
# This script can run in cron, e.g. once every minute
# if you run it on many puppetmasters at the same time, you might consider adding something like:
# sleep rand(10) # that not all PM hammers the DB at once.
# ohadlevy@gmail.com
# note this requires ruby 1.8.7+
[root@test ]# tftp foreman
tftp> get pxelinux.0
tftp> quit
[root@test ]# ls | grep pxelinux.0
pxelinux.0
@rbirnie
rbirnie / gist:4019346
Created November 5, 2012 18:06
Fact Loop
irb(main):049:0> a = 0
=> 0
irb(main):050:0> FactValue.where(:fact_name_id => fact_name_id).includes(:fact_name).map do |fact|
irb(main):051:1* a += 1
irb(main):052:1> puts fact.value
irb(main):053:1> end
irb(main):054:0> a
=> 6391
irb(main):061:0> FactValue.group(:fact_name_id, :value).where(:fact_name_id => fact_name_id).includes(:fact_name).map do |fact|
irb(main):062:1* a += 1
@rbirnie
rbirnie / _fact_hosts.html.erb
Created November 1, 2012 05:26
Show page with Partials
<% list = @hosts.nil? ? @trend : @hosts %>
<% list.values.includes(:trendable).in_groups(4, false) do |group| %>
<div class="span3">
<td>
<% group.each do |host| -%>
<ul class="base">
<li>
<% opts = host.name? ? host.name : host.fact_value %>
<%= link_to(opts, host_path(:id => opts), :title => "Show Host") %>
</li>