Skip to content

Instantly share code, notes, and snippets.

View FerPerales's full-sized avatar
🎯
Focusing

Fernando Perales FerPerales

🎯
Focusing
View GitHub Profile
@FerPerales
FerPerales / gist:3884860
Created October 13, 2012 14:42
Mutable strings
s = "Hello "
s = s + "rubyCUCEI!" #New object "Hello rubyCUCEI!"
puts s
s = s.capitalize #New object "Hello rubycucei!"
puts s
r = "Hello "
r += "rubyCUCEI!" #New object "Hello rubyCUCEI!"
puts r
r.capitalize! #Same object "Hello rubycucei"
puts r
@FerPerales
FerPerales / gist:3921738
Created October 20, 2012 02:22
String as array
s = "OMG!"
puts s[2]
#Ruby 1.8 displays 71; Ruby 1.9 displays G
@FerPerales
FerPerales / gist:3921743
Created October 20, 2012 02:25
Workarroung Ruby 1.8
s = "OMG!"
puts s[2,1]
#Ruby 1.8 now displays G
@FerPerales
FerPerales / gist:3921755
Created October 20, 2012 02:33
Workarround Ruby 1.9
s = "OMG!"
puts s[2].ord
#Ruby 1.9 now displays 71
@FerPerales
FerPerales / gist:3921787
Created October 20, 2012 02:46
More than one at a time
s = "Hello rubyCUCEI!"
puts s[6,4] # prints "ruby"
@FerPerales
FerPerales / gist:4275391
Created December 13, 2012 09:54
Knowledge database
<!-- Actually, a pseudo-XML format-->
<bc>
<regla> <condicion> <atomo> COMPRO_ARMA </atomo> </condicion> <conclusion> <atomo>GUERRERO_1 </atomo> <atomo>COMERCIANTE_1</atomo> <conjuncion/></conclusion></regla>
<regla> <condicion> <atomo> COMPRO_ITEM </atomo> </condicion> <conclusion> <atomo>MANIPULADOR_1</atomo> <atomo>COMERCIANTE_1</atomo> <conjuncion/></conclusion> </regla>
<regla> <condicion> <atomo> MATO_TODOS_MANIQUIES </atomo> </condicion> <conclusion>GUERRERO_2 </conclusion> </regla>
<regla> <condicion> <atomo> USO_ANTORCHA </atomo> </condicion> <conclusion> MEDIADOR_1 </conclusion> </regla>
<regla> <condicion> <atomo> ADQUIRIO_ITEM </atomo> <atomo> ADQUIRIO_ESPADA </atomo> <conjuncion/> </condicion> <conclusion> GUERRERO_2</conclusion> </regla>
<regla> <condicion> <atomo> ADQUIRIO_ITEM </atomo> <atomo> ADQUIRIO_POCIMA </atomo> <conjuncion/> </condicion> <conclusion> MEDIADOR_1</conclusion> </regla>
<regla> <condicion> <atomo> ADQUIRIO_ITEM </atomo> <atomo> ADQUIRIO_BACULO </atomo> <conjuncion/> </cond
@FerPerales
FerPerales / factorial.rb
Last active December 11, 2015 18:19
Ejercicios RoRBootcamp día 1
def factorial(valor = 1)
acum = 1
(1..valor).each {|x| acum = acum * x}
return acum
end
/** El ejemplo de aqui muestra como cargar una ontologia
* cualquiera, ya sea de la Web o de una copia local.
*
* @throws OWLOntologyCreationException */
public void cargarOntologia() throws OWLOntologyCreationException
{
// Generar nuestro manejador de ontologias.
OWLOntologyManager manejador = OWLManager.createOWLOntologyManager();
// Primero probando a cargar una ontologia desde la Web
@FerPerales
FerPerales / input.txt
Last active December 13, 2015 16:39
Palindromes
68
oyncbgymhkrgfoosnxrlzmbxxdvyfclg
zqcolemtoatzmvypy
matebobomacbmmegcgbtu
ermcvdvpmyfmrumgywffaguyauuchqpuuhdayewfaq
ynhehazomiqkxqiajevzmxykvnjrxyttowrxakaymkwm
cteonyxcelmaohxgqpslmbzq
djfohodetjbngtfqxjrbjhxdvdngvnenqr
kmntddnpyognls
mjgvquobosirhpoeaqigczyerafadhiiqmkgfadudwlssdrns
<!-- Rename to 0-ntfs-3g-policy.xml.fdi -->
<?xml version="1.0" encoding="UTF-8"?>
<deviceinfo version="0.2">
<!-- mount ntfs volume with the ntfs-3g driver to enable write support -->
<device>
<match key="volume.fstype" string="ntfs">
<merge key="volume.fstype" type="string">ntfs-3g</merge>
<merge key="volume.policy.mount_filesystem" type="string">ntfs-3g</merge>
<append key="volume.mount.valid_options" type="strlist">locale=</append>