I hereby claim:
- I am mattolenik on github.
- I am matthewolenik (https://keybase.io/matthewolenik) on keybase.
- I have a public key ASCQ3fh9LGPK1UYNYp6L_TGzifcHtI_bVCLZHJyIM-Vk-Qo
To claim this, I am signing this object:
| #!/bin/bash | |
| # From https://stackoverflow.com/questions/16115144/bash-save-and-restore-trap-state-easy-way-to-manage-multiple-handlers-for-trap | |
| trap_stack_name() { | |
| local sig=${1//[^a-zA-Z0-9]/_} | |
| echo "__trap_stack_$sig" | |
| } | |
| extract_trap() { | |
| echo ${@:3:$(($#-3))} | |
| } |
| # Strips n characters from the beginning of the line. This example uncomments a line in /etc/sudoers. | |
| n=3 | |
| cat /etc/sudoers | awk '/^# %wheel ALL=\(ALL\) ALL/ {$0=substr($0,$n)} 1 |
| [[ 'function some_func ( ) {' =~ ^[[:blank:]]*(function[[:blank:]]+)?([\x30-\x39\x41-\x5A\x61-\x7A\xA0-\x19FF\+\-\.\^\/\?,%#_@:~]+)[[:blank:]]*\([[:blank:]]*\)[[:blank:]]*({)?$ ]] | |
| #BASH_REMATCH results: | |
| #0 - whole match | |
| #1 - either 'function' or empty string | |
| #2 - function name | |
| #3 - either '{' or empty string | |
| #Character ranges include pretty much all unicode and normal characters that bash will accept. |
| # Caveat: grep can't match the beginning of the file, so this will catch files with a shebang on any line, | |
| # such as a script being embedded in another kind of file. To get around this each file should be checked with head -n1 | |
| grep -Ir '^#!/.*sh' --exclude-dir 'node_modules' --exclude '*.tpl' ./* | awk -F: '{print $1}' |
| # Install any missing plugins upon 'vagrant up' | |
| def ensure_plugins(required_plugins) | |
| if ARGV[0] == 'up' | |
| missing_plugins = required_plugins.select {|p| not Vagrant.has_plugin? p} | |
| unless missing_plugins.empty? | |
| plugins = missing_plugins.join(' ') | |
| puts "Found missing plugins: #{plugins}, installing..." | |
| exec "vagrant plugin install #{plugins} && vagrant up" | |
| end | |
| end |
| gem_dir = "#{Dir.home}/.vagrant.d/gems/#{RUBY_VERSION}" | |
| begin | |
| name = "inifile" | |
| version = "3.0.0" | |
| Gem::Specification.find_by_name(name, version) | |
| rescue Gem::LoadError | |
| require "rubygems/dependency_installer" | |
| installer = Gem::DependencyInstaller.new(:document => [], :install_dir => gem_dir) | |
| installer.install(name, version) |
I hereby claim:
To claim this, I am signing this object: