Friday, November 29, 2013

Chest

  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import java.util.*;
  4. import javax.swing.*;
  5. public class ChessGameDemo extends JFrame implements MouseListener, MouseMotionListener {
  6. JLayeredPane layeredPane;
  7. JPanel chessBoard;
  8. JLabel chessPiece;
  9. int xAdjustment;
  10. int yAdjustment;
  11. public ChessGameDemo(){
  12. Dimension boardSize = new Dimension(600, 600);
  13. // Use a Layered Pane for this this application
  14. layeredPane = new JLayeredPane();
  15. getContentPane().add(layeredPane);
  16. layeredPane.setPreferredSize(boardSize);
  17. layeredPane.addMouseListener(this);
  18. layeredPane.addMouseMotionListener(this);
  19.  
  20. //Add a chess board to the Layered Pane
  21. chessBoard = new JPanel();
  22. layeredPane.add(chessBoard, JLayeredPane.DEFAULT_LAYER);
  23. chessBoard.setLayout( new GridLayout(8, 8) );
  24. chessBoard.setPreferredSize( boardSize );
  25. chessBoard.setBounds(0, 0, boardSize.width, boardSize.height);
  26. for (int i = 0; i < 64; i++) {
  27. JPanel square = new JPanel( new BorderLayout() );
  28. chessBoard.add( square );
  29. int row = (i / 8) % 2;
  30. if (row == 0)
  31. square.setBackground( i % 2 == 0 ? Color.blue : Color.white );
  32. else
  33. square.setBackground( i % 2 == 0 ? Color.white : Color.blue );
  34. }
  35. //Add a few pieces to the board
  36. JLabel piece = new JLabel( new ImageIcon("/home/vinod/amarexamples/chess.jpg") );
  37. JPanel panel = (JPanel)chessBoard.getComponent(0);
  38. panel.add(piece);
  39. piece = new JLabel(new ImageIcon("/home/vinod/amarexamples/chess1.jpg"));
  40. panel = (JPanel)chessBoard.getComponent(15);
  41. panel.add(piece);
  42. piece = new JLabel(new ImageIcon("/home/vinod/amarexamples/king.jpg"));
  43. panel = (JPanel)chessBoard.getComponent(16);
  44. panel.add(piece);
  45. piece = new JLabel(new ImageIcon("/home/vinod/amarexamples/camel.jpg"));
  46. panel = (JPanel)chessBoard.getComponent(20);
  47. panel.add(piece);
  48.  
  49. }
  50. public void mousePressed(MouseEvent e){
  51. chessPiece = null;
  52. Component c = chessBoard.findComponentAt(e.getX(), e.getY());
  53. if (c instanceof JPanel)
  54. return;
  55. Point parentLocation = c.getParent().getLocation();
  56. xAdjustment = parentLocation.x - e.getX();
  57. yAdjustment = parentLocation.y - e.getY();
  58. chessPiece = (JLabel)c;
  59. chessPiece.setLocation(e.getX() + xAdjustment, e.getY() + yAdjustment);
  60. chessPiece.setSize(chessPiece.getWidth(), chessPiece.getHeight());
  61. layeredPane.add(chessPiece, JLayeredPane.DRAG_LAYER);
  62. }
  63. //Move the chess piece around
  64. public void mouseDragged(MouseEvent me) {
  65. if (chessPiece == null) return;
  66. chessPiece.setLocation(me.getX() + xAdjustment, me.getY() + yAdjustment);
  67. }
  68. //Drop the chess piece back onto the chess board
  69. public void mouseReleased(MouseEvent e) {
  70. if(chessPiece == null) return;
  71. chessPiece.setVisible(false);
  72. Component c = chessBoard.findComponentAt(e.getX(), e.getY());
  73. if (c instanceof JLabel){
  74. Container parent = c.getParent();
  75. parent.remove(0);
  76. parent.add( chessPiece );
  77. }
  78. else {
  79. Container parent = (Container)c;
  80. parent.add( chessPiece );
  81. }
  82. chessPiece.setVisible(true);
  83. }
  84. public void mouseClicked(MouseEvent e) {
  85. }
  86. public void mouseMoved(MouseEvent e) {
  87. }
  88. public void mouseEntered(MouseEvent e){
  89. }
  90. public void mouseExited(MouseEvent e) {
  91. }
  92. public static void main(String[] args) {
  93. JFrame frame = new ChessGameDemo();
  94. frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE );
  95. frame.pack();
  96. frame.setResizable(true);
  97. frame.setLocationRelativeTo( null );
  98. frame.setVisible(true);
  99. }
  100. }
  101.  

Message - Up

import java.*;
 
import java.security.MessageDigest;
 
public class pw_test {
        public static void main(String[] args) {
                // Original: String imei = System.getProperty("com.nokia.mid.imei");
                String imei = "580179140553553"; // your IMEI
               
        StringBuffer buffer = new StringBuffer(imei);
        if(buffer.length() == 0)
        {
            System.exit(0);
        }
        buffer = buffer.reverse();
        S40MD5Digest digest = new S40MD5Digest();
        digest.reset();
        try
        {
            digest.update(buffer.toString().getBytes("UTF-8"));
        }
                catch(Exception e)
        {
            e.printStackTrace();
        }
        byte bytes[] = digest.digest();
        int bytesLength = bytes.length;
        buffer = new StringBuffer();
        for(int i = 0; i < bytesLength; i++)
        {
            int unsignedByte = bytes[i] + 128;
            buffer.append(Integer.toString(unsignedByte, 16));
        }
 
        System.out.println(buffer.toString());
    }
}
 
class S40MD5Digest
//    implements com.whatsapp.api.util.MessageDigest
{
 
    public S40MD5Digest()
    {
        try
        {
            _md5 = MessageDigest.getInstance("md5");
        }
        catch(Exception x) { }
    }
 
    public void reset()
    {
        _md5.reset();
    }
 
    public void update(byte bytes[])
    {
        _md5.update(bytes, 0, bytes.length);
    }
 
    public byte[] digest()
    {
        byte arr[] = new byte[128];
        int res;
        try
        {
            res = _md5.digest(arr, 0, 128);
        }
        catch(Exception x)
        {
            return null;
        }
        byte resArr[] = new byte[res];
        System.arraycopy(arr, 0, resArr, 0, res);
        return resArr;
    }
 
    MessageDigest _md5;
}

ali



    <!DOCTYPE html>
    <html id="facebook" class="tinyViewport" lang="en">
        <head> … </head>
        <body class="fbIndex UIPage_LoggedOut gecko win Locale_en_US">
            <div class="_li">
                <div id="pagelet_bluebar" data-referrer="pagelet_bluebar">
                    <div id="blueBarHolder">
                        <div id="blueBar">
                            <div>
                                <div class="loggedout_menubar_container">
                                    <div class="clearfix loggedout_menubar">
                                        <a class="lfloat" title="Go to Facebook Home" href="/"> … </a>
                                        <div class="menu_login_container rfloat">
                                            <form id="login_form" onsubmit="return window.Event && Event.__inlineSubmit && Event.__inlineSubmit(this,event)" method="post" action="https://www.facebook.com/login.php?login_attempt=1">
                                                <input type="hidden" autocomplete="off" value="AVqC31eo" name="lsd"></input>
                                                <table cellspacing="0">
                                                    <tbody>
                                                        <tr> … </tr>
                                                        <tr>
                                                            <td>
                                                                <input id="email" class="inputtext" type="text" tabindex="1" value="" name="email"></input>
                                                            </td>
                                                            <td> … </td>
                                                            <td> … </td>
                                                        </tr>
                                                        <tr> … </tr>
                                                    </tbody>
                                                </table>
                                                <input id="u_0_k" type="hidden" value="-120" name="timezone" autocomplete="off"></input>
                                                <input type="hidden" value="085550_G4H8" name="lgnrnd"></input>
                                                <input id="lgnjs" type="hidden" value="1385744155" name="lgnjs"></input>
                                                <input id="locale" type="hidden" value="en_US" name="locale" autocomplete="off"></input>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                                <div id="login_chooser_container" class="_4--d hidden_elem"> … </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div id="globalContainer" class="uiContextualLayerParent"> … </div>
            </div>
            <script data-signature="1" type="text/javascript"> … </script>
            <script> … </script>
            <script> … </script>
            <script> … </script>
            <!--

             BigPipe construction and first response

            -->
            <script> … </script>
            <script> … </script>
            <script> … </script>
        </body>
    </html>