Skip to content

Instantly share code, notes, and snippets.

View kwilczynski's full-sized avatar
:octocat:

Krzysztof Wilczyński kwilczynski

:octocat:
View GitHub Profile
kwilczynski@tenahu ~/Development/Projects/Work/CEL/cli-tools (develop *+%)$ ./cl-get-deployment-status -i 73071 -C cookie.txt
Request ID: 73071
Current Status: Succeeded
Description: Execution Complete
Status Date: 2014-02-04T11:22:30.029
Step: 1
Percent Complete: 100
Servers: WA1RMSUBT01
Message: Success
kwilczynski@tehanu ~/Development/Projects/Work/CEL/cli-tools (develop %)$ ./cl-get-server -C cookie.txt -n WA1RMSUBT01
[13] pry(main)> quick(10_000_000) { 'bcdef'.insert(0, 'a') }
Rehearsal ------------------------------------
5.290000 0.000000 5.290000 ( 5.293643)
--------------------------- total: 5.290000sec
user system total real
5.310000 0.000000 5.310000 ( 5.314380)
=> nil
[14] pry(main)> quick(10_000_000) { "a#{'bcdef'}" }
Rehearsal ------------------------------------
gem install nokogiri -- \
--with-xml2-include=/usr/local/Cellar/libxml2/<VERSION>/include\/libxml2 \
--with-xml2-lib=/usr/local/Cellar/libxml2/<VERSION>/lib \
--with-xslt-dir=/usr/local/Cellar/libxslt/<VERSION> \
--with-iconv-include=/usr/local/Cellar/libiconv/<VERSION>/include \
--with-iconv-lib=/usr/local/Cellar/libiconv/<VERSION>/lib
# Avoid the configuration file questions ...
cat <<'EOF' | tee /etc/apt/apt.conf.d/99vagrant &>/dev/null
DPkg::options { "--force-confdef"; "--force-confnew"; }
EOF
# Disable need for user interaction ...
export DEBIAN_FRONTEND=noninteractive
# Setup insecure password "query.8" for the time being ...
echo "mysql-server-5.5 mysql-server/root_password password query.8" | debconf-set-selections
@kwilczynski
kwilczynski / SSL-error
Last active August 29, 2015 14:04
Vagrant with multiple storage attached
chef.custom_config_path = 'Vagrantfile.chef'
For 1.6.3:
```
s.add_dependency(%q<nokogiri>, ["= 1.6.2.1"])
```
Plus, add
```
ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] = '1'
[53] pry(main)> s = StringIO.new
#<StringIO:0xb85c1d8c>
[54] pry(main)> s.write "usable_port_range: '!ruby/range 10200..10500'"
45
[55] pry(main)> s.rewind
0
[56] pry(main)> YAML.load(s.read.gsub(/'(?=!)|'$/, ''))['usable_port_range'].class
Range < Object
[57] pry(main)>
execute 'remove-hostgroup-files' do
action :run
command 'rm -f /etc/nagios/conf.d/hostgroup_*'
only_if 'ls /etc/nagios/conf.d/hostgroup_* >/dev/null 2>&1 || false'
end
def search_nodes(query = nil)
nodes = search(:node, query).reject {|n| n.respond_to?(:empty?) && n.empty? }
nodes.sort! {|a,b| a['name'] <=> b['name'] }
end
chef > recipe_mode
chef:recipe > execute 'test' do
chef:recipe > command 'bash -c "source ~/.bashrc"'
chef:recipe ?> end
=> execute[test] name: "test" noop: nil before: nil params: {} provider: nil allowed_actions: [:nothing, :run] action: "run" updated: false updated_by_last_action: false supports: {} ignore_failure: false retries: 0 retry_delay: 2 source_line: "(irb#1):1:in `irb_binding'" guard_interpreter: :default elapsed_time: 0 resource_name: :execute command: "bash -c "source ~/.bashrc"" backup: 5 creates: nil cwd: nil environment: nil group: nil path: nil returns: 0 timeout: nil user: nil umask: nil cookbook_name: nil recipe_name: nil
chef:recipe >
=> :recipe
chef > run_chef
[2014-08-27T00:27:23+01:00] INFO: Processing execute[test] action run ((irb#1) line 1)
[2014-08-27T00:27:23+01:00] INFO: execute[test] ran successfully
@kwilczynski
kwilczynski / values_at.rb
Last active August 29, 2015 14:06
values_at.rb
#
# values_at.rb
#
# Copyright 2012-2014 Krzysztof Wilczynski
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0