Java Applet Restrictions 08 April 2003 at 00:00
Java applets run in a "sandbox" in most browsers which prevent many operations from executing due to security restrictions. In IE 5.5, these restrictions can be lifted by doing the following:
  • Tools...Internet Options....
  • Security Tab
  • Select the zone (Advisable to only do this for trusted sites)
  • Click Custom Level... button
  • Scroll down to Microst VM/Java permissions and click the Custom radio button
  • Click Java Custom Settings button
  • Click Edit Permissions Tab
  • Select the Unsigned Content/Run Unsigned Content/Enable radio button
The above procedure edits the following registry entries:
  • HKCUSoftwareMicrosoftWindowsCurrentVersionIInternet SettingsZones2 Key: 0xE245C3C0
  • HKCUSoftwareMicrosoftWindowsCurrentVersionIInternet SettingsZones2 {7839DA25-F5FE-11D0-883B-0080C726DCBB} 30 82 01 52 03 02 00 00 ...
  • HKCUSoftwareMicrosoftWindowsCurrentVersion\Internet SettingsZones2 Key: 0xE245C3C0
Regular Expressions Cheat Sheet 08 April 2003 at 00:00
<

A less than at the start of the string matches the start of a line.

% A percent sign at the start of the string matches the start of a line.
^ A circumflex at the start of the string matches the start of a line.
. A period matches any character.
* An asterisk after a string matches any number of occurrences of that string followed by any characters, including zero characters. For example, bo* matches bot, bo and boo but not b.
$ A dollar sign at the end of the expression matches the end of a line.
> A greater than at the end of the expression matches the end of a line.
? A question mark matches any single character.
@ An at sign after a string matches any number of occurrences of that string followed by any characters, including zero characters. For example, bo@ matches bot, boo, and bo.
+ A plus sign after a string matches any number of occurrences of that string followed by any characters, except zero characters. For example, bo+ matches bot and boo, but not b or bo.
| A vertical bar matches either expression on either side of the vertical bar. For example, bar|car will match either bar or car. ~ A tilde matches any single character that is not a member of a set.
[ ] Characters in brackets match any one character that appears in the brackets, but no others. For example [bot] matches b, o, or t.
[^] A circumflex at the start of the string in brackets means NOT. Hence, [^bot] matches any characters except b, o, or t. [-] A hyphen within the brackets signifies a range of characters. For example, [b-o] matches any character from b through o.
[-] A hyphen within the brackets signifies a range of characters. For example, [b-o] matches any character from b through o.
{ } Braces group characters or expressions. Groups can be nested, with a maximum number of 10 groups in a single pattern. . For the Replace operation, the groups are referred to by a backslash and a number according to the position in the ?Text to find? expression, beginning with 0. For example, given the text to find and replacement strings, Find: {[0-9]}{[a-c]*}, Replace: NUM1, the string 3abcabc is changed to NUMabcabc.
A backslash before a wildcard character tells the IDE to treat that character literally, not as a wildcard. For example, ^ matches ^ an d does not look for the start of a line.
Recompiling the Linux kernel 23 April 2003 at 00:00
The following steps should be followed in order to recompile the Linux kernel (example is for Slackware 8.0 - this may differ in other versions of Linux)
  1. Extract the linux source files to /usr/src and create a link: link -s linux-2.4.19 linux
  2. cd linux
  3. make mrproper
  4. make menuconfig
  5. make dep
  6. make clean
  7. make bzImage
  8. make modules
  9. make modules_install
  10. copy arch/i386/boot/bzImage to /boot
  11. copy System.map to /boot
  12. edit /etc/lilo.conf - change the image to point to /boot/bzImage
  13. type "lilo" (very NB - the machine will not boot up without this!)
  14. reboot

X Considerations

If you plan on installing X Windows, you should take note of the following:

  • Compile MTRR (Memory Type Range Registers) support into the kernel as it can increase performance of image write operations 2.5 times or more on PCI or AGP video cards. The option is found in the "Processor type and features" menu.
  • In the "Character Devices" section, enable AGP Support and select the chipset support on your motherboard. If you do not know the chipset, you may select all the chip types at the expense of extra kernel size. You can usually determine your motherboard's chipset by running "cat /proc/pci".
VB6 : Associating file extensions with your app 08 April 2003 at 00:00
  string keyName = "MyApp";
  string keyValue = "My Application";
  RegistryKey key = null;

  key = Registry.ClassesRoot.CreateSubKey(keyName);
  key.SetValue("",keyValue);
  key = key.CreateSubKey("shell");
  key = key.CreateSubKey("open");
  key = key.CreateSubKey("command");
  key.SetValue("","c:tempmy.exe %1");
            
  keyName = ".bar";	// file association you want
  keyValue = "MyApp";	// must correspond to above!!
  key = Registry.ClassesRoot.CreateSubKey(keyName);
  key.SetValue("", keyValue);
Linux : Scripting automatic file transfers via FTP 08 April 2003 at 00:00
You can FTP in script files as a scheduled tasks by doing the following:

Create the shell file that will be run by the cron job:

  echo "FTP process commencing"
  su <youruser> -c "ftp 192.1.2.2 < /home/youruser/prodftp.txt"
  echo "FTP process completed"
In the above file, the user must be a user that has been setup to automatically log into the FTP service on the remote machine 192.1.2.3 (see FTP: Automatic login under the Operating Systems/Linux category).

The text file /home/youruser/prodftp.txt will contain the actual FTP information, for example:

  cd backups
  ls
  binary
  prompt
  mdelete *.dmp
  ls
  mput *.dmp
  ls
  close
  exit
The prompt command is very important - it turns off the interactive prompting for moving multiple files.
C# : Capturing process output 08 April 2003 at 00:00
By running external commands using the System.Diagnostics.Process class, you can also retrieve the output from that command by using it's StandardOutput property:

  Process p = new Process();
  StreamReader sr = null;
  ProcessStartInfo psi = new ProcessStartInfo("D:\Matt\test.bat");
  psi.UseShellExecute = false;
  psi.RedirectStandardOutput = true;
  psi.CreateNoWindow = true;
  p.StartInfo = psi;
  p.Start();
  sr = p.StandardOutput;
  string line = null;
  while ((line = sr.ReadLine()) != null) {
    Console.WriteLine(line);
  }
PHP dynamic file downloads 03 April 2003 at 00:00
The following forces the user's browser to open a save dialog for the file:
  header("Content-type: application/pdf");
  header("Content-Disposition: inline; filename=downloaded.pdf");
C# Windows API Calls 30 April 2003 at 00:00

If, for example you want to send a message to you window to bring it to the top of the z-order, add the following code into your class declaration, e.g.:

  public class MyClass {

    private bool x = false;

   [DllImport("user32.dll",EntryPoint="BringWindowToTop")]
   private static extern int BringWindowToTop(int hWnd);

The EntryPoint is not required - if omitted the entry point into the dll will be the name of the method.

To use the imported method, just call as normal, e.g.

  BringWindowToTop(MyForm.Handle.ToInt32());
Running command-line queries on a PostgreSQL database 08 April 2003 at 00:00
To run command-line queries on a PostgreSQL database running on Linux, you need to locate the psql executable, connect to the database and run queries manually:
locate psql
(e.g. returns /usr/bin/psql)
/usr/bin/psql <database_name>
SELECT * FROM <table> LIMIT 200;
q (to quit)