Skip to content

Instantly share code, notes, and snippets.

@directionless
directionless / solar notes.md
Last active February 11, 2016 15:45
Notes about Solar (Massachusetts, circa 2014)

I wrote this in Feburary 2014, as a note to a friend, about solar. Though the market has changed, it might be useful to you.


My partner and I bought a house a couple years ago, and our roof is pretty ideal for solar. This fall, we spent awhile trying to understand the options, and we completed our installation in December. How programs work vary by state and year.

rindge:graphs seph$ ./test-irr.rb
-0.8461538461538315
-0.5233728905609968
-0.3055754160809478
-0.16941929133206396
-0.08153134104840357
-0.02240080635339052
0.018877821951107262
-1.7310946662195288
0.07055058069605046
@directionless
directionless / recipe_example.rb
Created April 29, 2013 15:28
chef sneakyness for managed_directory
managed_directory nrpechef_dir do
action :nothing
notifies :restart, "service[nagios-nrpe-server]"
end
directory nrpechef_dir do
owner "root"
group "root"
mode "0755"
notifies :clean, "managed_directory[#{nrpechef_dir}]", :delayed
end
class Chef::Recipe
def find_nrpe_plugin(name)
return name if name.start_with?("/")
end
end
@directionless
directionless / 1 set
Last active December 14, 2015 19:09
chef -- create an ssh key and store it in the attributes
# Create the ssh access key
#
# Something in the node.set lines happens at the *start* of the chef
# run. It might be the node.set, or it might be the File.read, but
# either way, it happens before the resource execution. To compensate
# for this, we need to shift the ssh key creation to the start of the
# run. http://docs.opscode.com/resource_common_compile.html
sshfile = "/home/runtime/id_rsa"
sshcomment = [
@directionless
directionless / gist:5057589
Last active December 14, 2015 08:28
mongodb sub document trouble
db.foo.insert( {_id: 1}, { "$set": {param: "one" }} )
db.foo.update(
{
"_id": 1,
"sub._id": 2
},
{ $set: { "sub.$": {
"param": 2,
"place": "Boston"
@directionless
directionless / gist:4090745
Created November 16, 2012 20:44
merge asset directories
def symlink_r(source, dest)
# recursively symlinks a directory tree.
# skips files that already exist.
::Dir.glob(::File.join(source, "**", "*")).each do |f|
next if ::File.directory?(f)
new_name = ::File.join(dest, f.gsub(/^#{source}/, "") )
next if ::File.exists?(new_name) or ::File.symlink?(new_name)
::FileUtils.mkdir_p(::File.dirname(new_name))
#puts "trying #{f} => #{new_name}"
::File.symlink(f, new_name)
@directionless
directionless / gist:3866649
Created October 10, 2012 16:16
cpu use test script
#!/usr/bin/env ruby
# we're seeing some odd slowdown on hosts. It kind of looks like the
# host is pausing for some number of milliseconds, which hits the
# various ruby processes. It would be nice if we understood what was
# happening. This is a small script to help understand it.
# theory:
# Do work that takes about N
# Measure elapsed time M
git whittemore:tmp seph$ git clone https://github.com/andersk/mosh.git
Cloning into mosh...
remote: Counting objects: 2305, done.
remote: Compressing objects: 100% (713/713), done.
remote: Total 2305 (delta 1627), reused 2247 (delta 1571)
Receiving objects: 100% (2305/2305), 504.41 KiB | 517 KiB/s, done.
Resolving deltas: 100% (1627/1627), done.
whittemore:tmp seph$ cd mosh/
whittemore:mosh seph$ git checkout macosx
Branch macosx set up to track remote branch macosx from origin.
@directionless
directionless / gist:1934869
Created February 28, 2012 20:20
compiling mosh
export PATH="/Users/seph/homebrew/bin:$PATH"
tar xzf /Users/seph/mosh-0.96a.tar.gz
cd mosh-0.96a
./configure --prefix=/tmp/mosh --with-boost=/Users/seph/homebrew/
make