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
| # IP to Integer | |
| ip = IPAddr.new('255.255.255.255') | |
| puts ip.to_i | |
| # Integer to IP | |
| ipnum = 4294967295 | |
| ip = IPAddr.new(ipnum, Socket::AF_INET).to_s | |
| # If you store the ipnum in MySQL, make sure to use unsigned into for the field. |
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
| namespace :buildout do | |
| #----------------------------------------------------------------------------# | |
| desc "Mirror the dynamic site into Rails.env/out" | |
| task :mirror do | |
| outdir = File.join(Rails.root, "out") | |
| Dir.mkdir(outdir) unless (File.exist?(outdir) && File.directory?(outdir)) | |
| Dir.chdir(outdir) do | |
| `wget -m -nH http://localhost:3000` | |
| 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
| rxvt -geometry 80x65-0+0 & | |
| rxvt -geometry 80x65+600+0 & | |
| rxvt -geometry 80x65+100+0 & | |
| rxvt -geometry 180x24+0-25 & | |
| rxvt -geometry 180x24+0+195 & | |
| rxvt -geometry 80x39+0+0 & |
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' | |
| require 'ipaddr' | |
| cidr = IPAddr.new("172.20.0.0") | |
| # cidr = IPAddr.new("198.6.5.0") | |
| mask = 16 | |
| # ip = IPAddr.new("198.6.5.22") | |
| ip = IPAddr.new("172.20.155.101") |
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
| module Encoding | |
| def aes_encode(string, passphrase) | |
| c = OpenSSL::Cipher::Cipher.new("aes-256-cbc") | |
| c.encrypt | |
| c.key = key = Digest::SHA1.hexdigest(passphrase) | |
| e = c.update(string) | |
| e << c.final | |
| end | |
| def aes_decode(string, passphrase) |
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
| if (!RegExp(/^\s*$/).test($("#message-popdown").html())) { | |
| $("#message-popdown").slideDown("slow", function() { | |
| var that = $(this); | |
| setTimeout(function() {that.slideUp();}, 5000); | |
| }); | |
| } | |
| $("#message-popdown").click(function() { | |
| $(this).slideUp(); | |
| }); |
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
| #message-popdown { | |
| background-color: #dea852; | |
| display: none; | |
| position: fixed; | |
| z-index: 999; | |
| cursor: pointer; | |
| padding-top: 20px; | |
| padding-bottom: 20px; | |
| -webkit-border-bottom-right-radius: 10px; | |
| -webkit-border-bottom-left-radius: 10px; |
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
| <div id="message-popdown" class="grid_12"> | |
| <% if flash[:error_msg] %> | |
| <span class="error-msg"><%= flash[:error_msg] %></span> | |
| <% elsif flash[:success_msg] %> | |
| <span class="success-msg"><%= flash[:success_msg] %></span> | |
| <% elsif flash[:warning_msg] %> | |
| <span class="warning-msg"><%= flash[:warning_msg] %></span> | |
| <% elsif flash[:message] %> | |
| <span class="notice-msg"><%= flash[:message] %></span> | |
| <% 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
| require 'date' | |
| (Date.new(year, 12, 31) << (12-month)).day # Ruby 1.8.x | |
| Date.new(2010, 12, 31).prev_month(12 - 4).day # Ruby 1.9.x |
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
| # requires and stuff go here | |
| def load_irbrc(path) | |
| return if (path == ENV["HOME"]) || (path == '/') | |
| load_irbrc(File.dirname path) | |
| irbrc = File.join(path, ".irbrc") | |
| load irbrc if File.exists?(irbrc) |