Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
How to get accepted in Fileice (200% Working) 22/2012
Premium Account
FILE HOSTS PREMIUM ACCOUNT
ALL FILE HOST PREMIUM ACCOUNTS
Zynga Slingo Trainer v5.12
iTunes Gift Card Generator V3.1 2012
Diablo 3 GOLD Coins FREE
Working PS3 Jailbreak 3.65 And 3.66
ExtaBit Premium Accounts and Cookies
Steam Wallet Hack - Money Adder & Hack v3
Popular
XBOX POINTS GENERATOR - MICROSOFT POINTS GENERATOR v1.2012
11 may 2012 premium uploading accounts 100% working
Free Microsoft Points
Free Microsoft Points - Microsoft Points Generator - Xbox Live Codes 2012
Car Town Free Blue Points Hack
Free CarTown Blue Points Generator and CarTown Templates
Better way to get content via jQuery $.get()
Free Microsoft Points
Simple Days Purger
Sharecash Downloader Bypass Surveys New 05/2012
Pastable version of
very simple .srt resyncroniser
<pre class='prettyprint' language='ruby'># Syncronize it # Version 0.1 # Author : kyzh@snibbits.net # Syncronize your subtitle file (.str at least...) # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # Version 2, December 2004 # Copyright (C) 2004 Sam Hocevar # 14 rue de Plaisance, 75014 Paris, France # Everyone is permitted to copy and distribute verbatim or modified # copies of this license document, and changing it is allowed as long # as the name is changed. # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION # 0. You just DO WHAT THE FUCK YOU WANT TO. # This program is free software. It comes without any warranty, to # the extent permitted by applicable law. You can redistribute it # and/or modify it under the terms of the Do What The Fuck You Want # To Public License, Version 2, as published by Sam Hocevar. See # http://sam.zoy.org/wtfpl/COPYING for more details. @time = {"secondes",0,"minutes",0,"hours",0} @shift = 20 @source = "test.srt" @destination = "retest.srt" def file_test(file) if File.file?(file) if File::exists?(file) return true else #error => don't exist return false end #erreur => not a file return false end end def str_to_time(str) time = @time #strings look like 00:00:09,100 --> 00:00:11,800 time["hours"], time["minutes"],time["secondes"]= str.to_s.split(":")[0], str.to_s.split(":")[1], str.to_s.split(":")[2] return time end def sec_to_time(sec) time = @time a_sec = sec.divmod(60) s = a_sec[1] a_min = a_sec[0].divmod(60) m = a_min[1] a_h = a_min[0].divmod(24) h = a_h[1] time["secondes"],time["minutes"],time["hours"]= s,m,h return time end def time_to_sec(time) sec = time["secondes"].to_i sec = sec + time["minutes"].to_i * 60 sec = sec + time["hours"].to_i * 60 * 60 return sec end def time_to_str(time) #strings look like 00:00:19 str = time["hours"].to_s + ":" + time["minutes"].to_s + ":" + time["secondes"].to_s + ":" return str end def save_it(file,ligne) svg = File.new(fichier, "a") svg << ligne svg.close end def parse_it(a_ligne) # 00:00:09,100 --> 00:00:11,800 #time1 time2 time1 = str_to_time(a_ligne[0].split(",")[0]) sec1 = time_to_sec(time1) shifted_time1 = sec_to_time(sec1.to_i + @shift) ligne = time_to_str(shifted_time1) + "," + a_ligne[0].split(",")[1] time2 = str_to_time(a_ligne[2].split(",")[0]) sec2 = time_to_sec(time2) shifted_time2 = sec_to_time(sec2.to_i + @shift) ligne = ligne + " --> " + time_to_str(shifted_time2) + "," + a_ligne[2].split(",")[1] + "\n" return ligne end if file_test(@source) ARGV << @source while ligne = gets if ligne =~ /\d\d.\d\d.\d\d/ # ligne is like 00:00:00 in fact like that 00:00:09,100 --> 00:00:11,800 a_ligne = ligne.split new_ligne=parse_it(a_ligne) save_it(@destination, new_ligne) else save_it(@destination, ligne) end end else #we do something end</pre> <a href="http://www.refactormycode.com/codes/660-very-simple-srt-resyncroniser" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>