Skip to content

Instantly share code, notes, and snippets.

View ravicious's full-sized avatar

Rafał Cieślak ravicious

View GitHub Profile
=begin
By Ravicious aka Torian (ID 386)
http://ravsite.net/
Umieść swój ASCII art w pliku "ascii.txt" w tym samym folderze, co skrypt. Następnie odpal skrypt i otwórz ponownie plik, a później możesz to wkleić do swojego profilu ;)
Thanks for:
- Robert Evans
http://www.megasolutions.net/ruby/search-a-file-and-replace-text-50116.aspx
- Hipekhop
require 'rexml/document'
xml = REXML::Document.new(File.open("list.xml"))
quantity = 0
xml.elements.each("//item") { quantity += 1 }
puts quantity
require 'rexml/document'
xml = REXML::Document.new(File.open("list.xml"))
gg_numbers = Array.new
gg_nicknames = Array.new
gg_list = Array.new
file = "list.txt"
# dodaję do tablicy kolejne JID-y
xml.elements.each("//item") { |element| gg_numbers.push(element.attributes["jid"]) }
irb(main):002:0> require 'date'
=> true
irb(main):003:0> d = Date.new(2008, 12, 22)
=> #<Date: 4909645/2,0,2299161>
irb(main):004:0> d1 = Date.new(1993, 9, 28)
=> #<Date: 4898517/2,0,2299161>
irb(main):005:0> d - d1
=> Rational(5564, 1)
irb(main):006:0>
irb -r roznicadat.rb
irb(main):001:0> d1 = "28-09-1993"
=> "28-09-1993"
irb(main):002:0> Scan(d1)
Poprawna data
=> nil
irb(main):003:0> d1 = "2809-1993"
=> "2809-1993"
irb(main):004:0> Scan(d1)
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS D->- s+: a--- C++>++ U P> L+>+ E--->--- W+++ N o() K- w o-- M- V-
PS PE Y PGP- t 5 X+ R() tv() b+>+ DI+(+) D+ G> e->- h!>! !y+
------END GEEK CODE BLOCK------
require 'date'
def Scan(text)
case text
when /^([0-9]{1,2})[-\.]([0-9]{1,2})[-\.]([0-9]{4})/
puts "Poprawna data"
else
puts "Niepoprawna data, sprobuj jeszcze raz"
end
end
@ravicious
ravicious / gist:42826
Created January 3, 2009 11:21
Skrypt Klisia [ http://klisiu.pl/blog/hello-php/ ] napisany w Ruby
require 'date'
require 'parsedate'
def scan(text)
text =~ /^([0-9]{1,2})[-\.]([0-9]{1,2})[-\.]([0-9]{4})/
end
d1 = ''
d2 = ''
Moby - Hotel
Thievery Corporation - The Richest Man in Babylon
The Kilimanjaro Darkjazz Ensemble - The Kilimanjaro Darkjazz Ensemble
Jimi Hendrix - The Ultimate Experience
75 ,77 ,120 ,220 ,237 ,335 ,337 ,350 ,
371 ,603 ,618 ,621 ,1326 ,1333 ,1360 ,1538 ,
1618 ,1800 ,1803 ,1913 ,1914 ,2042 ,2059 ,2096 ,
2123 ,2184 ,2188 ,2233 ,2234 ,2235 ,2236 ,2237 ,
2243 ,2244 ,2245 ,2246 ,2247 ,2254 ,2269 ,2271 ,
2328 ,2337 ,2338 ,2339 ,2340 ,2341 ,2357 ,2358 ,
2373 ,2374 ,2375 ,2376 ,2377 ,2406 ,2407 ,2425 ,
2429 ,2448 ,2449 ,2450 ,2452 ,2453 ,2549 ,2551 ,
2558 ,2572 ,2611 ,2629 ,2634 ,2648 ,2651 ,2652 ,
2654 ,2664 ,2670 ,2674 ,2684 ,2688 ,2695 ,2704 ,