Created
December 5, 2008 18:09
-
-
Save ivyl/32427 to your computer and use it in GitHub Desktop.
Some useful stuff.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'uri' | |
#set those varibles to your personal info | |
pesel = XXXXXXXXXX | |
imie = 'John' | |
nazwisko = 'Doe' | |
wait = 3600 #seconds | |
#do you need loop? other option is to run it manualy | |
loop do | |
res = Net::HTTP.post_form(URI.parse('http://www.kierowca.pwpw.pl/PJAction.do'), | |
{'pesel' => pesel.to_s, | |
'imie' => imie.upcase, | |
'nazwisko' => nazwisko.upcase}) | |
#use %x[notify-send, knotify, etc] puts or other suitable output metod | |
out = res.body.match(/<div id="result">(.*?)<\/div>/m)[1].scan(/>(.*?)</).map{|x|x.first} | |
`notify-send "#{out[0,2].join}" "#{out.last}"` #nice formating, you can use out.join instead | |
sleep wait | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#extracts all images encoded with base 64 form eml files (mail) | |
#example: ./eml2img.rb OSM.eml => skanuj0014.jpg saved | |
require 'base64' | |
REGEXP = /Content-Type: image\/\w+; name="(.+?)"\nContent-Transfer-Encoding: base64.+?\n\n(.*?)\n\n/m | |
File.read(ARGV[0]).scan(REGEXP).each do |element| | |
File.open(element.first, 'w') {|f| f.write Base64::decode64(element.last)} | |
puts element.first + ' saved' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#generates password, example: ./passgen.rb 5 => f3uv5 | |
puts (1..ARGV[0]).map{(rand(2) == 0 ? (rand(25)+97).chr : rand(10).to_s)}.join |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#by Teamon | |
require 'iconv' | |
class String | |
def to_p | |
Iconv.iconv('ascii//translit//IGNORE', 'utf-8', self).first.gsub("'", '').gsub(/[^a-zA-Z0-9-]+/, '-').gsub(/^-/, '').gsub(/-$/, '') | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#by Ivyl | |
def usage | |
puts "This program converts Winamp's playlist to extended m3u readable by Exaile." | |
puts "Usage: ./#{__FILE__} winamp.playlist exaile.playlist /prefix/to/windows/partition" | |
Kernel.exit(0) | |
end | |
usage unless ARGV.size == 3 | |
winamp = File.read(ARGV[0]) | |
exaile = "#EXTM3U\n" | |
usage unless winamp =~ /^\[playlist\]/ | |
data = [] | |
winamp.each_line do |line| | |
match=line.match(/^(File|Title|Length)(\d+)=(.*?)\s+$/) | |
if match | |
type, index, info = match[1..3] | |
data[index.to_i] = {type.to_sym => info}.merge(data[index.to_i]||{}) | |
end | |
end | |
data.each do |hash| | |
next unless hash | |
exaile << "#EXTINF:#{hash[:Length]}," << hash[:Title].split(/\s*-\s*/).last << "\n" | |
exaile << ARGV[2] | |
exaile << "/" unless ARGV[2][-1] == 47 | |
exaile << hash[:File].split(/\\/)[1..-1].join('/') << "\n" | |
end | |
File.open(ARGV[1], 'w'){|f| f.puts exaile} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment