Tuesday, September 4, 2012

Windows Firewall from the command line

netsh firewall show state

netsh firewall set opmode mode=DISABLE

netsh firewall set opmode mode=ENABLE exceptions=DISABLE

netsh firewall set opmode mode=ENABLE exceptions=ENABLE

More about it: http://support.microsoft.com/kb/947709

Tuesday, August 28, 2012

Windows uptime


1.  Go to "Start" -> "Run".

2.  Write "CMD" and press on "Enter" key.

3.  Write the command "net statistics server" and press on "Enter" key.

4.  The line that start with "Statistics since …" provides the time that the server was up from.

The command "net stats srv" can be use instead.

Taken from: http://support.microsoft.com/kb/555737

Other possibility: the command systeminfo

And another: net statistics workstation.

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.