Thursday, February 5, 2015

Finding files which are created or modified after a certain time (Unix)

On unix, we frequently need to find any new files created/modified in a directory after a given time. You can do this with the touch and find command 

Create a file with the date you need
touch -t yyyymmddHHMM t.tmp (dummy file to have a timestamp)

List all files which are newer than the date of the tmp file
find <dir> -type f  -newer t.tmp -print -exec ls -lt {} \; 

Wednesday, February 4, 2015

Setting Context Menu without Admin Privileges on Windows


If you are like mw, your company doesnt give you admin access to your Windows PC. This prevents you from customizing your PC for productivity.

Two things that I frequently use on Window are shortcuts from teh Windows Explorer menu to

  • Open my favorite editor - Notepad++ or Sublime Text 3
  • Open a command prompt at a directory - I use ConEmu

You can typically add these by adding a "command" key under


  • HKEY_CLASSES_ROOT\*\shell\"My Command Title"\command &
  • HKEY_CLASSES_ROOT\Dir\shell\"My Command Title"\command respectively

However without admin access you cannot add those keys in the registry

The good thing is that the HKEY_CLASSES_ROOT key provides a merged view of HKEY_LOCAL_MACHINE\Software\Classes and HKEY_CURRENT_USER\Software\Classes. So as a standard (non-admin) user you should have access to the later key.

You can add the commands you need to the following instead
  • HKEY_CURRENT_USER\Software\Classes\*\shell\"My Command Title"\command &
  • HKEY_CURRENT_USER\Software\Classes\Dir\shell\"My Command Title"\command respectively


Add "Edit with Notepad++" to context menus for all files


I find it very useful to be able to edit a file from the windows explorer with Notepad++ using the context menu. While I can drag the file into a open Notepad++ window, I dont always have Notepad++ open. Also I find it easier to use the context menu rather than find the window and drag the file there

Lets add a context menu item to open the file using Notepad++

My Notepad++.exe is located in c:\MyBin\Notepad++\Notepad++.exe. You will need the full path name to the exe

Since we are adding to the menu for any file, regardless of type, the Registry key of interest is HKEY_CURRENT_USER\Software\Classes\*\shell

Here is the procedure:
  1. Using Regedit, navigate to HKEY_CURRENT_USER\Software\Classes
  2. If a key "*" is present under software\Classes skip the next step 
  3. Right click on Classes and choose "New->Key". Name the new key "*"
  4. If a key "shell"  is present under Software\Classes\*  skip the next step 
  5. Right click on "*" and choose "New->Key". Name the new key "shell"
  6. Right-click on shell and choose "New->Key". Name the new key "Edit with Notepad++" (without quotes)
  7. Right-click on  "Edit with Notepad++" and choose "New->Key". Name the key as "command"
  8. Now select "command" and navigate to the right pane
  9. Double click "Default" in the right pane 
  10. Enter a value "C:\MyBin\Notepad++\Notepad++.exe "%1"" (without the outer quotes)
The context menu should appear in Windows Explorer for files of all types

Friday, April 11, 2014

Useful JVM Options (mainly related to GC troubleshooting)

-XX:+PrintFlagsInitial - Prints all JVM options with default values
-XX:+PrintCommandLineFlags - Prints the command line flags that were passed
-XX:+PrintFlagsFinal - Prints all JVM options after processing the command line

-verbose:gc - logs garbage collector runs and how long they are taking
-XX:+PrintGCTimeStamps - Prints timestamps at garbage collection
-XX:+PrintGCDetails - includes data from -verbose:gc but also adds information about the new generation
-Xloggc:gc.log - redirects the gc logs to a log file rather than the standard output

Wednesday, March 12, 2014

Installing Google Chrome on a debian Linux system using google's repository

$ sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
$ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install google-chrome-stable

Friday, August 23, 2013

Design Patterns

Creational Patterns

In software engineering, creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.
Creational design patterns are composed of two dominant ideas. One is encapsulating knowledge about which concrete classes the system uses. Another is hiding how instances of these concrete classes are created and combined.[1]
Creational design patterns are further categorized into Object-creational patterns and Class-creational patterns, where Object-creational patterns deal with Object creation and Class-creational patterns deal with Class-instantiation. In greater details, Object-creational patterns defer part of its object creation to another object, while Class-creational patterns defer its object creation to subclasses.[2]
Five well-known design patterns that are parts of creational patterns are the
  • Abstract factory pattern, which provides an interface for creating related or dependent objects without specifying the objects' concrete classes.[3]
  • Builder pattern, which separates the construction of a complex object from its representation so that the same construction process can create different representation.
  • Factory method pattern, which allows a class to defer instantiation to subclasses.[4]
  • Prototype pattern, which specifies the kind of object to create using a prototypical instance, and creates new objects by cloning this prototype.
  • Singleton pattern, which ensures that a class only has one instance, and provides a global point of access to it.[5]

Structural Patterns

  • Adapter pattern: 'adapts' one interface for a class into one that a client expects
    • Adapter pipeline: Use multiple adapters for debugging purposes.[1]
    • Retrofit Interface Pattern:[2][3] An adapter used as a new interface for multiple classes at the same time.
  • Aggregate pattern: a version of the Composite pattern with methods for aggregation of children
  • Bridge pattern: decouple an abstraction from its implementation so that the two can vary independently
    • Tombstone: An intermediate "lookup" object contains the real location of an object.[4]
  • Composite pattern: a tree structure of objects where every object has the same interface
  • Decorator pattern: add additional functionality to a class at runtime where subclassing would result in an exponential rise of new classes
  • Extensibility pattern: aka. Framework - hide complex code behind a simple interface
  • Facade pattern: create a simplified interface of an existing interface to ease usage for common tasks
  • Flyweight pattern: a high quantity of objects share a common properties object to save space
  • Pipes and filters: a chain of processes where the output of each process is the input of the next
  • Private class data pattern: restrict accessor/mutator access
  • Proxy pattern: a class functioning as an interface to another thing

Behavioral Patterns

In software engineering, behavioral design patterns are design patterns that identify common communication patterns between objects and realize these patterns. By doing so, these patterns increase flexibility in carrying out this communication.
Examples of this type of design pattern include:

Concurrency Patterns

In software engineering, concurrency patterns are those types of design patterns that deal with the multi-threaded programming paradigm. Examples of this class of patterns include: