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/ruby | |
require 'digest/md5' # Hashing strings to MD5 | |
if ARGV[0] != '-i' || ARGV[2] != '-o' || ARGV[3].nil? | |
puts "Syntax Error!" | |
puts "Usage: ruby lookup.rb -i <input file> -o <output file>" | |
else | |
input_file = ARGV[1] | |
if File.exist?(input_file) | |
output_file = ARGV[3] | |
text = File.open(input_file).read |
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 | |
# Ruby script to generate SSHA (Good for LDAP) | |
require 'digest/sha1' | |
require 'base64' | |
# The output in hash will never have trailing whitespace, removed .chomp! | |
hash = Base64.encode64(Digest::SHA1.digest(#{pass}#{salt}#{salt})) | |
# Use string interpolation, no need to add \n puts does this for you | |
puts "userPassword: #{hash}" |
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
class Enumerator::Lazy | |
def filter_map | |
Lazy.new(self) do |holder, *values| | |
result = yield *values | |
holder << result if result | |
end | |
end | |
end | |
class Fizz |
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/ruby | |
def hailstorm n | |
vals = [n] | |
while n > 1 and n = (n.even?) ? (n/2) : (3 * n + 1) | |
vals << n | |
end | |
p vals # List returns | |
end | |
hailstorm(27) |
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/ruby | |
require 'rubygems' | |
require 'RMagick' | |
prompt = '> ' | |
puts "Image to embed (not overwritten):" | |
print prompt | |
image_file = gets.chomp | |
img = Magick::Image::read(image_file)[0] | |
width = img.columns | |
height = img.rows |
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/ruby | |
def weechat_init | |
Weechat.register('exec', 'Ninjex', '1.0', 'GPL3', 'Execute a terminal command via /exec <command>', '', '') | |
Weechat.hook_command('exec', 'Execute a terminal command from chat', '', '', '', 'exec', '') | |
return Weechat::WEECHAT_RC_OK | |
end | |
def exec(data, buffer, args) | |
to = nil | |
buffer = Weechat.current_buffer |
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/ruby | |
# Need to add a validation check on URL's -- just don't be ignorant with it :D | |
require 'mechanize' # Necessary to communicate with the server. | |
def weechat_init | |
Weechat.register('short_url', 'Ninjex', '1.0', 'GPL3', 'Shorten a URL /short_url <link>', '', '') | |
Weechat.hook_command('short_url', 'Shorten URL /short_url <link>', '', '', '', 'short_url', '') | |
return Weechat::WEECHAT_RC_OK | |
end | |
def short_url(data, buffer, args) |
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/ruby | |
# Required packages / gems | |
# libmysql-ruby libmysqlclient-dev | |
# gem mysql2 | |
require 'mysql2' | |
@options = { | |
"public" => "false", # MySQL query result publicly visible | |
"host" => "localhost", # MySQL host | |
"user" => "root", # MySQL username |
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/ruby | |
@convert = { | |
"e" => ["e", "3"], "l" => ["l", "1"], "o" => ["o", "0"], | |
"a" => ["a", "4"], "t" => ["t", "7"], "s" => ["s", "5", "$"], | |
"c" => ["c", "("], "g" => ["g", "6"], "p" => ["p", "9"], | |
"b" => ["b", "8"] | |
} | |
@arrays = @convert.values # Grab all arrays in the hash |
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/ruby | |
require 'mechanize' | |
require 'io/console' | |
def decrypt(str) | |
final = [] | |
for i in (0..str.length) | |
i.odd? ? final << str[i-2] : final << str[i] | |
end |
OlderNewer