Skip to content

Instantly share code, notes, and snippets.

@sczizzo
sczizzo / pmap.rb
Created March 7, 2016 15:35
Simple, plain Ruby implementation of parallel map/each
#!/usr/bin/env ruby
require 'thread'
Thread.abort_on_exception = true
module Enumerable
def peach n=nil, &block
pmap n, &block
self
end
@sczizzo
sczizzo / node_log_and_cookbooks.rb
Created February 8, 2015 01:28
Node Log and Cookbooks Knife Plugin
require 'chef/knife'
module Plugins
class NodeCookbooks < Chef::Knife
banner "knife node cookbooks NODE"
deps do
require 'chef/search/query'
require 'chef/knife/search'
@sczizzo
sczizzo / report_log.rb
Created February 7, 2015 23:49
Log Handler
require 'chef/handler'
require 'chef/log'
require 'json'
# Based on https://docs.chef.io/handlers.html#cookbook-versions
# and http://dev.nuclearrooster.com/2011/05/10/chef-notifying-and-logging-updated-resources
module Handlers
@sczizzo
sczizzo / updated_resources.rb
Last active August 29, 2015 14:14
Updated Resources Report Handler
require 'chef/handler'
require 'chef/log'
require 'json'
# Based on http://dev.nuclearrooster.com/2011/05/10/chef-notifying-and-logging-updated-resources/
module Handlers
class UpdatedResources < Chef::Handler
@sczizzo
sczizzo / cookbook_versions.rb
Last active August 29, 2015 14:14
Cookbook Versions Report Handler
require 'chef/handler'
require 'chef/log'
require 'json'
# Based on https://docs.chef.io/handlers.html#cookbook-versions
module Handlers
class CookbookVersions < Chef::Handler
@sczizzo
sczizzo / kitchen--logs--default-ubuntu-1404.log
Created November 6, 2014 23:37
Test Kitchen logs for Issue #537
F, [2014-11-06T14:13:36.636050 #51663] FATAL -- default-ubuntu-1404: The `berkshelf' gem is missing and must be installed or cannot be properly activated. Run `gem install berkshelf` or add the following to your Gemfile if you are using Bundler: `gem 'berkshelf'`.
F, [2014-11-06T14:13:59.797336 #51860] FATAL -- default-ubuntu-1404: The `berkshelf' gem is missing and must be installed or cannot be properly activated. Run `gem install berkshelf` or add the following to your Gemfile if you are using Bundler: `gem 'berkshelf'`.
F, [2014-11-06T14:14:17.284094 #52049] FATAL -- default-ubuntu-1404: The `berkshelf' gem is missing and must be installed or cannot be properly activated. Run `gem install berkshelf` or add the following to your Gemfile if you are using Bundler: `gem 'berkshelf'`.
I, [2014-11-06T14:14:34.938104 #52250] INFO -- default-ubuntu-1404: -----> Cleaning up any prior instances of <default-ubuntu-1404>
I, [2014-11-06T14:14:34.938218 #52250] INFO -- default-ubuntu-1404: -----> Destroying <default-
@sczizzo
sczizzo / version.rb
Last active December 25, 2015 00:59
Quick version comparator
class Version
include Comparable
attr_reader :a, :b, :c, :str
def initialize str
parts = str.split('.')
raise unless parts.length == 3
@a, @b, @c = parts.map(&:to_i)
@str = str
end
@sczizzo
sczizzo / zk_demo_lock.rb
Created August 28, 2013 22:27
Implementation of distributed locking with ZooKeeper
#!/usr/bin/env ruby
require 'rubygems'
require 'zk'
require './zk_ext'
ZK.open '10.0.0.100:2181' do |zk|
zk.with_lock('test') do
zk.explore '/'
end
end
@sczizzo
sczizzo / screenshot.png
Last active December 21, 2015 10:09
Electric rain / static shock / thunder mountain
screenshot.png
@sczizzo
sczizzo / analyze_prontonation.py
Created March 15, 2013 21:54
Examine the relationship between the sidechain separation and protonation
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from marshal import dump, load
from random import sample
from glob import glob
from pdb import *
import sys
def run_experiment(residues, interests, ss_code=None, mind=0.0, maxd=100.0):