This file contains 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
sudo last -i -f /var/log/btmp | | |
awk '{ per[$3] += 1 } END { for (i in per) print per[i], i }' | | |
sort -n | | |
tail -15 |
This file contains 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
echo -e 'count\t size\t name' | |
for dir in *; do | |
echo -e `find "$dir" -type f | wc -l` '\t' \ | |
`du -sh "$dir" | awk '{ print $1 }'` '\t' \ | |
"$dir" | |
done | sort -n |
This file contains 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
ip addr show | | |
grep 'inet' | | |
awk '{ print $2 }' | | |
awk -F / '{ print $1 }' | | |
sort |
This file contains 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
Is there a way to get mustache to do the following? |
This file contains 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
def collapse_array_of_ranges(array) | |
# simplify, by sorting on range.begin | |
array.sort_by(&:begin).inject([]) do |a, r| | |
# compared with last range... | |
last_range = a[-1] | |
if last_range && last_range.include?(r.begin) | |
# ignore range if it is completely inside of last range | |
unless(last_range.include?(r.end)) | |
# this range overlaps last range, | |
# thus, pull off last range and merge them |
This file contains 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
# stick this code at the bottom of your config/environment.rb | |
# (unless, of course, you already have something similar) | |
initializer_glob = File.join(RAILS_ROOT, "config/initializers/*.rb") | |
initializers = Dir[initializer_glob].map {|f| File.expand_path(f) }.sort | |
initializers.each {|f| require f } |
This file contains 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 into your config/eydeploy.rb | |
def bundle | |
if File.exist?("#{c.release_path}/Gemfile") | |
info "~> Gemfile detected, bundling gems" | |
lockfile = File.join(c.release_path, "Gemfile.lock") | |
bundler_installer = if File.exist?(lockfile) | |
get_bundler_installer(lockfile) | |
else | |
warn_about_missing_lockfile |
This file contains 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
ip_prefix=xxx.yyy.zzz | |
count=4 | |
for (( i=96; i <= 127; i=i+1 )); do ip=$ip_prefix.$i; echo Trying $ip; mtr -nr -c $count $ip; done | |
# or | |
for (( i=96; i <= 127; i=i+1 )); do ip=$ip_prefix.$i; echo Trying $ip; arping -c $count -w $count $ip; done | |
# ... |
This file contains 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 | |
module TopLevel | |
CONST_D = :d_from_top_level | |
module MiddleLevel | |
class BottomLevel | |
CONST_A = :foo | |
CONST_B = :bar | |
CONST_C = :c_from_bottom_level |
This file contains 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 | |
module M | |
extend self | |
def foo | |
"hello world" | |
end | |
private |