26. jan. 2011

Gratis E-bøger

Der er jo så moderne at have en smartphone eller en iPad og dermed have muligheden for at læse elektroniske bøger, imens man er på farten.

Her er nogle steder, hvor du kan hente gratis E-bøger.

Her kan du blandt andet finde gratis bøger om java- og .net-certificeringer.

Her findes danske bøger.
Ingen registrering og gratis download.

Gratis danske bøger.

BookBooN.com tilbyder gratis e-bøger til studerende, rejsende og erhvervsfolk i PDF format. Ingen registrering nødvendig. Alle bøger er lovlige og skrevet eksklusivt til BookBooN.com. De er financieret af få reklamer i bøgerne.

Skal registrere sig, og man kan gratis downloade 5 bøger om måneden.

Gratis og kræver ingen registrering.

Gratis danske bøger.

Lige til at downloade...

Online bøger. Ingen registrering nødvendig.

Skal registrere sig.


Online bøger. Ingen registrering nødvendig.

20. dec. 2010

Tips til julerengøring

Rengøringstips:
Hvis du har et rodet hjem, skal du gøre følgende:
  1. Opret en ny mappe på din computer.
  2. Navngiv mappen "rod i huset."
  3. Gå hen og tage et glas vin
  4. Højreklik for at slette mappen.
  5. Computeren vil derefter spørge:
  6. "Vil du fjerne rod i huset permanent?"
  7. Klik på JA - knappen.
  8. Placer dine fødder på bordet, drik din vin og bare nyd;)

20. sep. 2010

JavaOne i San Francisco

Så er JavaOne i San Francisco startet, og jeg er så heldig at firmaet har sendt mig herover.

Vi er 41.000 deltagere i år, fra 136 lande (skulle være 59 % af alle lande).

I går holdt Larry Ellison, direktør fra Oracle holdt blandt andet en Keynote, hvor han bare forsøgte at sælge en ny server - gaaaaab.
Før det, holdt HP en salgstale - lige så meget gab!
Keynoten skulle vare 2 timer, men da der var gået 2½ time og good old Larry stadigvæk ikke var færdig, gik jeg :-)

Tilgengæld deltog jeg i en diskussionsgruppe under Java User Group, hvor man bl.a. talte om Concurrency og hvad ville du gøre hvis du kunne bestemme over Java? (Tilføje Clojure eller Aspects?)

Se mere her: http://www.oracle.com/javaonedevelop/index.html

12. nov. 2009

DecimalFormat and rounding off

Why does DecimalFormat round off wrong?


I have this nice method that can format a double.
You may also specify the number of decimals.

public static String formatNumber(double number, int decimals) {
String pattern = "###,##0";
if (decimals > 0) {
pattern += "." ;
// Add the wanted number of decimals to the pattern
for (int i = 0; i < decimals; i++) {
pattern += "0";
}
}

// Get the English version of the decimalformatter
DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(
Locale.ENGLISH);
df.applyPattern(pattern);

return df.format(number);
}


Now I want to run it:

public static void main(String[] args) {
testNumber(1.5, 0, "2");
testNumber(2.5, 0, "3");
testNumber(2.15, 1, "2.2");
testNumber(2.25, 1, "2.3");
}
public static void testNumber(double number, int decimals,
String expected) {
String formatted = formatNumber(number, decimals);
System.out.print("Testing " + number + ", decimals " +
decimals + ", Actual = " + formatted);
if (formatted.equals(expected)) {
System.out.println(" Expected = " + expected);
} else {
System.out.println(" Expected = " + expected +
" <- Not the same!");
}
}


The outcome is:

Testing 1.5, decimals 0, Actual = 2 Expected = 2
Testing 2.5, decimals 0, Actual = 2 Expected = 3 <- Not the same!
Testing 2.15, decimals 1, Actual = 2.2 Expected = 2.2
Testing 2.25, decimals 1, Actual = 2.2 Expected = 2.3 <- Not the same!


What???
It looks like it rounds off completely randomly.
If you look closer to the documentation, you'll find that DecimalFormat uses ROUND_HALF_EVEN.
This means that "Rounding mode to round towards the 'nearest neighbor' unless both neighbors are equidistant, in which case, round towards the even neighbor. "

But I don't want that, I want it to round up where the fraction is >= 0.5, which is ROUND_HALF_UP, but it seems that you can't change the way DecimalFormat is rounding off, so I've found a way to do it.

If you move the fraction, so the rounding off allways is at the first decimal, you can use Math.round which uses ROUND_HALF_UP, and then set back the correct position for the fraction.

Something like:

double pow = Math.pow(10, decimals);
double numberPowed = number * pow;
number = Math.round(numberPowed) / pow;


Now we can format it using DecimalFormat

But we're not yet homefree, because Math.round is returning a Long, which can't hold big numbers like doubles, so we can only do this trick if the number don't get too big!

The complete method now looks like this:

public static String formatNumber(double number, int decimals) {
double pow = Math.pow(10, decimals);
double numberPowed = number * pow;
// Only do it if the number is not too big
// Math.round returns the neastest Long, so it must fit
// inside a long
if (numberPowed < Long.MAX_VALUE) {
number = Math.round(numberPowed) / pow;
}

String pattern = "###,##0";
if (decimals > 0) {
pattern += "." ;
// Add the wanted number of decimals to the pattern
for (int i = 0; i < decimals; i++) {
pattern += "0";
}
}

// Get the English version of the decimalformatter
DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(
Locale.ENGLISH);
df.applyPattern(pattern);

return df.format(number);
}


And we'll get the right outcome:

Testing 1.5, decimals 0, Actual = 2 Expected = 2
Testing 2.5, decimals 0, Actual = 3 Expected = 3
Testing 2.15, decimals 1, Actual = 2.2 Expected = 2.2
Testing 2.25, decimals 1, Actual = 2.3 Expected = 2.3

14. aug. 2009

Two convicted in U.K. for refusal to decrypt data

Two convicted in U.K. for refusal to decrypt data

What will come next?
That you must reveal your banking password?

It seems that the authorities want to look in your diary.

I think it should not be possible to force people to reveal such stuff.

It's fine, that the authorities can get a court-order to see your financial transactions.

25. jun. 2009

27. apr. 2009

28. feb. 2009

Set the default printer using command shell

I want to set my default printer using a command shell, can it be done?


Yes...

Running "RUNDLL32 PRINTUI.DLL,PrintUIEntry /?" gives you a list of what you can do, and this help you set the default printer:
RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "hp psc 1200 series"

See: Usage and examples

26. feb. 2009

Pragtfuldt 1-plans rækkehus med god beliggenhed i Ishøj



Pragtfuldt 1-plans rækkehus med god beliggenhed i Ishøj
Den perfekte bolig hvad enten man er ung eller gammel!


Står du og mangler et rækkehus i Ishøj eller kender du nogen der gør, så er dette rækkehus perfekt...

BEMÆRK:
Åbent hus søndag d. 01.03.2009 kl. 13.00 - 13.30,
Bøgelunden 57
2635 Ishøj


Se flere billeder og yderligere oplysninger: Danbolig

7. nov. 2008

Understanding your visitors

Original post

Why are people leaving your site?


For instance, you can use Google Analytics for tracking where people clicked.

28. jun. 2008

Disable Windows XP stamping reading files

Whenever XP reads a file, it stamps the file with the date and time of the access. This feature has its place but is not required for normal use unless you rely on the date of last access for backup purposes, which is a rare requirement for most backups. Putting a timestamp a file that has just been read means that a write access has to be made to disk, so every time a read is executed, a corresponding write is also executed.

At the command prompt, enter the following then reboot;

FSUTIL behavior set disablelastaccess 1

Those of us who read and write English need to take note of the American spelling of the BEHAVIOR parameter.

To turn timestamps back on, repeat the command but replace the 1 with 0.


25. jun. 2008

Reduce Windows shutdown time

To reduce the timeout Windows XP has for unfinished programs, you may edit it in the registry in milliseconds at the location: HKEY_CURRENT_USER\Control Panel\Desktop editing the value WaitToKillAppTimeout.

Ny blog - Fototips

Jeg har oprettet en ny blog som skal handle om fotografering og billedmanipulation.

Se den her: http://fustphoto.blogspot.com