This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| remote_file "/tmp/remote_file.zip" do | |
| source "http://www.example.com/remote_file" | |
| checksum "sha256checksum" | |
| notifies :run, "bash[unzip_and_own]", :immediately | |
| end | |
| bash "unzip_and_own" do | |
| action :nothing | |
| user "root" | |
| cwd "/destination_path" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cloud_monitoring_alarm "memory_usage alarm" do | |
| check_label "memory" | |
| criteria do | |
| warn_if( | |
| percentage("used", "total"), | |
| ">", | |
| 100, | |
| "Used percentage too high" | |
| ) | |
| warn_if metric("thing"), "<", 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Array | |
| def seach | |
| self.sort.each do |a| | |
| yield a | |
| end | |
| end | |
| end | |
| [2,1,3].seach do |i| | |
| puts i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Object | |
| def to_py_bool | |
| (!!self).to_s.capitalize | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class String | |
| def is_valid_ip? | |
| self.match(/\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/) ? true : false | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var net = require('net'); | |
| function test_connection(addr, port, cb) { | |
| var client = net.createConnection(port, addr); | |
| var start = (new Date()).getTime(); | |
| client.on('connect', function () { | |
| var end = (new Date()).getTime(); | |
| client.end(); | |
| client.destroy(); | |
| cb(null, (end - start)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Traceback (most recent call last): | |
| File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 213, in addCallbacks | |
| self._runCallbacks() | |
| File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 371, in _runCallbacks | |
| self.result = callback(self.result, *args, **kw) | |
| File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 280, in callback | |
| self._startRunCallbacks(result) | |
| File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 354, in _startRunCallbacks | |
| self._runCallbacks() | |
| --- <exception caught here> --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function git_current_branch() { | |
| git symbolic-ref HEAD 2> /dev/null | sed -e 's/refs\/heads\///' | |
| } | |
| function git_current_origin() { | |
| git config --get remote.origin.url | sed -e 's/^.*\://' | sed -e 's/\.git.*//' | |
| } | |
| alias gpr='open "https://github.com/$(git_current_origin)/pull/new/$(git_current_branch)"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function jc { | |
| jmx_host=$1 | |
| jmx_port=${2:-8080} | |
| proxy_host=${3:-$jmx_host} | |
| proxy_port=${4:-8123} | |
| echo "connecting jconsole to $jmx_host:$jmx_port via SOCKS proxy $proxy_host using local port $proxy_port" | |
| ssh -f -ND $proxy_port $proxy_host | |
| jconsole -J-DsocksProxyHost=localhost -J-DsocksProxyPort=${proxy_port} service:jmx:rmi:///jndi/rmi://${jmx_host}:${jmx_port}/jmxrmi | |
| kill $(ps ax | grep "[s]sh -f -ND $proxy_port" | awk '{print $1}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Put this below the other knife.rb stuff | |
| knife[:data_bag_secret_file] = '/Users/phil.kates/.chef/encrypted_data_bag_secret' |