Category Archives: ruby

Ruby – Generate Random Password

0
Filed under ruby
Tagged as , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Generate eight characters random password using Active Support. Active Support is utility classes and standard library extensions from Rails. The preferred method of installing Active Support is through its GEM file. You’ll need to have install RubyGems first (http://docs.rubygems.org/)

#!/usr/bin/env ruby

#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com

require 'rubygems'
require 'active_support'

passwd = ActiveSupport::SecureRandom.base64(8)
puts "Random Password: " + passwd


ruby,code,code,snippet

Ruby – Stackoverflow Notifier

0
Filed under ruby
Tagged as , , , ,

Author: khelll
Site: http://www.khelll.com/blog/
Summary: Simple script to notify the user when a new question is posted on Stackoverflow, it works on Mac and uses growl. You may need install Nokogiri & Growl.

[sudo] gem install nokogiri
[sudo] gem install growl


ruby,code,code,snippet

Ruby – Simple Web Server

0
Filed under ruby
Tagged as , , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Simple web server using Ruby’s standard library. Tested on Linux and Ruby 1.8.7.
Usage: ruby filename.rb

#!/usr/bin/ruby

#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com

require 'webrick'

# importing WEBrick module
include WEBrick

# Creating HTTPServer instance on port 2000
server = HTTPServer.new(
:Port => 2000,
:DocumentRoot => "/home/slac3dork/ruby/www/"
)

# To shutdown server if get an interrupt signal (ctrl-c).
trap("INT"){ server.shutdown }

# To run the server
server.start


ruby,code,code,snippet