Snippet

Find the Calling Class

Here is a simple snippet to find out the calling Java Class.

Class.forName(new Throwable().getStackTrace()[2].getClassName()));

Compute size of Mysql database with it's tables

Basically a database is a collection of tables.
So the size of the database is sum total of size of its individual tables.
Size of the table = Size of its Data + Size of its Indexes.
Size of database = Sum of {Individual Table Size}
The following snippet uses that above logic to compute the overall size of the database by computing the size of its individual tables.

Recursively Convert Gif Images To Jpg

Converting images from gif to jpg for web or other reason can be done easily using the ImageIO package. The following snippet convert all the gif images in directory rootDir to jpg images.Compile this class and execute using java command line. This utility class is also available as part of the Livrona Tools Project.The following is the code for the Image Converter.

 

Clean up Rail Sessions

By default rails does not clear out stale sessions from the session store. Depending on the configuration session can be stored in the local file system or the database.

Retrieve Page Contents via Http Get

This script retrieves the content of url and dumps it to the output

Example copy this script into file named : get_page.rb

#!/usr/bin/ruby
require 'net/http'
host,port,url = ARGV
http = Net::HTTP.new(host, port)
STDERR.puts "url {#url}"
response, data = http.get(url)
puts data

Usage

ruby get_page.rb <host> <port> <url>

The url is specified as a relative path

Syndicate content

Back to top