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
#!/usr/bin/env sh | |
# | |
# install GNU grep (`/usr/local/bin/ggrep`)... | |
# | |
# brew tap homebrew/dupes; brew install grep | |
# | |
# usage - ensure `${PROJECTS_HOME}` is set... | |
# | |
# find ${PROJECTS_HOME}/seedy/content -name '*.md' | ./validate_external_urls.sh > seedy_external_urls.tsv |
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
# | |
# This first version should work on Mac OS X and Linux, but it spawns a process | |
# | |
# the number of TCP connections owned by the process. | |
def Process.tcp_count() `lsof -l -n -P -p #{Process.pid} -a -i tcp | egrep -v '^COMMAND' | wc -l`.chomp.to_i ; 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
#!/usr/bin/env ruby | |
require 'pp' | |
def ruby_repl processor = nil | |
unless (processor && Proc === processor) || block_given? | |
warn "Please invoke `ruby_repl` with a block or a proc..." | |
else | |
in_pry = Kernel.const_defined?("Pry::ColorPrinter") | |
cmd_count = 0 # for use in the command prompt |
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
#!/usr/bin/env ruby | |
# A quick and dirty implementation of an HTTP proxy server in Ruby | |
# because I did not want to install anything. | |
# | |
# Copyright (C) 2009-2014 Torsten Becker <[email protected]> | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining | |
# a copy of this software and associated documentation files (the | |
# "Software"), to deal in the Software without restriction, including | |
# without limitation the rights to use, copy, modify, merge, publish, |
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
#!/usr/bin/env ruby | |
# | |
# This script can be used to patch the following script on an Amazon Linux AMI: | |
# | |
# /etc/update-motd.d/70-available-updates | |
# | |
# which is run by cron on a daily basis to add package update info to the MOTD: | |
# | |
# 19 package(s) needed for security, out of 160 available |
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
# as a String | |
HOME = ENV['HOME'] || File.expand_path("~#{Etc.getlogin}") | |
# as a Pathname | |
HOME = Pathname.new(ENV['HOME'] || File.expand_path("~#{Etc.getlogin}")) |
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
#!/usr/bin/env ruby | |
# Remove all gems EXCEPT defaults :) | |
`gem list -d`.split(/\n\n^(?=\w)/).each do |data| | |
match = data.match(/(?<name>([^\s]+)) \((?<versions>.*)\)/) | |
name = match[:name] | |
versions = match[:versions].split(', ') | |
if match = data.match(/^.*\(([\d\.]*),? ?default\): .*$/) | |
next if match[1].empty? # it's the only version if this match is empty |
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
# | |
# This first version should work on Mac OS X and Linux, but it spawns a process | |
# | |
# http://stackoverflow.com/questions/7220896/ | |
# https://github.com/rdp/os/blob/master/lib/os.rb#L127 | |
# http://www.ruby-doc.org/core-2.0/Process.html | |
# | |
# A better - but more complicated - way to achieve the same is documented here: | |
# | |
# https://build.betterup.com/tracking-a-processs-memory-usage-in-ruby/ |
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
#!/usr/bin/ruby | |
require 'rubygems' | |
installed_gems = Gem::Dependency.new '', Gem::Requirement.default | |
missing = [] | |
# mind the short-hand, looping over installed gem specs | |
specs = Gem.source_index.search installed_gems | |
specs.each do |spec| | |
gem = Gem::Dependency.new spec.name, spec.version | |
# looping over gem dependencies | |
specs = Gem.source_index.search gem |
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
#!/usr/bin/env ruby | |
# | |
# NAME | |
# | |
# benchmark.rb -- a multi-dimensional Ruby benchmark script :-) | |
# | |
# DESCRIPTION | |
# | |
# a customized Ruby "interpreter" that benchmarks | |
# other Ruby scripts... by default, both resident |