Friday, August 28, 2015

Why markup when you can excel? :)

What-a-concept.. first I write a bit of glue code to make Excel-to-Wiki, now the other way around
This was, however, a bit trickier.
The path followed was to convert wiki markup to HTML and parse HTML table elements to generate Excel.
I am using a fine library called py-wikimarkup which appears to work quite well in the conversion to HTML.

Note that this is now trivially wrapped in a web service that can round trip between Excel and Wiki markup all day long.
If anyone has any interest in the webservice I can post that up here as well.

Wiki To Excel project: https://github.com/venkman69/WikiToExcel

Enjoy!
N
PS: The other direction: http://techybabble.blogspot.com/2015/07/excel-to-wiki-markup.html

Thursday, July 30, 2015

Excel to Wiki Markup

After some digging, it looks like openpyxl and some slightly unorthodox inspection of the excel file's structure (gleaned from internet searches) offer a way to extract cell and font styling information.
The wiki markup being what it is, still feels like writing on a stone tablet considering tools we have nowadays. To make life slightly more liveable in the wiki world, I wrote a converter that supports the styling information.

Guess what, I am yet to see one excel to wiki converter that maintains the styling information. I know my code has a ways to go, but it is a far better effort than treating it just as data. Seriously, without simple background colors etc, excel sheets just look like matrix. And that thrown into wiki shows up even more ugly.

Anyhoo, cutting to chase, here's the github link: https://github.com/venkman69/ExcelToWiki
And it is also available from PyPi so you should be able to pip install it as well: https://pypi.python.org/pypi/exceltowiki

Enjoy,
N
PS: The other direction: http://techybabble.blogspot.com/2015/08/why-markup-when-you-can-excel.html

Tuesday, June 30, 2015

Store and Retrieve passwords in a Script using Mac KeyChains

Store a password into the mac keychain:

The following command stores a password into the keychain

security add-generic-password -a <username> -s <appname, friendly name> -p <password> -A -U


Retrieve the password from the mac keychain:

And this outputs the password to the stdout:
security find-generic-password -s <appname, friendly name> -g -w

Thursday, May 21, 2015

MAC to Linux dircolors does not work

Going from MAC to Linux over ssh the dircolors command does not work

When you test dircolors command with simply typing dircolors it gives:
$ dircolors
LS_COLORS='';
export LS_COLORS

The cause is that the discolors is inspecting the TERM variable and the TERM as reported is:

$ echo $TERM
xterm-256color

The fix to get around this is to add the line into the .dir_colors for this terminal type
TERM xterm
TERM xterm-256color
TERM xterm-color
TERM xterm-debian
TERM rxvt

Notes: 

  • The $HOME/.dir_colors can be your custom color setup. 
  • You can typically get a vanilla copy from /etc/dircolors
  • If not, you can run the following command to print the database of dircolors into this file.
    dircolors -p > ~/.dir_colors
  • Next, add the following into your .profile, .bash_profile etc. wherever appropriate.
    eval `dircolors -b ~/.dir_colors`
    alias ls='ls --color=always'
Now, 'ls' command will appropriately color the entries and it will work when ssh'ing from a mac.

Thursday, April 9, 2015

How to setup remote debug with WebLogic and Eclipse

Setup remote debug with WebLogic and Eclipse

As always there is the clean way, and the one-off way.
We will see how to setup debug for weblogic using the clean way which is to leverage all the built-in items already present but not clear that they are.

<domain>/bin/setDomainEnv.sh has interesting items: 

  • First there is the debugFlag="true"
  • Then there is DEBUG_ PORT="8453"
  • Then you will also see:
JAVA_DEBUG="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=${DEBUG_PORT},server=y,suspend=n -Djava.compiler=NONE

So the clean answer lies somewhere between these three. Also while there is the command line option as well (as you can see at the bottom of the setDomainEnv.sh).

Note: In production mode the debug is disabled by default by unsetting the flag. We can however get around this by re-setting the flag after this piece of code.

So here are the steps

Set the debug Flag

After around line number 203 in setDomainEnv.sh add the lines (ignore echo if you don't want the noise). This will also get around the production mode issue mentioned above

Add after this block (around Line 203):
if [ "${PRODUCTION_MODE}" = "true" ] ; then
        debugFlag="false"
        export debugFlag
        testConsoleFlag="false"
        export testConsoleFlag
        iterativeDevFlag="false"
        export iterativeDevFlag
        logErrorsToConsoleFlag="false"
        export logErrorsToConsoleFlag
fi
echo "Setting debug flag"
export debugFlag="true"

If you are not using just the Admin Server:

If your deployment is using a specific managed server, then you can modify the above as:
if [ "${SERVER_NAME}" = "mgdserver1" ] ; then
      echo "Setting debug flag for mgdserver1"
      export debugFlag="true"
fi

If you have to remote debug more than one managed server

The above block also allows you to specify a different port number for this server. And you can duplicate the same block for each of your servers if needed.
if [ "${SERVER_NAME}" = "mgdserver1" ] ; then
      echo "Setting debug flag for mgdserver1 and port to 8454"
      export debugFlag="true"
      export DEBUG_PORT="8454"
fi

Eclipse setup

In Eclipse the setup is simple.
  • Right click on the Project containing the deployed items. Select "Debug as">"Debug Configurations"
  • Locate "Remote Java Application" in the list on the left
  • Create a new configuration with hostname and debug port of the weblogic server


Wednesday, February 11, 2015

Eclipse GIT beginners tutorial - Part I



Goals:
To get a local GIT repository working with Eclipse project quickly. The idea is to have a GIT source control backed Eclipse project so you can make commits and get into the habit of using the GIT's features of branching, tagging, etc.
And at some point of time if the project needs to be shared then adding a remote and sync'ing (push) with it.

Note: I didn't find a simple guide when I searched for it and have decided to write one for those in search of such a setup.

(And thanks to the 'wink' project debugmode.com, I have used it for several years. It is simple and good enough for most captures).

Starting from the top

  • Create a new project. I created a Java project in eclipse, but obviously it can be whatever you choose. 
 

  • Name your project. Location of the project at this time is not relevant since it will end up being moved into the GIT repository later.


  •  Optional : create some code etc.

 
  • Share the project: Right click the Project then Team> Share Project

  • Select GIT
  • Create a GIT repository.
  • Note that you will be creating one repository per Eclipse Project. You can obviously have more than one project in one Repository but that messes with the commits and tagging of a single project related activity and tracking etc.

  • All set to make the move to a GIT repo.
     
  • Check the properties of the project to identify where the project files are located.
  •  Note that it has been moved into the GIT repository location. IMP NOTE: Any open files while you were making the move into GIT are now stranded since they are still open from the original location. So close those files and re-open them in Eclipse.








  • We make a spelling mistake and commit the change. 
  • Commit the change


    • History of commits shows the activity.
    • Oops we just noticed the error 'nmae' instead of 'name'.
    •  Fix the spelling and commit again. I prefer to commit one file at a time with notes on the changes for each file. You could have committed any number of changes in any number of files with a single commit comment. That is definitely helpful when changes are fairly obvious.
    • Note: At the time of committing a change, you can double click on any file in the commit box and Eclipse will bring up a compare window showing comparison between current and previous commit history.

    • You can compare with older commits for a file now using GIT functionality. And identify what changed.