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 | |
| def n | |
| STDOUT.sync = true | |
| print '--->' | |
| gets | |
| end | |
| puts "Trying to require blah lib" | |
| puts "require 'blah'" |
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
| # Printing only matching lines | |
| l="john smith\nalice pena\nroot\nbob living\ntammy baroot\ncats" | |
| q="root" | |
| #string.each works by "splitting" on the end of line char... so this works "a\n\b\c" | |
| l.each {|x| next unless x =~ /#{q}/ ; puts "x #{x}" } | |
| # Create a new multi-line string w/only matching lines | |
| s="abc\nlots of girls\nfat chickens\ngirls everywhere\nmeetings\ntaco\ngirl in bikini\ncats" |
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 | |
| @net172_octet_rejects = [nil, %w(16 20 24 31), %w(0 1)] | |
| @net192_octet_rejects = [nil, nil, %w(0 1 2 3 4 5 6 7 8 9 10 168 254)] | |
| def generate_net172(n=:C) | |
| begin | |
| octet_2 = (rand(16) + 16).to_s | |
| end while @net172_octet_rejects[1].include?(octet_2) |
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
| ruby -e 'require "rubygems"; \ | |
| begin; \ | |
| require "fastercsv"; \ | |
| myCSV=FasterCSV; \ | |
| rescue LoadError; \ | |
| require 'csv'; \ | |
| myCSV=CSV; \ | |
| end; \ | |
| s=0; | |
| myCSV.foreach(ARGV[0]) do |r| \ |
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 "rubygems" | |
| begin | |
| require "fastercsv" | |
| myCSV=FasterCSV | |
| rescue LoadError | |
| require 'csv' | |
| myCSV=CSV | |
| 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
| Some methods for randomizing the processing order for results returned from a DB query | |
| Straight SQL | |
| SELECT * FROM `fax_stats` WHERE (`company` IN ('company123')) ORDER BY random(); | |
| ActiveRecord option #1 | |
| FaxStat.find(:all, :conditions => "company='company123'", :order => rand())[2]; |
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
| #!/bin/sh | |
| default_user="root" | |
| user=${default_user} | |
| homedir=`grep "^${user}:" /etc/passwd | awk -F: '{print $6}'` | |
| ssh_dir="${homedir}/.ssh" | |
| auth_key_file="${ssh_dir}/authorized_keys" |
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
| require 'rubygems' | |
| require 'hmac-sha1' | |
| require 'net/https' | |
| require 'base64' | |
| s3_access='S3_ACCESS_KEY' | |
| s3_secret='S3_SECRET_KEY' | |
| cf_distribution='CLOUDFRONT_DISTRIBUTION_ID' | |
| if ARGV.length < 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
| -- Drop this script in ~/Library/Address Book Plug-Ins | |
| -- Edit the path in the "do shell script" line | |
| using terms from application "Address Book" | |
| on action property | |
| return "phone" | |
| end action property | |
| on action title for aPerson with aNumber | |
| return "Dial with Google Voice" | |
| end action title |
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
| bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-latest ) | |
| source /usr/local/rvm/scripts/rvm | |
| echo "source /usr/local/rvm/scripts/rvm" >> $HOME/.profile | |
| yum install -y bash curl gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel iconv-devel | |
| rvm install 1.9.2 | |
| rvm use --default 1.9.2 | |
| gem install bundler |