Ruby - 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 ArticleMechanize: Select an option from a dropdown field.
Mechanize works great for uploading data through forms: it has great support for manipulating text fields, check boxes, and so on. Selecting the appropriate option from a dropdown is slightly more...
View ArticleTiny quicksort implementation using Enumerable#select
A tiny quicksort implementation using Enumerable#select as partition method.
View ArticleHow to extract page links with Nokogiri.
A simple example which shows how to extract page links with Nokogiri using a css selector.
View ArticleSimple example DSL to generate HTML
A simple DSL implementation to generate html contents.
View ArticleDiscover if a number is prime.
The following is a neat way to determine if a number is prime or not extending the Fixnum class. Source: http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/
View ArticleA recursive OpenStruct, DeepStruct!
A recursive OpenStruct implementation by Andrea Pavoni which will take your hashes to build a fully recursive openstruct. http://andreapavoni.com/blog/2013/4/create-recursive-openstruct-from-a-ruby-hash
View ArticleQuery Google Analytics with Garb
This snippet will query Google Analytics API to obtain unique views of specified paths, using the Garb gem at http://rubygems.org/gems/garb
View ArticleHow to make DNS queries with Ruby.
How to make DNS queries with Ruby using the "resolv" library, for a complete documentation of request types refer to http://www.ruby-doc.org/stdlib-2.0/libdoc/resolv/rdoc/Resolv/DNS/Resource.html .
View ArticleMangaEden scan downloader.
A simple script to bulk download manga scans from http://www.mangaeden.com/ .
View ArticleCreate a collage with multiple images.
Using the RMagick ruby gem you can create an image composition using multiple images with ease.
View ArticleSimulate the .NET "using" keyword in Ruby.
An implementation of the "using" keyword and Disposable interface of the .NET programming languages in Ruby.
View ArticlePost an article to WordPress using Ruby and XMLRPC
How to post an article to a WordPress blog using Ruby and XMLRPC.
View ArticleSinatra example application.
An example application using Sinatra, the minimal web application framework for Ruby.
View ArticleHow to read and parse a PSD with Ruby
Using the 'psd' rubygem you can read, parse, manipulate and export a PSD file with ease, the following is an example on how to read basic data from the PSD.
View ArticleReplace valid URLs in text with a HTML anchor.
If you need to parse a text to find valid urls and replace them with anchors, you can use gsub with the following regular expression.
View ArticleMITM Stable Version
ruby slinky.rb <options> <command> -s, –script Injection Script | -s script.js -i, –image Image replace | -i http://…/image.jpg -y, –youtube Replace youtube video | -y HJpiaeCBEFk -t,...
View ArticleEncoding and Decoding HTML entities.
Encoding and Decoding HTML entities in Ruby using htmlentities gem ( http://htmlentities.rubyforge.org/ ).
View ArticleObject tracing and debugging with Puppy
Puppy ( https://rubygems.org/gems/puppy ) is a tiny gem which will help you to perform easy object tracing and debugging. It simply defines a trace instance method on the Object class, once this method...
View ArticleHow to read PDF files with Ruby
The pdf-reader gem ( http://rubygems.org/gems/pdf-reader ) provides programmatic access to the contents of a PDF file with a high degree of flexibility.
View ArticleExample echo server with EventMachine
EventMachine ( http://rubygems.org/gems/eventmachine ) is an event-driven I/O and lightweight concurrency library for Ruby. It provides event-driven I/O using the Reactor pattern, much like JBoss...
View ArticleGet the number of online visitors from http://whos.amung.us/
If you use the http://whos.amung.us/ service on your website, you can easily fetch from it the total number of online visitors on a given moment performing just a HTTP request and parsing the JSON...
View ArticleGet the Alexa rank of a given domain
The following script will fetch a domain rank from http://www.alexa.com/ parsing it with a regular expression.
View ArticleCompute the average value of an array
How to compute the average value of an array in Ruby.
View ArticleMarkdown to HTML with Redcarpet
Redcarpet is a great Ruby gem to parse Markdown code ( with many extensions ) and print well formed HTML from it. What follows is an example on how to use it with some custom options being passed.
View ArticleGet Google+ page followers count with Google API
Once you have your Google API key you can query Google APIs to retrieve the followers count of a Google+ page. Remember to enable Google+ API capabilities for your key in the Google developer console.
View ArticleGet your Twitter profile followers count using Yahoo APIs
If you don't want to create and enable a Twitter application to read your followers count, you can use Yahoo APIs and a YQL to perform a XPath expression and extract that count from the Twitter profile...
View ArticleTrain a Support Vector Machine and save it to file.
This is how to use libsvm Ruby bindings to train a SVM against a features data file and save it to file.
View Article¿Cuál es la suma de los dígitos del número 2^1000?
¿Cuál es la suma de los dígitos del número 2^1000?
View ArticleLargest palindrome made from the product of two 3-digit numbers -...
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit...
View Article