Monday, 30 September 2013

Just to remember: starting firefox profile manager

To start firefox profile manager one should:
1. Shut down all firefox instances
2. >firefox.exe -p
To run firefox with created profile
>firefox.exe" -p backdoor -no-remote

Monday, 22 July 2013

Remains of the Day: Add 'Open command window here' context menu to any file

Command prompt here PowerToy for Windows adds 'Open command prompt here' context menu for every folder.
Use this registry file to add 'Open command prompt here' to any file context menu:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Open command prompt here]

[HKEY_CLASSES_ROOT\*\shell\Open command prompt here\command]
@="cmd"

Converting a VirtualBox VM to a VMWare Workstation 7.0.1 VM

To successfully convert a VirtualBox (latest version) vm to VMWare Workstation 7.0.1 vm one should do the following:
1. In VirtualBox export vm as ovf virtual appliance without manifest file (don't forget to check 'ovf version 0.9').
2. Ensure that VMWare will understand newly generated ovf file. To do it:
2.1 Edit ovf file so 'rasd' elements are sorted in the following order:
  <Item>
    <rasd:Caption>Some caption</rasd:Caption>
    <rasd:Description>Some description</rasd:Description>
    <rasd:InstanceId>0</rasd:InstanceId>
    <rasd:ResourceType>1</rasd:ResourceType>
    <rasd:ResourceSubType>2</rasd:ResourceSubType>
  </Item>
2.2 Ensure that rasd:Parent elements precede rasd:AdressOnParent elements.
2.3 Change the extension of original vmdk disk files to something like '~vmdk'.
2.4 Check that conversion is possible using VMWare OVF Tool with the following command:
"C:\Program Files\VMware\VMware OVF Tool\ovftool.exe" --noDisks "ODD - Source.ovf" "ODD - Source.vmx"
You should see the following output:
Opening OVF source: ODD - Source.ovf
Opening VMX target: ODD - Source.vmx
Writing VMX file: ODD - Source.vmx
Transfer Completed
Warning:
 - No manifest file found.
 - No manifest entry found for: 'ODD - Source-disk1.vmdk'.
 - No manifest entry found for: 'ODD - Source-disk2.vmdk'.
Completed successfully
If not, the tool will report error lines. So correct errors and rerun.
2.5 Delete vmdk files generated by ovftool and change back the extension of original files.

Pitiful but OVF Tool alone cannot properly convert ovf to vmx. Disk partitions will remain read only as made by VirtualBox export process.
3. So the last thing to do is to use VMWare Converter 4.0.1 (can be downloaded following links in this post) to convert ovf to vmx changing disks types to 2 GB Split pre-allocated.

Thursday, 4 July 2013

On database link naming

Name dblinks as a site it refers.
For example name it 'subdomain.somesite.com' and then create synonyms to objects on the site:
create synonym some_table for some_table@subdomain.somesite.com
Doing so you help other developers to decipher the site particular database link refers to without consulting all_db_links system view.

Friday, 7 June 2013

Perl script to extract and present hex colors found in arbitrary text

The following script searches STDIN for 3 or 6 symbol hex values and prints a html structure that represents those values as colors on page.
#!/usr/bin/perl -w
use Set::Scalar;

$uniqueColors = Set::Scalar->new;
while( defined( $_ = <STDIN> ) ){
 while ( $_ =~/(#[a-fA-F0-9]{1,6})/g ){
  $uniqueColors->insert( $1 )
 }
}
print <<HEADER;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
   <HEAD>
      <TITLE>Found HEX colors</TITLE>
   </HEAD>
   <BODY>
HEADER
while ( defined( my $color = $uniqueColors->each ) ){
 print "<p style=\"background: " . $color . "\">" . $color . "</p>\n"
}
print "</BODY>
</HTML>"
Used this one to parse color-theme-tangotango.el emacs color theme file.
To view example output hit "read more".

Interesting remarks on using standard libraries

While searching for implementation of Sets in Perl bumped into these interesting arguments for using standard libraries on StackOverflow.

Use one of the many Set modules on CPAN. Judging from your example, Set::Light or Set::Scalar seem appropriate.


I can defend this advice with the usual arguments pro CPAN (disregarding possible synergy effects).

  1. How can we know that look-up is all that is needed, both now and in the future? Experience teaches that even the simplest programs expand and sprawl. Using a module would anticipate that.
  2. An API is much nicer for maintenance, or people who need to read and understand the code in general, than an ad-hoc implementation as it allows to think about partial problems at different levels of abstraction.
  3. Related to that, if it turns out that the overhead is undesirable, it is easy to go from a module to a simple by removing indirections or paring data structures and source code. But on the other hand, if one would need more features, it is moderately more difficult to achieve the other way around.
  4. CPAN modules are already tested and to some extent thoroughly debugged, perhaps also the API underwent improvement steps over the time, whereas with ad-hoc, programmers usually implement the first design that comes to mind.

Rarely it turns out that picking a module at the beginning is the wrong choice.

Thursday, 6 June 2013

Oracle SQL selects to get familiar with table naming standard and to find junk tables in scheme

Run following selects to discover prefix and suffix hierarchies and to get count of particular prefix/suffix occurrences. That will help you become familiar with naming standard and to find suspicious prefixes/suffixes that belong to tables that probably store junk data.