Friday, February 26, 2010

Vinyl Stained By Rubber

Closures in JavaScript

After I have examples of closures (function accounts) in Scala and JavaFX had imagined, let's look the same example in JavaScript (ECMAScript ) to:
 / / closures.js 

zaehlerMitStartwert function (start value) {
return function () {return
starting value + +
}}


next1 = zaehlerMitStartwert (10)
next2 = zaehlerMitStartwert (20)

document.writeln (next1 ( ) document.writeln) / / 10
(next2 document.writeln ()) / / 20
(next2 document.writeln ()) / / 21
(next1 ()) / / 11

Much more can be found to really to say except that it
  1. really is that simple (which can also lead to problems )
  2. since the first versions of JavaScript (and thus For over 10 years) is available and
  3. unlike JavaFX Script is dynamically typed, and Scala, also no additional local variable is needed because of the transfer parameters already starting value is a modifiable variable. Both are evaluated in terms of stable, maintainable software is not necessarily positive.
Many modern JavaScript libraries make heavy use of such a function literals and closures, such as jQuery .

Tuesday, February 16, 2010

Things To Write On A Guestbook For Wedding

Hibernate / JPA, hashCode () and Eclipse

entities in Hibernate / JPA often have a synthetic (technical) primary key, which is implemented in the following example as Long id . If There are no additional technical key candidates, you have the hashCode () method for Hibernate / JPA to implement so that it works exclusively with this id. (There are at hibernate.org a long discussion on this issue because "officially" proposed variation, "semi-unique" fields to use in practice often makes more problems than the ID variant.)

This one hashCode () (equals and that the obligatory accompanying () ) do not write again and again by hand, Eclipse offers over Source> Generate hashCode () and equals () the possibility that the two to generate methods with selectable attributes. An example entity might look like this: @ Entity
 
public class Record {@ Id @

GeneratedValue
private Long id;

/ / other fields, getters, setters, equals (), etc. ...

/ ** *
generated from Eclipse 3.5.
* / @ Override

public int hashCode () {final int prime = 31
;
int result = 1;
result = prime * result +
((id == null) 0 : id?. hashCode ());
return result;}

}
in itself returns the hash value calculation using primes a good spread, and attends the automatically generated code and that may be the Id zero - that is not stored in the database (persisted) objects.

Now we test this entity class:
 @ Test public void 
testAddToHashSet () {

set = new HashSet \u0026lt;Datensatz> quantitative \u0026lt;Datensatz> ();

record ds1 = new Record ();
record ds2 = new Record ();

assertTrue ("Quantity should be empty," menge.isEmpty ());

menge.add (ds1);

assertTrue ("Quantity should have an element "
menge.size () == 1);
/ / ok

menge.add (ds2);

assertTrue (" Quantity should have two elements, "
menge.size () == 2);?!
/ / still first .. Ups
}
Whenever one associations in the object model built before the records are stored (eg in case of unit tests as in the example above), occurs The above scenario. We have two objects that both have no Id ( = null ). But there are still two non-identical objects in separate memory areas corresponding to the persistence of two records with different generating primary keys (IDs) would. Unfortunately, the HashSet remember only one of the two objects - and the persistence of an association Sun would lose one of the objects!

An adaptation of the generated hashCode () method is very simple. Place at a non-existing ID number to use 0 for the hash calculation, we take the hash value of the property, which is different for non-identical objects in most cases:
 @ Override 
public int hashCode () {
final int prime = 31;
int result = 1;
result = prime * result +
((id == null) ? super.hashCode () : id.hashCode ());
return result;}

A similar implementation I've been using for years without problems, so I think this is the most viable option for a flat rate. In some cases, of course, more specific implementations may be more appropriate.

Saturday, February 13, 2010

Getting Bonded In Ontario







ALEXANDRA G. KISS ALEXANDRA G., 46X46cm, oil, wood, 2010

Happened 360 Gamesaves






FRIENDS, 24x30 cm, oil lines, 2010

Wednesday, February 3, 2010

Community Service Letters Recommendation

HTML with CSS Accesskey represent

with the standard HTML attribute accesskey allows keyboard shortcuts (shortcuts) to define with whom you can set the input focus to the associated input elements:
 \u0026lt;label for = "last_name"  accesskey = " n "> Name: \u0026lt;/ label> 
\u0026lt;input id = "last_name" type = "text">
Which key combination is set, the focus is browser-and system-dependent. The above code to enable the IE / Win with Alt + N, in Firefox / Win with Shift + Alt + N, in Firefox / Mac, Ctrl + N, in Safari / Mac, Ctrl + Alt + N. ..

course, one should also show the user that keyboard shortcuts are available. Man, this information can still write once statically in the HTML source code (in addition to accesskey attribute). With a simple CSS2 rule, but can do without such redundant information and allow the shortcut label at all represent elements for which accesskey
 
label [accesskey]: after {
content: is set "[" attr (accesskey) "]";
text-transform: uppercase;
color: # 999999;
font-size: x-small;


} The CSS rule is based primarily on a single attribute selector and a pseudo-element . This is according to (: after ) each label element in which the accesskey attribute is present, the value of the attribute in upper case ( uppercase ) in the document content ( content ) added:



these techniques are On quite old, the appropriate standards were formally adopted years ago (the HTML 4.01 specification is more than 10 years, CSS 2 as well). What makes this issue again today?

Google recently announced , from 1 March this year, older browser versions and in particular the Internet Explorer 6 (IE6) to no longer support in its Web applications. This
- actually long overdue - step should also move to other suppliers, newer versions of IE (or alternatives such as Firefox ) assumed. And it could finally IE users of Web standards such as the attribute selectors That benefit the IE6 unfortunately ignored for years.