RSS
Recortes: 7
Registrado: 9/8/2006
Web
rails (2)
jdbc (1)
ruby (1)
fechas (1)
lectura (1)
validación (1)
ficheros (1)
oracle (1)
validacion (1)
java (1)
php (1)
XMLHttpRequest (1)
javascript (1)
índices (1)
f = File.new("fichero.txt") array_lineas_de_fichero = f.readlines f.close #quitamos los saltos de linea en cada elemento del array, si nos interesa array_lineas_de_fichero.collect! {|x| x.strip}Tratamos todos los ficheros de un directorio de una extensión determinada
Dir.chdir(@dir) #@dir:: mi directorio de interés myfiles = File.join("**", "*.EXTENSION") # para cada fichero de extensión EXTENSION en todos los subdirectorios # si no nos interesasen los subdirectorios, eliminariamos "**" Dir.glob(myfiles) { |file| process_file file }Y el método anterior process_file podría ser:
def process_file (aFile) File.open(aFile){|ioF| counter=0 # ¿para contar las lineas? while (line = ioF.gets) # con esto leemos también cada linea y la podemos tratar... process_line line counter = counter + 1 end puts "-" + aFile + " --> " + counter.to_s + " lineas" } end
DECLARE CURSOR the_index IS SELECT index_name FROM all_indexes WHERE tablespace_name = '<tablespace_name>'; BEGIN FOR name IN the_index LOOP EXECUTE IMMEDIATE 'alter index '||name.index_name||' rebuild'; END LOOP; END;Los índices se duplican antes de ser sustituidos por los recien creados. Así que ojo con el espacio en los tablespaces.
<?php $tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y")); $lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); $nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1); echo date("M-d-Y",$tomorrow); echo date("M-d-Y",$lastmonth); echo date("M-d-Y",$nextyear); ?>
PreparedStatement ps=null; ResultSet rs=null; String sql="SELECT algo FROM algunsitio WHERE algo=?"; Connection c=null; try { Class.forName ("oracle.jdbc.OracleDriver"); c = DriverManager.getConnection("jdbc:oracle:thin:@maquina.dominio:1521:instancia", "usuario", "passwd"); ps = c.prepareStatement(sql); //parametros ps.setString(1, "p"); rs = ps.executeQuery(); while (rs.next()) { // dato = rs.getString(1); } }catch (SQLException se) { // excepcion !! se.printStackTrace(System.err); }finally { //ten en cuenta que esto puede lanzar SQLexception a su vez... if (rs!=null) rs.close(); if (ps!=null) ps.close(); if (c!=null) c.close(); }
function getHTTPObject() { var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/ if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp; } var http = getHTTPObject(); // We create the HTTP ObjectY para poder realizar la petición mediante POST es importante la siguiente linea de enconding:
http.open("POST", url, true); http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1'); http.onreadystatechange = handleHttpResponse;Siendo "handleHttpResponse" la función que queramos que trate la respuesta.
function handleHttpResponse() { if (http.readyState == 4) { results = http.responseText; //tratar la respuesta contenida en results. } }
validates_length_of :campo, :within => 1..150
validates_format_of :campo_url, :with => /(http):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/