Recent posteets

Sort by: Date / Title /

  1. 9 years ago by haduart
    With this function we can save a serialized class into a MySQL's table.
    1. /**
    2.           * Actualitza l'objecte serialitzat (scorm_structure) de
    3.           * l'usuari amb l'identificador indicat.
    4.           *
    5.           * Nota! Fa un update, per tant ha d'existir l'usuari!
    6.           *
    7.           * @param courseStudentName : El nom de la taula en que ho guardem.
    8.           * @param studentId : L'identificador de l'usuari.(int Type)
    9.           * @param object : Retornarà l'UserObjective, caldrà fer un cast.
    10.           * @return int Type: Retornarà l'identificador del resultset.
    11.           * @throws Exception : Llança una excepció si hi ha un error.
    12.           */
    13.         private int writeJavaObject(
    14.                         final String courseStudentName,
    15.                         final int studentId,
    16.                         final Object object)
    17.          throws Exception {          
    18.                 String sqlUpdateScormStructure =
    19.                         "UPDATE " + courseStudentName
    20.                         + " set scorm_structure = ? WHERE student_id = ?";
    21.                 /** We already have
    22.                   * private Connection conn = DriverManager.getConnection(url, userName, password);
    23.                   */
    24.                 PreparedStatement pstmt =
    25.                         conn.prepareStatement(sqlUpdateScormStructure);
    26.                
    27.                 ByteArrayOutputStream baos = new ByteArrayOutputStream();
    28.                 ObjectOutputStream oout = new ObjectOutputStream(baos);
    29.                 oout.writeObject(object); //serializing
    30.                     
    31.                 // set input parameters
    32.                 pstmt.setBytes(1, baos.toByteArray());        
    33.                 pstmt.setInt(2, studentId);
    34.                 pstmt.executeUpdate();
    35.  
    36.                 // get the generated key for the id
    37.                 ResultSet rs = pstmt.getGeneratedKeys();
    38.                 int id = -1;
    39.                 if (rs.next()) {
    40.                         id = rs.getInt(1);
    41.                 }
    42.                
    43.                 rs.close();
    44.                 pstmt.close();
    45.                 return id;
    46.         }
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/703"></script>
  2. 9 years ago by haduart
    I'm not loading a .jar library, I'm only loading a .class, which implements my library functions. To test this code you must have in the directory D:\LoadLibrary a TestHelloWorld.class and the interface TestString WITH THE SAME package that you have in the main code. It means that if your TestString in your main code is com.haduart.TestString you must put your TestString.class in the D:\LoadLibrary\com\haduart\TestString.class.
    1. /**
    2. * In the D:/LoadLibrary we must have .class and the same interface (TestString) with the same pacakge as the
    3. * main program.
    4. */
    5. URL urlToJar = new URL("file://D:/LoadLibrary/");
    6. URLClassLoader cl = new URLClassLoader(new URL[] { urlToJar });
    7.                
    8. System.out.println("loading...");
    9. Class c2 = cl.loadClass("TestHelloWorld");
    10. System.out.println("loaded!");
    11. Object nouObject = c2.newInstance();
    12.  
    13. TestString ts = (TestString) cons.newInstance(args);
    14. /**
    15. * Now we can use the "ts" object as a normal TestString interface. No matter which is the implementation that is begin it.
    16. */
    17. System.out.println("S1: " + ts.printS1());
    18. System.out.println("S2: " + ts.printS2());
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/699"></script>
  3. 9 years ago by kwd2032
    Estos son los códigos para las paginas de las alianzas de OGame que funcionan con la nueva versión 0.78c Revisar cada nueva actualización.
    1. [font=textstyle] [/font] => Estilo de fuente (ej: arial, tahoma...)
    2. [sub] [/sub] => subscript - Texto en subindice
    3. [sup] [/sup] => superscript - Texto en superindice
    4. [U] [/U] => Texto subrayado
    5. [size=number] [/size] => Tamaño
    6. [color=#htmlcolorcode] [/color] => Colores (ver parte inicial del post)
    7. [align=center/left/right] [/align] => Alineamiento (3 posibilidades)
    8. [center] [/center] => Centrado (se puede hacer con la anterior tb)
    9. [b] [/b] => Negrita (tambien llamado, morenita, gorda, africana)
    10. [s] [/s] => Tachado
    11. [i] [/i] => Italica (si, de roma, por ejemplo)
    12. [EMAIL=email@mail.xx]text[/EMAIL] => Para poner link de eMail
    13. [IMG]pic.jpg[/IMG] => Una imagen
    14. [URL=http://ogame.de]text[/URL] => Una URL (http://es.wikipedia.org/wiki/Localizador_Uniforme_de_Recursos)
    15. [background image="url"]text[/background] ==> imagen de fondo
    16. [background image="url" image-repeat='yes-x']text[/background] ==> imagen de fondo repetida en el eje x (de derecha a izquierda)
    17. [background image="url" image-repeat='yes-y']text[/background] ==> imagen de fondo repetida en el eje y (de arriba a abajo)
    18. [background image="url" image-repeat='no']text[/background]
    19. [background image="url" image-repeat='yes']text[/background]
    20. [background color="color"]text[/background]
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/698"></script>
  4. sponsorised links
  5. 9 years ago by spirit
    1. var myfunc = function(optional) {
    2.   if (typeof optional == "undefined") {
    3.     optional = "default value";
    4.   }
    5.   alert(optional);
    6. }
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/691"></script>
  6. 9 years ago by spirit
    Vérifier tout de même sur le site http://www.backports.org que le paquet plus récent à installer a bien été backporté
    1. echo "deb http://www.backports.org/debian etch-backpoprts main contrib non-free" >> /etc/apt/source.list   # Le mirroir
    2. aptitude update
    3. aptitude install debian-backports-keyring   # Clé publique du dépôt
    4. aptitude update
    5.  
    6. # Remplacer postgresql par le package que vous souhaitez
    7. echo "Package: postgresql
    8. Pin: release a=etch-backports
    9. Pin-Priority: 999" >> /etc/apt/preferences
    10.  
    11. aptitude install postgresql
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/690"></script>
  7. 9 years ago by spirit
    - Catalyst Cisco 6509 or 3750:
    
    switch#configure terminal
    switch(config)#monitor session 1 source interface GigabitEthernet x/x
    switch(config)#monitor session 1 destination interface GigabitEthernet x/x
    
    - Catalyst Cisco 3500XL:
    
    switch#configure terminal
    switch(config)#interface FastEthernet x/x
    switch(config-if)#port monitor FastEthernet x/x
    
    - Firewall Juniper/Netscreen 25
    
    set mirror port source interface1 destination interface2
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/689"></script>
  8. 9 years ago by spirit
    Prevent flooding
    Switch# conf t
    Switch1(config)# interface ethernet 0/4 
    Switch1(config-if)# port secure max-mac-count 100
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/688"></script>
  9. 9 years ago by spirit
    1. function replace(str:String,find:String,replace:String):String
    2. {
    3.         var index:Number;
    4.         while(str.indexOf(find)!=-1)
    5.         {
    6.                 index= str.indexOf(find);
    7.                 str = str.substr(0,index) + replace + str.substr(index + find.length);
    8.         }
    9.         return str;
    10. }
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/685"></script>
  10. 9 years ago by spirit and saved by 1 other
    1. # Debian : edit the following file (mac to eth association)
    2. /etc/udev/rules.d/z25_persistent-net.rules
    3.  
    4. # The long way : change the name when loading the module for the NIC
    5. cat /etc/sysconfig/hwconf | grep -A 16 NETWORK
    6. class: NETWORK
    7. bus: PCI
    8. detached: 0
    9. device: eth0
    10. driver: 8139t
    11. # Then change the device name in the ifcfg script: /etc/sysconfig/network-scripts/ifcfg-ethX
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/682"></script>

First / Previous / Next / Last / Page 51 of 51 (509 posteets)