Skip to content

Instantly share code, notes, and snippets.

View bleything's full-sized avatar
🤡
Computerin'

Ben Bleything bleything

🤡
Computerin'
View GitHub Profile
require 'json'
namespace :databags do
desc "Update databags on server from disk"
task :push do
Dir[ 'data_bags/**/*json' ].each do |file|
bag = file.split('/')[1]
sh "knife data bag from file #{bag} #{file}"
end
end
%w{
nagios-nrpe-server nagios-plugins
nagios-plugins-basic nagios-plugins-standard
}.each do |pkg|
package(pkg) do
# your options here
end
end
sorted = stats[key].sort
min = sorted.first
max = sorted.last
sum = sorted.inject(0) {|sum,sample| sum + sample }
avg = sum / sorted.size
# calculate standard deviation
diffs = sorted.map {|val| val - avg }
squared_diffs = diffs.map {|val| val ** 2 }
sqd_diff_sum = squared_diffs.inject(0) {|sum,sample| sum + sample }
@bleything
bleything / flac2mp3
Created August 23, 2010 17:42 — forked from mxcl/flac2mp3.md
#!/usr/bin/ruby
# http://gist.github.com/gists/124242
filename=ARGV[0]
abort "Usage: flac2mp3 FLACFILE" if filename.nil?
`metaflac --export-tags-to=- "#{filename}"`.each_line do |s|
v=s.strip.split '=', 2
v[0].upcase!
v[1].gsub! '"', '\"'

DESCRIPTION:

Create and manage users and groups

DATABAGS:

users

{

"id"       : "username",
require 'rubygems'
require 'eventmachine'
puts Date.today
module Enumerable
def frequencies
counts = Hash.new(0)
self.each{|item| counts[item] +=1}
return counts
end
end
namespace "/api/v1" do
# mounted at /api/v1/things
get "/things" {}
# mounted at /api/v1/admin/asplode
get "/admin/asplode" {}
end
@bleything
bleything / example.rb
Created March 11, 2010 19:21
an example of Hash[ *ary1.zip(ary2).flatten ]
require 'pp'
# say you've loaded a csv file with a header row, but you don't have
# access to any nice csv library. All you've got is an array of rows,
# which are also arrays:
#
# [
# [ a, b, c, d ],
# [ 1, 2, 3, 4 ],
# [ 5, 6, 7, 8 ],
What I Want In A Site Generator: An Essay
by Ben Bleything
Mrs. Anderson's 4th Grade Class
------------
All of the static generators I've looked at so far have some nice
features, but none of them really come together for me. I like what
Jekyll is doing with a flat directory of posts, but I _don't_ like how
you have no control over where those posts go.