Quantcast
Channel: EmotiCODE - Snippets and Source Code Search Engine
Browsing latest articles
Browse All 146 View Live

Ruby - Putting data on the clipboard in OS X

IO.popen('pbcopy', 'w').print "Text to go on clipboard ...

View Article



Ruby - 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 Article

Ruby - 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 Article

Ruby - 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

Ruby - find a value in a grid

how to find the value's coordinate in a grid in ruby

View Article


Mechanize: 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 Article

Tiny quicksort implementation using Enumerable#select

A tiny quicksort implementation using Enumerable#select as partition method.

View Article

How to extract page links with Nokogiri.

A simple example which shows how to extract page links with Nokogiri using a css selector.

View Article


Simple example DSL to generate HTML

A simple DSL implementation to generate html contents.

View Article


Funny Maths

Funny Maths

View Article

Discover 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 Article

File Write and Read

Enjoy

View Article

A 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 Article


Query 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 Article

How 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 Article


FTP BruteForce

https://github.com/crashover32/FTPBruteForce

View Article

MangaEden scan downloader.

A simple script to bulk download manga scans from http://www.mangaeden.com/ .

View Article


Create a collage with multiple images.

Using the RMagick ruby gem you can create an image composition using multiple images with ease.

View Article

Simulate the .NET "using" keyword in Ruby.

An implementation of the "using" keyword and Disposable interface of the .NET programming languages in Ruby.

View Article

Post an article to WordPress using Ruby and XMLRPC

How to post an article to a WordPress blog using Ruby and XMLRPC.

View Article

Sinatra example application.

An example application using Sinatra, the minimal web application framework for Ruby.

View Article


Add method to

Add method to

View Article


Convert to base

Convert to base

View Article

Ruby base conversion

Ruby base conversion

View Article

Add Method to Array

i love coffee

View Article


How 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 Article

Yield Example

Yield Example

View Article

Ruby compare class

Ruby compare class

View Article

Singleton Example

Singleton Example

View Article



Replace 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 Article

MITM 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 Article

Encoding and Decoding HTML entities.

Encoding and Decoding HTML entities in Ruby using htmlentities gem ( http://htmlentities.rubyforge.org/ ).

View Article

PStore Example

PStore Example

View Article


CGI With Ruby Example

CGI With Ruby Example

View Article

Object 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 Article

How 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 Article


Example 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 Article


Get 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 Article

Get 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 Article

Compute the average value of an array

How to compute the average value of an array in Ruby.

View Article

Marshal Example usage

Marshal Example usage

View Article


Markdown 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 Article

Get 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 Article


Get 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 Article

Train 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


Fibonacci's Series

Implementation of the Fibonacci's Series in Ruby

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 Article

Largest 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

Ruby multiple file upload

Ruby multiple file upload

View Article


Dynamic model

Dynamic model

View Article

Browsing latest articles
Browse All 146 View Live




Latest Images