Skip to content

Instantly share code, notes, and snippets.

*Programa que genera un arreglo con tamaño aleatorio de enteros aleatorios
e imprime un histograma de frecuencias
*/
package ejercicios;
//clase de java para generar números aleatorios:
import java.util.Random;
//sirve para representar colecciones tabulares
import java.util.HashMap;
//contiene distintas utilidades para colecciones
@lfborjas
lfborjas / Histograma.java
Created October 5, 2010 22:38
Ejemplos para la clase del 06 de Octubre de 2010
/**Programa que genera un arreglo con tamaño aleatorio de enteros aleatorios
e imprime un histograma de frecuencias
*/
package ejercicios;
//clase de java para generar números aleatorios:
import java.util.Random;
//sirve para representar colecciones tabulares
import java.util.HashMap;
//contiene distintas utilidades para colecciones
cd CARPETA_X
git init
git remote add origin git://github.com/progra4/ejemplos.git
git pull origin master
package ejercicios;
import java.util.Random;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map.Entry;
public class RandWords{
private static String genPalabra(){
@lfborjas
lfborjas / sacrilege.rb
Created October 14, 2010 02:09
An interpreter for one-liner java expressions. Useful for testing stuff without writing mains; based on beanshell
#based on jruby
require "java"
#copied the beanshell jar because jruby can't seem to be aware of the classpath
require "./bsh-2.0b4.jar"
#cf. http://bogojoker.com/readline/
require 'readline'
#based on this: http://blogs.sun.com/coolstuff/entry/using_java_classes_in_jruby
include_class Java::bsh.Interpreter
@lfborjas
lfborjas / Cuaderno.java
Created October 14, 2010 03:17
La clase cuaderno, creada para progra 2 el 13 de octubre de 2010
package laboratorio2;
import java.util.HashMap;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Map.Entry;
public class Cuaderno{
private int noPaginas;
package ejercicios;
import java.util.ArrayList;
import java.util.Random;
import java.util.Arrays;
public class Conjuntos{
private static ArrayList<String> union(ArrayList<String> primero, ArrayList<String> segundo){
ArrayList<String> retVal = new ArrayList<String>(primero);
for(String worte: segundo){
if(!primero.contains(worte))
import java.util.*;
public class agenda{
public static void main(String[] args){
HashMap<Character, ArrayList<String>> agenda = new HashMap<Character, ArrayList<String>>();
for(Character c='A'; c<='Z';c++){
agenda.put(c, new ArrayList<String>());
}
String nombre1= "Alejandro";
String nombre2= "Zaida";
@lfborjas
lfborjas / forkitall.markdown
Created October 18, 2010 06:14
Una breve descripción del modelo fork+pull

Para colaborar en un repositorio mediante el modelo fork+pull (se presupone que ya tenés instalado git )

  1. Hacer fork en github.com
  2. Te vas a tu fork
  3. En tu compu, ejecutás git clone git@github.com:YamilG/lfborjas.github.com.git
  4. Te creará una carpeta llamada lfborjas.github.com, hacés cd a ella y comenzás a hacer tus cambios
  5. Cuando querás ver qué has cambiado, hacés git status y para cambios específicos, git diff
  6. Cuando estés listo para hacer un snapshot de tus cambios, agregarlos al historial git, hacés un git commit -am "mensaje descriptivo", el switch -am es un atajo para agregar todos los archivos que git ya conocía; si agregás otros archivos, tendrás que hacer git add archivo.ext otroArchivo.ext antes de hacer un commit.
  7. Cuando terminés de hacer commits y estés listo para que integremos cambios, hacés un git push origin master y luego me mandás una [pull request](http://help.github.com/pull-reque
@lfborjas
lfborjas / session_counter.rb
Created October 20, 2010 02:00
A simple script to decode sinatra sessions and tamper them
require 'sinatra'
enable :sessions
#cf: http://rack.rubyforge.org/doc/Rack/Session/Cookie.html
class Visits
@@global = 0
def self.global; @@global; end
def self.add
@@global +=1
end