Thursday, October 24, 2013

To connect two computers with a crossover cable

Step 1 – Configure IP Addresses
Usually, if you are using a crossover cable to connect two computers, the computers are not connected to a LAN network. In this case, you will need to configure static IP addresses for each computer.
You have to make sure that both computers have IP addresses that are on the same subnet. For example, if you give one computer an IP address of 192.168.0.1, then you should give the second computer an IP of 192.168.0.2.
If you used the above IP addresses, you should use a subnet mask of 255.255.255.0. If you use an incorrect subnet mask, the connection will not work.

Lastly, the value for the default gateway should be the same on both machines. You can pick which IP address you want to use, but use it on both computers for the default gateway. Below is how my setup looks for one computer:

Step 2 – Crossover Cable
The second thing you need to verify is that you actually have a proper crossover cable. Basically, there are a few different types of crossover cables, but it’s best to get the standard crossover cable where the green and orange pairs are swapped and the brown and blue pairs stay in the same position.
The only pins that need to be crossed are 1,3 and 2,6. So just check your cable on both end and make sure it matches the diagram.

Step 3 – Local User Accounts
If you’re having problems accessing files both ways, you may have to create a user account on each computer that has the same name and same password. This helps get past any kind of Access is Denied errors that may pop up.
Make sure the accounts are administrator accounts also! It’s best to create a new account rather than rename a current account.
Step 4 – Disable Firewalls
Finally, you should disable the firewall on both computers to ensure that none of the file sharing ports are being blocked. You can do this by going to Control Panel and then Windows Firewall. Click on Off.

Tuesday, April 23, 2013

Installing Apache with PHP

Configuring Apache:
  1. Open the httpd.conf file.  (/conf sub-directory)
  2. Use slashes / for paths.
  3. Change the DocumentRoot to point to the location of the root document folder. In the default httpd.conf file, point to "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs".
  4. Change the Directory path to match the one used in the previous step.
  5. Add to index.php to the DirectoryIndex.
  6. Append the following lines to the end of the httpd.conf file:
      LoadModule php5_module "c:/php/php5apache2_2.dll"
       AddType application/x-httpd-php .php
       PHPIniDir "C:/php"

 Configuring PHP:
  1. Rename php-ini-recommended.ini to php.ini.
  2. Uncomment the Windows include_path.
    Note: In the PHP.ini file, semicolons are used to denote that something is commented out. To uncomment a line, simply remove the semicolon.
  3. Update the doc_root to match the one that was set up in the httpd.conf file.
  4. Update the extension_dir to "C:\php\ext".
  5. Uncomment php_gd2.dll extension.
  6. Uncomment mysql.dll extension.
  7. Update the sessions.save_path to the Windows temporary files directory (i.e. C:\Temp).
  8. The PHP directory needs to be added to the Path Environment Variables.
  9. Restart Apache and test PHP on Apache.
      
      
      () ?>
     

      


       
        () ?>
       

       
Change localhost:
  1. Open the 'hosts' file with notepad. It can usually be found in c:/windows/system32/drivers/etc.
  2. Edit the end of the file to read:
         127.0.0.1 localhost
   127.0.0.1 testsite1


         

Friday, December 2, 2011

Fiddler

Fiddler is a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect traffic, set breakpoints, and "fiddle" with incoming or outgoing data.
http://www.fiddler2.com/fiddler2/

Socket IO

Socket.IO aims to make realtime apps possible in every browser and mobile device, blurring the differences between the different transport mechanisms. It's care-free realtime 100% in JavaScript.

Wednesday, October 19, 2011

Java Class File Layout and Structure

There are 10 basic sections to the Java Class File structure:

  • Magic Number: 0xCAFEBABE
  • Version of Class File Format: the minor and major versions of the class file
  • Constant Pool: Pool of constants for the class
  • Access Flags: for example whether the class is abstract, static, etc.
  • This Class: The name of the current class
  • Super Class: The name of the super class
  • Interfaces: Any interfaces in the class
  • Fields: Any fields in the class
  • Methods: Any methods in the class
  • Attributes: Any attributes of the class (for example the name of the sourcefile, etc.)

There is a handy mnemonic for remembering these 10: My Very Cute Animal Turns Savage In Full Moon Areas.

Magic, Version, Constant, Access, This, Super, Interfaces, Fields, Methods, Attributes (MVCATSIFMA)

Magic Numbers in Files

Detecting such constants in files is a simple and effective way of distinguishing between many file formats and can yield further run-time information.

Examples
  • Compiled Java class files (bytecode) start with hex CAFEBABE. When compressed with Pack200 the bytes are changed to CAFED00D.
  • GIF image files have the ASCII code for "GIF89a" (47 49 46 38 39 61) or "GIF87a" (47 49 46 38 37 61)
  • JPEG image files begin with FF D8 and end with FF D9. JPEG/JFIF files contain the ASCII code for "JFIF" (4A 46 49 46) as a null terminated string. JPEG/Exif files contain the ASCII code for "Exif" (45 78 69 66) also as a null terminated string, followed by more metadata about the file.
  • PNG image files begin with an 8-byte signature which identifies the file as a PNG file and allows detection of common file transfer problems: \211 P N G \r \n \032 \n (89 50 4E 47 0D 0A 1A 0A). That signature contains various newline characters to permit detecting unwarranted automated newline conversions, such as transferring the file using FTP with the ASCII transfer mode instead of the binary mode.
  • Standard MIDI music files have the ASCII code for "MThd" (4D 54 68 64) followed by more metadata.
  • Unix script files usually start with a shebang, "#!" (23 21) followed by the path to an interpreter.
  • PostScript files and programs start with "%!" (25 21).
  • PDF files start with "%PDF" (hex 25 50 44 46).
  • MS-DOS EXE files and the EXE stub of the Microsoft Windows PE (Portable Executable) files start with the characters "MZ" (4D 5A), the initials of the designer of the file format, Mark Zbikowski. The definition allows "ZM" (5A 4D) as well, but this is quite uncommon.
  • Amiga's black screen of death called Guru Meditation, in its first version, when the machine hung up for uncertain reasons, showed the hexadecimal number 48454C50, which stands for "HELP" in hexadecimal ASCII characters (48=H, 45=E, 4C=L, 50=P).
  • TIFF files begin with either II or MM followed by 42 as a two-byte integer in little or big endian byte ordering. II is for Intel, which uses little endian byte ordering, so the magic number is 49 49 2A 00. MM is for Motorola, which uses big endian byte ordering, so the magic number is 4D 4D 00 2A.
  • Unicode text files encoded in UTF-16 often start with the Byte Order Mark to detect endianness (FE FF for big endian and FF FE for little endian). UTF-8 text files often start with the UTF-8 encoding of the same character, EF BB BF.
  • LLVM Bitcode files start with BC (0x42, 0x43)
  • Microsoft Office document files start with D0 CF 11 E0, which is visually suggestive of the word "DOCFILE0".
  • Headers in ZIP files begin with "PK" (50 4B), the initials of Phil Katz, author of DOS compression utility PKZIP.