Friday, July 6, 2012

How to Initialise a static Map in Java

private static final Map<String, String> channelTypes =
    new HashMap<String, String>();
static {
        channelTypes.put("I", "Incremental");
        channelTypes.put("N", "Instrument");
        channelTypes.put("S", "Snapshot");
}

private static final Map<String, String> channelTypes =
     new HashMap<String, String>() {
     {
                    put("I", "Incremental");
                    put("N", "Instrument");
                    put("S", "Snapshot");
      }
};

Friday, June 29, 2012

MP3 tagging with Perl


#!/usr/bin/perl

use strict;
use warnings;

use MP3::Tag;
use File::Basename;

my $Directory = ".";

while (<$Directory/*.mp3>) {
my ($FileName) = basename($_, '.mp3');

my $Mp3 = MP3::Tag->new($_);

$Mp3->title_set($FileName);
$Mp3->artist_set('Artist');
$Mp3->album_set('Album');
$Mp3->year_set('2012');

$Mp3->update_tags();

print "Filename: $_\n";
print "Artist: " . $Mp3->artist . "\n";
print "Title: " . $Mp3->title . "\n";
print "Album: " . $Mp3->album . "\n";
print "Year: " . $Mp3->year . "\n";
print "Genre: " . $Mp3->genre . "\n";

$Mp3->close();
}

__END__

Friday, June 8, 2012

How do I add the Bloomberg Excel Add-in to Excel?

  1. Open Excel
  2. Go to Tools menu
  3. Select Addins, then Browse
  4. Select: C:\blp\API\Office Tools\BloombergUI.xla
  5. After selecting the add-in the Bloomberg Excel tools should appear checked in your add-ins list. Close the add-ins and the toolbar should appear.

Thursday, May 24, 2012

Five Fridays in July every 823 years == false


package pkg5fridaysinjuly;

import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {

    private static final int NUMBER_OF_YEARS = 823;

    public static void main(String[] args) {

        Calendar c = new GregorianCalendar();

        int firstYear = c.get(Calendar.YEAR);
        int lastYear = firstYear - NUMBER_OF_YEARS;

        c.set(firstYear, Calendar.JULY, 1);

        System.out.println("Initial: " + firstYear);
        System.out.println("Last: " + lastYear);

        for (int y = firstYear; y >= lastYear; y--) {

            c.set(y, Calendar.JULY, 1);

            if (c.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY) {

                System.out.println(y + " Found!");
            }
        }
    }
}

Wednesday, April 25, 2012

Configuring Logging in Glassfish

Calls to System.out.println are logged at the INFO level using the logger name javax.enterprise.system.stream.out. Calls to System.err.println are logged at the WARNING level using the logger name javax.enterprise.system.stream.err. To turn off the logs from these sources, specify the logger name with the value OFF in the Additional Properties area.


Friday, April 20, 2012

The World's Greatest Solvable Problem


The price tag for solving hunger is also less than you may realise:

- US 20 cents: the cost of one super-healthy ration of Plumpy’Sup for a small child, less than the cost of a US postage stamp
- US $10: the costs to feed a boy in a Kenya refugee camp for 3 weeks, less than the cost of a lipstick bought in Manhattan
- US $50: the cost to feed a schoolgirl for one year, roughly the same price for an iPod shuffle
Taken from freerice.com site.

Monday, April 16, 2012

We Animals pictures

Stray dog in Santiago, Chile. I visited this market several times and the dog was always in the same place, lying in his box. 2005.
Taken from: http://www.weanimals.org/photographs.php