Skip to content

Instantly share code, notes, and snippets.

View larrywright's full-sized avatar

Larry Wright larrywright

View GitHub Profile
@larrywright
larrywright / Markdown Link.workflow
Last active October 19, 2021 16:36
A MacOS Automation for converting a Safari window full of tabs into Markdown-formatted links, as well as one for just a single link.

ChefDK, Test Kitchen Driven NTP Cookbook

This gist uses TK+Berkshelf to drive creating a vagrant virts and converging a simple recipe to install and configure NTPd. This is a simple cookbook that has one recipe, one template (for ntp.conf) and one attribute file. It works on Ubuntu 12.04 and CentOS 6.4 (and derviatives) and the attribute file is used to support both distros.

This should work on Mac (where I developed it) and any chef-supported Linux that you can get Vagrant onto (Ubuntu/CentOS).

Because I use ChefDK and Test Kitchen, I can largely ignore setting up Vagrant and Berkshelf and can get right to work on writing recipe code.

NOTE: Modern (7/6/2014) Recipe Generation

Keybase proof

I hereby claim:

  • I am larrywright on github.
  • I am larrywright (https://keybase.io/larrywright) on keybase.
  • I have a public key whose fingerprint is EF5C 1336 516C 0BA7 46DE 62FF 93F6 11C2 9097 498B

To claim this, I am signing this object:

Chef 11 introduces event dispatching mechanism, which emits event at different milestones in Chef run (aka lifecycle) , and users can add their custom handlers to hook into these events. Chef formatters already uses this API. For a complete list of currently available events check this

Following is a bare minimal example for adding a custom handler:

chef_event_handler_foo.rb

require 'chef/event_dispatch/base'
class Foo < Chef::EventDispatch::Base
  # lets say hello world when chef run ends
 def run_completed(node)
@larrywright
larrywright / gist:4052883
Created November 10, 2012 23:03
Evernote

I use Instapaper as well, but the things I might want to read again, I email into Evernote, and then I tag them. Evernote's full text search is really good, and will make it easier to find things later. Notebooks and tags also allow you to categorize things. When I'm researching a new technology or a product, I can clip a bunch of things into Evernote and then tag them with the tech (Chef, ElasticSearch, whatever).

Email stuff into Evernote. I do this all the time. Tax receipts get a tag for the year and get stuck in a folder called "Tax Receipts". Then at the end of the year it's easy to find them. Tweets that contain links I may want to look at later get emailed into Evernote.

If you scan documents, Evernote will OCR them and then the search makes them easy to find.

Checklists. I do checklists for quick todo lists, like travel checklists and things.

Notes. I take meeting notes, tag it with the project name, and then I can email or share them in Evernote. I also use it for lots of other notetaking task

@larrywright
larrywright / IPInsetLabel.h
Created May 4, 2012 17:59
IPInsetLabel: a simple UILabel subclass that adds padding insets and auto-height-resizing
//
// IPInsetLabel.h
// Instapaper
//
// Created by Marco Arment on 7/23/11.
// Copyright 2011 Instapaper LLC, released to the public domain.
//
#import <UIKit/UIKit.h>
@larrywright
larrywright / Procfile
Created February 25, 2012 16:29 — forked from ngauthier/Procfile
Heroku Serving a Directory
web: ruby serve.rb $PORT
@larrywright
larrywright / chat.rb
Created January 1, 2012 05:17 — forked from rkh/chat.rb
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
Larrys-MacBook-Air:gutenberg larrywright$ rake db:migrate --trace
rake aborted!
can't convert Class into String
org/jruby/RubyFile.java:872:in `basename'
org/jruby/RubyFile.java:1069:in `extname'
/Users/larrywright/.rvm/gems/jruby-1.6.3/gems/rake-0.9.2/lib/rake/application.rb:561:in `load_imports'
/Users/larrywright/.rvm/gems/jruby-1.6.3/gems/rake-0.9.2/lib/rake/application.rb:502:in `raw_load_rakefile'
/Users/larrywright/.rvm/gems/jruby-1.6.3/gems/rake-0.9.2/lib/rake/application.rb:78:in `load_rakefile'
/Users/larrywright/.rvm/gems/jruby-1.6.3/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/larrywright/.rvm/gems/jruby-1.6.3/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
@larrywright
larrywright / gist:1161155
Created August 21, 2011 20:57
remote_file checksum wonkiness
17)
[Sun, 21 Aug 2011 20:59:38 +0000] DEBUG: remote_file[/opt/logstash/logstash-1.0.14.jar] checking for changes
[Sun, 21 Aug 2011 20:59:38 +0000] DEBUG: Sending HTTP Request via GET to semicomplete.com:80/files/logstash/logstash-1.0.14-monolithic.jar
[Sun, 21 Aug 2011 20:59:38 +0000] DEBUG: Streaming download from http://semicomplete.com/files/logstash/logstash-1.0.14-monolithic.jar to tempfile /tmp/chef-rest20110821-12274-dr3ntz-0
[Sun, 21 Aug 2011 21:00:08 +0000] DEBUG: remote_file[/opt/logstash/logstash-1.0.14.jar] checking for file existence of /opt/logstash/logstash-1.0.14.jar
[Sun, 21 Aug 2011 21:00:08 +0000] DEBUG: remote_file[/opt/logstash/logstash-1.0.14.jar] file exists at /opt/logstash/logstash-1.0.14.jar
[Sun, 21 Aug 2011 21:00:08 +0000] DEBUG: remote_file[/opt/logstash/logstash-1.0.14.jar] target checksum: 06fc4d82dc87d65a581c881b94cb34735bab5186121cd05f3daa5e80f3357807
[Sun, 21 Aug 2011 21:00:08 +0000] DEBUG: remote_file[/opt/logstash/logstash-1.0.14.jar] source checksum: 06fc4d82dc87d65a581c88