Skip to content

Instantly share code, notes, and snippets.

View clifferson's full-sized avatar

Cliff Erson clifferson

View GitHub Profile
@clifferson
clifferson / gist:4576573
Created January 20, 2013 03:50
Compact couchdb with curl
curl -H "Content-Type: application/json" -X POST http://localhost:5984/chef/_compact
@clifferson
clifferson / gist:4570717
Created January 19, 2013 04:17
If your chef-server checksum dir gets out of whack with couchdb
/usr/bin/find /var/cache/chef/checksums/ -maxdepth 1 -type f -ctime +1 -delete
Then delete all the checksums in CouchDB using Shef:
require 'chef/checksum'
r = Chef::REST.new('http://localhost:5984/chef/_design/checksums/_view/', false, false)
r.get_rest("all")["rows"].each do |c| c["value"].cdb_destroy end
@clifferson
clifferson / gist:4399205
Last active December 10, 2015 07:09 — forked from grantm/gist:4367372
scp override function for when you forget the :.
# a useful addition to anyone's .bashrc
#
# Note, you don't want this function in effect on the remote host side of the scp transfer,
# so make sure to only define it for interactive shells, e.g.: wrap with: if [ ! -z "$PS1" ]
function scp() {
if echo "$@" | grep -q ':'
then
/usr/bin/scp "$@"
else
@clifferson
clifferson / gist:4243867
Created December 9, 2012 08:20
chef-solr change solr document commit interval
/var/lib/chef/solr/home/conf/solrconfig.xml
<autoCommit>
<maxDocs>100</maxDocs>
<maxTime>60000</maxTime>
</autoCommit>
@clifferson
clifferson / hack.sh
Created December 6, 2012 13:30 — forked from DAddYE/hack.sh
OSX For Hackers
#!/bin/sh
##
# This is a script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# Run in interactive mode with:
# $ sh -c "$(curl -sL https://raw.github.com/gist/2108403/hack.sh)"
#
# or run it without prompt questions:
@clifferson
clifferson / knife-config
Created November 10, 2012 04:11 — forked from capoferro/knife-config
Shell script to swap knife configs
#!/bin/sh
die () {
echo >&2 "$@"
exit 1
}
available_configs () {
echo "Available configs:"
ls -A ~ | grep .chef- | sed 's/.chef-//'
}
@clifferson
clifferson / noit.rb
Created August 17, 2012 04:51 — forked from thommay/noit.rb
Modify a file line inline in chef
ruby_block "configure #{p} module" do
block do
require 'chef/util/file_edit'
nc = Chef::Util::FileEdit.new("/etc/reconnoiter/noit.conf")
nc.insert_line_after_match(/lua.*noit.module.smtp/, "<module loader=\"lua\" name=\"#{p}\" object=\"noit.module.#{p}\"/>")
nc.write_file
Chef::Log.info "Inserted module config for #{p}"
end
http://tickets.opscode.com/browse/CHEF-78?focusedCommentId=10781&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-10781
@clifferson
clifferson / gist:3369464
Created August 16, 2012 11:26
Put a comma after each line except the last when generating a template in chef
rack_map = {
<% counter = @options.size %>
<% @options.each do |key, value| %>
<% counter -= 1 %>
'<%= key %>' => '<%= value %>'<%= ',' unless counter == 0 %>
<% end %>
}
value = 5; while value > 0; value -= sleep(value); end
@clifferson
clifferson / gist:3177657
Created July 25, 2012 18:17
Output the public key for a private key.
ssh-keygen -y -f <private key file>