Skip to content

Instantly share code, notes, and snippets.

View frimik's full-sized avatar

Mikael Fridh frimik

  • Electronic Arts / DICE
  • Uppsala, Sweden
View GitHub Profile
@vStone
vStone / params.pp
Created January 19, 2012 15:25
Example / Trial use case for 'dynamic' module incorp.
# === Actions:
#
# === Requires:
#
# === Sample Usage:
#
class passenger::params (
$packages = undef,
$configpath = undef,
$version = undef,
@jordansissel
jordansissel / README.md
Created February 19, 2012 06:30
Reading RPMs

Something in RPM changed between RHEL5 and RHEL6.

I can read RPMs for CentOS5 and earlier, but in EL6, the signature header is longer than expected by exactly 4 bytes. I have also observed some normal header (non signature) sections being longer than expected by 16 bytes. It is quite confusing.

If you have insight, please let me know here.

#! /bin/sh
#
USER="admin"
PASS="changeme"
FOREMAN_URL="https://foreman"
FQDN=$1
CHANGED_ATTRIBUTE="host[environment_id]=2"
curl -H "Accept:application/json" -X PUT \
-k -u $USER:$PASS \
@rafaelp
rafaelp / gist:1976687
Created March 5, 2012 04:55
A solution to a more obscure problem related to the "vulnerability" of mass assignment:
# account.rb
class Account < ActiveRecord::Base
has_many :users
has_many :services
end
# user.rb
class User < ActiveRecord::Base
belongs_to :account
end
@GregSutcliffe
GregSutcliffe / gist:2503242
Created April 26, 2012 21:04
Gitolite config example
class test {
# Create the admin repo in the inital call, using defaults
class { 'gitolite': }
# Optionally override with your own config and keys
#class { 'gitolite': }
# authfile => 'puppet:///modules/test/admin.conf',
# keydir => 'puppet:///modules/test/admin-keys',
#}
#!/bin/bash
#
# IRC notification post-receive hook.
# Based on https://wiki.icinga.org/display/community/GIT+Commit+Bot
#
# Author: Mikael Fridh <frimik@gmail.com>
# Modified by: Greg Sutcliffe <gsutcliffe@ibahn.com
#
# This script pulls out the commit information and sends it to
# the RemoteCtl plugin in rbot via quassel.office:7268 using
# encoding: binary
# Removes any bytes from a string that are not valid UTF-8
class Cleaner
attr_reader :bytes, :buffer, :outstanding
def self.clean(str)
new.tap { |c| c << str }.to_s
end
class Array
def expand_ranges
self.collect { |wtf| wtf.is_a?(Range) ? wtf.to_a : wtf }.flatten
end
end
[1..15, 19, 21..25].expand_ranges.each { |i| puts i }
@crazed
crazed / ip.rb
Created December 2, 2011 21:42
useful facter plugins
if File::exists?("/sbin/ip")
Facter.add('gateway') do
setcode do
`/sbin/ip route show`.match(/^default.*/)[0].match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/)[0]
end
end
end