elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


  Mostrar Mensajes
Páginas: 1 [2] 3 4 5 6 7
11  Sistemas Operativos / GNU/Linux / [Debian Wheezy] Error con repo updates en: 17 Julio 2013, 21:59 pm
Hola. Últimamente, he tenido inconvenientes al actualizar los repos de mi Debian Wheezy 7.1. Aquí les dejo lo que bota la consola y mi sources.list

  • Sources:
Código:
# Repositorios Oficiales
deb http://ftp.debian.org/debian/ wheezy main contrib non-free
deb-src http://ftp.debian.org/debian/ wheezy main contrib non-free
#Repositorios Seguridad
deb http://security.debian.org/ wheezy/updates main contrib non-free
deb-src http://ftp.debian.org/debian/ wheezy/updates main contrib non-free
# wheezy-updates
deb http://ftp.debian.org/debian/ wheezy-updates main contrib non-free
deb-src http://ftp.debian.org/debian/ wheezy-updates main contrib non-free
# Repositorios Backports
deb http://mirrors.kernel.org/debian/ wheezy-backports main contrib non-free
deb-src http://mirrors.kernel.org/debian/ wheezy-backports main contrib non-free
deb http://ftp.debian.org/debian/ wheezy-backports main

  • Terminal:
Código:
Obj http://security.debian.org wheezy/updates Release.gpg                      
Obj http://mirrors.kernel.org wheezy-backports Release.gpg                     
Obj http://ftp.debian.org wheezy Release.gpg           
Obj http://security.debian.org wheezy/updates Release                         
Obj http://mirrors.kernel.org wheezy-backports Release                         
Ign http://ftp.debian.org wheezy/updates Release.gpg                         
Obj http://security.debian.org wheezy/updates/main i386 Packages               
Obj http://mirrors.kernel.org wheezy-backports/main Sources                   
Obj http://ftp.debian.org wheezy-updates Release.gpg   
Obj http://security.debian.org wheezy/updates/contrib i386 Packages           
Obj http://mirrors.kernel.org wheezy-backports/contrib Sources                 
Obj http://ftp.debian.org wheezy-backports Release.gpg
Obj http://security.debian.org wheezy/updates/non-free i386 Packages           
Obj http://mirrors.kernel.org wheezy-backports/non-free Sources               
Obj http://ftp.debian.org wheezy Release               
Obj http://security.debian.org wheezy/updates/contrib Translation-en           
Obj http://mirrors.kernel.org wheezy-backports/main i386 Packages             
Ign http://ftp.debian.org wheezy/updates Release       
Obj http://security.debian.org wheezy/updates/main Translation-en             
Obj http://ftp.debian.org wheezy-updates Release                               
Obj http://security.debian.org wheezy/updates/non-free Translation-en         
Obj http://ftp.debian.org wheezy-backports Release                             
Obj http://mirrors.kernel.org wheezy-backports/contrib i386 Packages         
Obj http://mirrors.kernel.org wheezy-backports/non-free i386 Packages         
Obj http://mirrors.kernel.org wheezy-backports/contrib Translation-en
Obj http://ftp.debian.org wheezy/main Sources         
Obj http://mirrors.kernel.org wheezy-backports/main Translation-en         
Obj http://mirrors.kernel.org wheezy-backports/non-free Translation-en     
Obj http://ftp.debian.org wheezy/contrib Sources       
Obj http://ftp.debian.org wheezy/non-free Sources
Obj http://ftp.debian.org wheezy/main i386 Packages
Obj http://ftp.debian.org wheezy/contrib i386 Packages
Obj http://ftp.debian.org wheezy/non-free i386 Packages
Obj http://ftp.debian.org wheezy/contrib Translation-en
Obj http://ftp.debian.org wheezy/main Translation-es
Obj http://ftp.debian.org wheezy/main Translation-en
Obj http://ftp.debian.org wheezy/non-free Translation-en
Obj http://ftp.debian.org wheezy-updates/main Sources
Obj http://ftp.debian.org wheezy-updates/contrib Sources
Obj http://ftp.debian.org wheezy-updates/non-free Sources
Obj http://ftp.debian.org wheezy-updates/main i386 Packages
Obj http://ftp.debian.org wheezy-updates/contrib i386 Packages
Obj http://ftp.debian.org wheezy-updates/non-free i386 Packages
Obj http://ftp.debian.org wheezy-updates/contrib Translation-en
Obj http://ftp.debian.org wheezy-updates/main Translation-en
Obj http://ftp.debian.org wheezy-updates/non-free Translation-en
Obj http://ftp.debian.org wheezy-backports/main i386 Packages
Obj http://ftp.debian.org wheezy-backports/main Translation-en
[b]Err http://ftp.debian.org wheezy/updates/main Sources
  404  Not Found [IP: 130.89.148.12 80]
Err http://ftp.debian.org wheezy/updates/contrib Sources
  404  Not Found [IP: 130.89.148.12 80]
Err http://ftp.debian.org wheezy/updates/non-free Sources
  404  Not Found [IP: 130.89.148.12 80]
W: Imposible obtener http://ftp.debian.org/debian/dists/wheezy/updates/main/source/Sources  404  Not Found [IP: 130.89.148.12 80]

W: Imposible obtener http://ftp.debian.org/debian/dists/wheezy/updates/contrib/source/Sources  404  Not Found [IP: 130.89.148.12 80]

W: Imposible obtener http://ftp.debian.org/debian/dists/wheezy/updates/non-free/source/Sources  404  Not Found [IP: 130.89.148.12 80]

E: Some index files failed to download. They have been ignored, or old ones used instead.[/b]


Gracias de antemano. Un saludo.
12  Programación / Ejercicios / Re: ayuda en: 29 Junio 2013, 23:36 pm
Está claro, que el espacio en blanco no le compila en ensamblador.

 ;D
13  Programación / Ejercicios / Re: ayuda en: 29 Junio 2013, 23:09 pm
¿? ¿Cuál es tu problema?
14  Sistemas Operativos / GNU/Linux / BackTrack 5r3 dual boot with Windows 8 en: 29 Junio 2013, 23:02 pm
Pues ésa es mi duda. La cosa es que tengo bastante info en W8 y no tengo un hdd externo para poder salvarla, en caso BT5 joda el grub como leí por allí..

Si se preguntan por qué coño no lo instalo en una VM, pues la razón es sencilla. Tengo 2GB de ram (core i3) y me corre como el culo  ;D

¿Alguien ya lo ha intentado?


Saludos.
15  Programación / Ejercicios / Re: Ejercicios en JAVA en: 28 Junio 2013, 17:37 pm
deseo los    ejercicios con metodos java porfitas uno de ellos es :
Escriba una aplicación que permita convertir 150 centímetros a pies y pulgadas.
Una pulgada = 2.54 centímetros.


¿Por qué no simplemente razonas? Estoy seguro que un algoritmo tan sencillo se desarrolla simplemente pensando 2 minutos..
16  Programación / Java / Re: [principiante] Loteria en: 28 Junio 2013, 01:47 am
En tu código hay un bug. ¿Que pasaría si se ingresara por error una letra o caracter? Terminaría en una expeción tipo InputMismatchException. Para evitar esto, pediríamos el ingreso del número de tickets y determinaríamos si es o no un número.

Código
  1. // Este metodo se encargará de avisarnos si lo ingresado es un número
  2. private static boolean isNumeric(String cadena){
  3.  try {
  4.    Integer.parseInt(cadena);
  5.    return true;
  6.  } catch (NumberFormatException nfe){
  7.    System.out.println("Ingrese solo numeros");
  8.    return false;
  9.   }
  10. }

Y lo llamaríamos al ingresar un valor:

Código
  1. boolean esNumero;
  2. do {
  3.  
  4. System.out.println("$$$$$$$ LOTTO $$$$$$$");
  5.                                        System.out.println("Hi, how many tickets would you like to buy?");
  6.                                        System.out.println(" [1] 1 Ticket");
  7.                                        System.out.println(" [2] 2 Tickets");
  8.                                        System.out.println(" [3] 3 Tickets");
  9.                                        System.out.println(" [4] 4 Tickets");
  10.                                        System.out.println(" [5] 5 Tickets");
  11.                                        System.out.println(" [0] In bankrupt - Nothing\n");
  12.                                        String choice2 = keyboard.next();
  13.                                        esNumero = isNumeric(choice2);
  14.                                        if (esNumero == true){
  15.                                         choice = Integer.parseInt(choice2);
  16.                                        }
  17.  
  18. } while(esNumero==false || choice<0 || choice>5);


Como ves, ingresamos choice como String. Luego llamamos al metodo isNumeric para determinar si es un número. Si es un número devuelve true, de lo contrario devuelve false a la variable Boolean esNumero. Si esNumero ahora es true, convertimos choice a entero. Al final, en el while, colocamos que se vuelva a ingresar choice, mientras que No sea un numero, o mientras se ingrese un valor menor a 0 o mayor a 5.

El método isNumeric tiene un catch en caso no se pueda convertir choice a entero (aquí ya sabemos que lo ingresado no es un número), que mostrará el mensaje "Ingrese solo números".

Otro problema que tienes, es que los números que generas pueden repetirse, por lo que si hay 43, 43 en los tickets y tu tienes 43, cuenta como 2 aciertos.

Para arreglar esto, una opción es crear un método que nos avise si el ticket actual ya ha sido sacado:

Código
  1. //determina si el valor de la bola ya ha sido sacado
  2. boolean numeroRepetido(int num, int[] numeros, int count)
  3. {
  4.  // num = bola, numeros = textfields de numeros, count = cuenta
  5.  for(int i=0; i<count; i++)
  6.  {
  7.    // si el numero q se ha sacado ya esta en algun textfield
  8.    if(numeros[i] == num)
  9.    {
  10.      return true; //devuelve true
  11.    }
  12.  }
  13.  return false;
  14. }

Y lo llamamos cada vez que generamos un ticket:

Código
  1. // genera los tickets
  2. void generar_tickets(int eleccion){
  3.  
  4. System.out.println("\nPrinting tickets...");
  5. System.out.println("----------------------");
  6.  
  7. tickets = new int[59];
  8. yourTickets = new int[eleccion];
  9.  
  10.  
  11. // Generate list of numbers
  12. for(int i = 0; i < tickets.length; i++) {
  13. int numero;
  14. do{
  15.   numero = 1+generateNumbers.nextInt(60);
  16. }while(numeroRepetido(numero,tickets,i));
  17. tickets[i] = numero;
  18. }
  19. }

Código
  1. // genera nuestros numeros
  2. void generar_mistickets(){
  3. // Give him his tickets
  4. System.out.print("\nThese are your tickets: \t");
  5. for (int i = 0; i < yourTickets.length; i++) {
  6. int numero;
  7. do{
  8. numero = 1+generateNumbers.nextInt(60);
  9. }while(numeroRepetido(numero,yourTickets,i));
  10. yourTickets[i] = numero;
  11. if(i != yourTickets.length-1){
  12. System.out.print(yourTickets[i] + ", ");
  13. }
  14. else
  15. System.out.print(yourTickets[i]);
  16. }
  17.  
  18. } // fin metodo

Como podrás ver, dentro de cada for hacemos un do - while cuando se crea un nuevo ticket. Y la condición es:

Código
  1. while(numeroRepetido(numero,tickets,contador));

Donde numero es el número que se ha generado actualmente, tickets es el arreglo de tickets (yourTickets y tickets), y contador es la cuenta de cuántos numeros se van sacando actualmente.

Código
  1. //determina si el valor del ticket ya ha sido sacado
  2. boolean numeroRepetido(int num, int[] numeros, int count)
  3. {
  4.  // num = ticket, numeros = arreglo de tickets, count = cuenta
  5.  for(int i=0; i<count; i++)
  6.  {
  7.    // si el numero q se ha sacado ya se ha sacado
  8.    if(numeros[i] == num)
  9.    {
  10.      return true; //devuelve true
  11.    }
  12.  }
  13.  return false;
  14. }

Por ejemplo, si recién vamos sacando 3 tickets (i = 2). El for del método quedaría:

Código
  1. for(int i=0; i<count; i++) {
  2.  // 0 < 2 &#243; 1 < 2 -> Si, entonces compara:
  3.  // si el numero q se ha sacado ya se ha sacado
  4.    if(numeros[i] == num)
  5.    {
  6.      return true; //devuelve true
  7.    }
  8.    else
  9.      return false;
  10.  }


Otra cosita es la cantidad de aciertos. Pueden haber más de 10 aciertos en tu código. Podemos hacer esto:

Código
  1. // Check if something matched
  2. for(int i = 0; i < yourTickets.length; i++) {
  3. for(int j = 0; j < tickets.length; j++) {
  4. if (yourTickets[i] == tickets[j]) {
  5. matched++;
  6. System.out.println(yourTickets[i]+ " = "+tickets[j]);
  7. }
  8. if(matched == 5){
  9. j=60;
  10. i=60;
  11.   }
  12.  
  13.  } // fin for interno
  14. } // fin for externo

Solamente se coloca un if (matched == 5). Cuando hayan 5 aciertos (que se suponen son lo máximo), i & j se les asigna 60 solo para romper los fors.

Espero hayas entendido este pedazo de código. Un saludo.

PD: Te dejo todo el code para que lo estudies cuando veas POO.

Código
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4. public class Loteria {
  5.  
  6. int choice;
  7. int[] tickets;
  8. int[] yourTickets;
  9. int matched=0;
  10. Scanner keyboard = new Scanner(System.in);
  11. Random generateNumbers = new Random();
  12.  
  13. public Loteria(){
  14. Jugar instance = new Jugar();
  15. instance.start();
  16. }
  17.  
  18. // genera los tickets
  19. void generar_tickets(int eleccion){
  20.  
  21. System.out.println("\nPrinting tickets...");
  22. System.out.println("----------------------");
  23.  
  24. tickets = new int[59];
  25. yourTickets = new int[eleccion];
  26.  
  27.  
  28. // Generate list of numbers
  29. for(int i = 0; i < tickets.length; i++) {
  30. int numero;
  31. do{
  32.   numero = 1+generateNumbers.nextInt(60);
  33. }while(numeroRepetido(numero,tickets,i));
  34. tickets[i] = numero;
  35. }
  36. }
  37.  
  38. // genera nuestros numeros
  39. void generar_mistickets(){
  40. // Give him his tickets
  41. System.out.print("\nThese are your tickets: \t");
  42. for (int i = 0; i < yourTickets.length; i++) {
  43. int numero;
  44. do{
  45. numero = 1+generateNumbers.nextInt(60);
  46. }while(numeroRepetido(numero,yourTickets,i));
  47. yourTickets[i] = numero;
  48. if(i != yourTickets.length-1){
  49. System.out.print(yourTickets[i] + ", ");
  50. }
  51. else
  52. System.out.print(yourTickets[i]);
  53. }
  54.  
  55. } // fin metodo
  56.  
  57.  
  58. //determina si el valor de la bola ya ha sido sacado
  59. boolean numeroRepetido(int num, int[] numeros, int count)
  60. {
  61.  // num = bola, numeros = textfields de numeros, count = cuenta
  62.  for(int i=0; i<count; i++)
  63.  {
  64.    // si el numero q se ha sacado ya esta en algun textfield
  65.    if(numeros[i] == num)
  66.    {
  67.      return true; //devuelve true
  68.    }
  69.  }
  70.  return false;
  71. }
  72.  
  73. // compara nuestros numeros con los tickets y aumenta los aciertos
  74. void comparar(){
  75.  
  76. System.out.println("\n\nLet's if you won something... \n");
  77.  
  78. // Check if something matched
  79. for(int i = 0; i < yourTickets.length; i++) {
  80. for(int j = 0; j < tickets.length; j++) {
  81. if (yourTickets[i] == tickets[j]) {
  82. matched++;
  83. System.out.println(yourTickets[i]+ " = "+tickets[j]);
  84. }
  85. if(matched == 5){
  86. j=60;
  87. i=60;
  88.   }
  89.  
  90.  } // fin for interno
  91. } // fin for externo
  92.  
  93. // Make a pause
  94. try {
  95. Thread.sleep(3000);
  96. } catch(InterruptedException e) {
  97. }
  98. System.out.println("Matchs:\t"+matched);
  99. switch (matched) {
  100. case 1:
  101. System.out.println("You won $100!");
  102. break;
  103.  
  104. case 2:
  105. System.out.println("You won $200!");
  106. break;
  107.  
  108. case 3:
  109. System.out.println("You won $500!");
  110. break;
  111.  
  112. case 4:
  113. System.out.println("You won $800!");
  114. break;
  115.  
  116. case 5:
  117. System.out.println("GREAT. You've got the pot: $1000!");
  118. break;
  119.  
  120. case 0:
  121. System.out.println("Have luck next time!");
  122. break;
  123.  
  124. }
  125.  
  126. } // fin metodo
  127.  
  128. // pregunta si se desea jugar denuevo
  129. boolean jugar_denuevo() {
  130.  
  131. // Ask if he wants to try again
  132. matched = 0;
  133. System.out.println("Would you like to try again? (X to exit) \t");
  134. String tryAgain = keyboard.nextLine();
  135.  
  136. if(tryAgain.compareToIgnoreCase("x") == 0) {
  137. System.out.println("Thank you. Bye");
  138. System.exit(0);
  139. return false;
  140. }
  141. else {
  142. // Just clear screen
  143. for (int l = 0; l < 5; l++) {
  144. System.out.println();
  145.  }
  146. return true;
  147.  
  148.  }
  149. }// fin metodo
  150.  
  151. // este metodo nos indica si lo ingresado es un numero
  152. private static boolean isNumeric(String cadena){
  153.  try {
  154.    Integer.parseInt(cadena);
  155.    return true;
  156.  } catch (NumberFormatException nfe){
  157.    System.out.println("Ingrese solo numeros");
  158.    return false;
  159.   }
  160. }
  161.  
  162. // clase que empieza el juego mediante thread
  163. private class Jugar extends Thread{
  164.  
  165. private boolean continuar=true; //condicion del thread
  166.  
  167.  
  168. public void run()  { // incia el thread
  169. while(continuar) { // hace la tarea mientras continuar sea true
  170. boolean esNumero;
  171. do {
  172.  
  173. System.out.println("$$$$$$$ LOTTO $$$$$$$");
  174.                                        System.out.println("Hi, how many tickets would you like to buy?");
  175.                                        System.out.println(" [1] 1 Ticket");
  176.                                        System.out.println(" [2] 2 Tickets");
  177.                                        System.out.println(" [3] 3 Tickets");
  178.                                        System.out.println(" [4] 4 Tickets");
  179.                                        System.out.println(" [5] 5 Tickets");
  180.                                        System.out.println(" [0] In bankrupt - Nothing\n");
  181.                                        String choice2 = keyboard.nextLine();
  182.                                        esNumero = isNumeric(choice2);
  183.                                        if (esNumero == true){
  184.                                         choice = Integer.parseInt(choice2);
  185.                                        }
  186.  
  187. } while(esNumero==false || choice<0 || choice>5);
  188.  
  189.                                        if (choice == 0) {
  190.                                        System.out.println("EXITING...");
  191.                                        System.exit(0);
  192.                                      }
  193.  
  194.                                       generar_tickets(choice);
  195.                                       generar_mistickets();
  196.                                       comparar();
  197.                                       continuar = jugar_denuevo();
  198.  
  199.  
  200. }
  201. }
  202. }
  203.  
  204.  
  205.                       public static void main(String[] args) {
  206.                        new Loteria();
  207.                       }
  208.                   } // fin.
  209.  
17  Seguridad Informática / Seguridad / Re: Ayuda con antivirus por favor en: 27 Junio 2013, 23:04 pm
¿Probaste pasando el AV en modo seguro?

Haz lo que te recomienda HdM.

Te recomiendo que utilices MalwareBytes Antimalware:

  • Descarga MalwareBytes Antimalware e instálalo.
  • Reinicia el equipo e inicia en modo seguro.
  • Abre el MalwareBytes y elige 'modo completo'.
  • Dale a analizar y espera que termine.
  • Asegúrate que todos los virus estén marcados.
  • Eliminar seleccionados (algunas veces pide reiniciar).


Saludos.
18  Programación / Programación General / Re: Ayuda / Guia para un buen programador en: 27 Junio 2013, 22:54 pm
Yo son fan de recomendar primero, desarrollar una buena lógica a base de algoritmos. Ahora, hablando de lenguajes para empezar te recomendaría Python. Es el lenguaje más fácil de aprender. Transforma tus algoritmos a código Python para ir ganando cancha.

Luego ya depende de lo que quieras hacer. Si lo que deseas es programar webs, PHP, Ruby, Python (tienes una ligera ventaja ;)),Perl, etc.
Si lo que deseas es programar aplicaciones de escritorio, pues te recomiendo aprender Java y C#. Si vamos por el torno empresarial, C++ es la mejor opción.

Como te repito, todo es cuestión de lo que quieres hacer. Pero mientras más lenguajes se pueda aprender, mucho mejor. Poco a poco..


Saludos.
19  Programación / Java / Re: [principiante] Loteria en: 27 Junio 2013, 22:32 pm
Claro, es importante una buena praxis. La identación es muy importante en un código ya que lo hace más legible. Pero la identación la coloca automáticamente el IDE. ¿Qué IDE usas? ¿O usas un editor de texto común?

No es necesario comentar solo con funciones. Simplemente, cuando haya un pedazo de código que creas conveniente comentar, simplemente coméntalo. Cuando recién empecé, no comentaba mis algoritmos, y a las 3 semanas no sabía ni qué había hecho. Comentar el código es muy importante.

Saludos.
20  Programación / Java / Re: [principiante] Loteria en: 27 Junio 2013, 22:07 pm
Para mí its okay, yo comento mucho más mis códigos (creo que es una manía mía jeje) pero se entiende bastante bien lo que quieres hacer (aunque el 100% del code esté en inglés).

Respecto a tabulación ¿A qué te refieres?

Y por último como recomendación aprende POO, si usamos Java sin POO mejor irnos a C  ;D


Saludos.

PD: Léete el libro 'Cómo programar en Java 7ma edición - Deitel'. Aprenderás muy rápido con este libro.
Páginas: 1 [2] 3 4 5 6 7
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines