Ruby - http sniffing Ruby
#!/usr/local/bin/ruby require 'pcaplet' httpdump = Pcaplet.new('-s 1500 -i eth0') HTTP_REQUEST = Pcap::Filter.new('tcp and dst port 80', httpdump.capture) HTTP_RESPONSE = Pcap::Filter.new('tcp ...
View ArticleRuby - usuario, clave y calculadora
usuario_correcto= "clober" clave_correcta= "clobero" puts "Introduce tu nombre de usuario" usuario = gets.chomp while (usuario != usuario_correcto) do puts "El usuario no es correcto ...
View ArticleRuby - Object#tap
# encoding: utf-8 'one two three' .split .tap { |x| p x } .collect(&:upcase) .tap { |x| p x } .join(' ') .tap { |x| p x } #=> ["one", "two", "three"] # ["ONE", " ...
View ArticleRuby - Ruby: File Path Basics
#Platform independant way of showing a File path. Empty String ('') means the root puts File.join('', 'Users', 'chrisaiv', 'Desktop') #Provide the RELATIVE path of THIS file puts __FILE__ # ...
View ArticleRuby - tribial
preguntas = ["¿Quien levanto la copa del mundo en 2010?", "¿Qien fue el primer pais que hizo mapas de todo el mundo?", "¿Cuando nacio Michael Jackson ...
View ArticleRuby - Howto set up a Rake task to run Cucumber features and generate reports
require 'cucumber' require 'cucumber/rake/task' desc 'Run Cucumber features and generate an HTML summary, JUnit XML and a plain text log' Cucumber::Rake::Task.new(:features) do |t| t. ...
View ArticleRuby - stupid hash update experiments in ruby
h1 = {'1'=>'a', '2'=>'b', '3'=>'c', '4'=>'z'} h2 = {'4'=>'e'} puts h1.inspect # => {"1"=>"a", "2"=>"b", "3"=>"c", "4"=>"z"} h1.update(h2) puts h1.inspect # =>...
View ArticleRuby - Filter base64 encoded Textmate snippet back into text
ruby -e "require 'base64'; print Base64.decode64( STDIN.read ...
View ArticleRuby - Format strings like PRINT USING
require 'strscan' class String # Returns the string formatted according to a pattern. # # The pattern consists of placeholders and literals. The string is placed in # the placeholders ...
View ArticleRuby - Rollup Count of Events
if ARGV[0] == nil then puts "SYNTAX: smtp_errors.rb " exit end log = ARGV[0] offenders = Hash.new(0) File.open(log,"r").each do |line| if line =~ /SMTP error/ then addy = line ...
View ArticleRuby - uTorrent WebUI API Ruby Class
#!/usr/bin/env ruby # uTorrent WebUI API Class for Ruby # Copyright (C) 2012 Keiran "Affix" Smith # http://affix.me # # This program is free software: you can redistribute it and/or ...
View ArticleRuby - facebook chat
require 'mechanize' require 'json' require 'ostruct' require 'pp' class FacebookChat def initialize(email, pass); @email, @pass = email, pass; end def login @agent = WWW::Mechanize. ...
View ArticleRuby - Juego aleatorio
puts "Bienvenido al juego del numero que nunca adivinaras wajajajaja" puts "Es un numero entre 1 y 20 que nunca adivinaras!! Te dare 5 oportunidades" puts "Escribe un numero!" numero_secreto = rand ...
View ArticleRuby - Simple Authentication Checker
def check_authentication unless session[:admin] session[:intended_action] = action_name session[:intended_controller] = controller_name redirect_to :action => "signin" end ...
View ArticleRuby - Regular Expression to Parse Ruby Log Messages
# parse ruby log message # customize as needed LOG_EXPRESSION = /([\w]+),\s+\[([^\]\s]+)\s+#([^\]]+)]\s+(\w+)\s+--\s+(\w+)?:\s+(.+)/ # sample log output from this call: # logger.info("Ubiquitously ...
View ArticleRuby - Create a Todo in Things
require "rubygems" require "appscript" include Appscript @things = app("Things") @todos = @things.to_dos def create_to_do(name,source,link) unless @todos[its.name.eq(name)].get.length > 0 ...
View ArticleRuby - Putting data on the clipboard in OS X
IO.popen('pbcopy', 'w').print "Text to go on clipboard ...
View ArticleRuby - preguntas para mejorar tu calidad de vida
puts "escribe tu nombre aquÃ:" nombre = gets.chomp puts "tu nombre es #{nombre}" puts "escribe si eres mayor o menor de edad aqui:" edad = gets.chomp puts "eres #{edad}" puts " ...
View ArticleRuby - Problem 5
#!/usr/bin/ruby require 'mathn' i = 2520 q = i j = Prime.new flag = 0 while(flag == 0) do for k in 1..20 if(q % k == 0) flag = 1 else j = j.next q = i*j ...
View ArticleRuby - read id3 v1 information from mp3
#!/usr/bin/env ruby #This script retrive i3V1 information from an mp3 file #it's a proof of concept so don't use it in productions #let's read the file f = File.open(ARGV.first, 'rb'); #we need ...
View Article