Виртуальная песочница (тм)

Thursday, August 21, 2008

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan Read more...

Number to month name


echo form_label('Month: ');
$options = array(
'0' => 'New',
'1' => 'January',
'2' => 'February',
'3' => 'March',
'4' => 'April',
'5' => 'May',
'6' => 'June',
'7' => 'July',
'8' => 'August',
'9' => 'September',
'10' => 'October',
'11' => 'November',
'12' => 'December',
'13' => 'I'm an idiot!',
);
Read more...

Wednesday, August 20, 2008

The March of Progress

1980: C

    printf("%10.2f", x);

1988: C++
   cout << setw(10) << setprecision(2) << showpoint << x;

1996: Java
   
java.text.NumberFormat formatter
= java.text.NumberFormat.getNumberInstance();
formatter.setMinimumFractionDigits(2);
formatter.setMaximumFractionDigits(2);
String s = formatter.format(x);
for (int i = s.length(); i < 10; i++) System.out.print(' ');
System.out.print(s);

2004: Java
   System.out.printf("%10.2f", x);


[Cay Horstmann's Home Page]

Read more...

Thursday, August 14, 2008

Encoding Recipe

Q: знатоки, подскажите, как из строки типа "Привет" получить "\u0441\u043b\u0443\u0445\u0438"?
A: на C это делается так:
if (str == "Привет") str = "\u0441\u043b\u0443\u0445\u0438"; Read more...

Tuesday, August 5, 2008

Transaction management and JPA

"My current project is a web application with Struts in the web tier, a stateless session EJB (EJB3) in the middle tier and various entity pojos (JPA) that model the data. The application server is JBoss 4.2.0.CR2 that uses Hibernate as the persistence provider.

In this configuration with container-managed transactions, the transaction boundary is the EJB method call. Struts action classes make calls to the session EJB methods in order to retrieve data for display in various JSPs. The problem is that after the EJB method returns, the transaction is over, the persistence context has ended and the POJOs returned are detached. If the JSP that displays the data tries to access any lazily loaded associations an exception occurs."

Read more...

At least we all understand each other on Wednesday

http://www.unbound.ru/pict/cows.gif Read more...

Friday, August 1, 2008

"Довольный, как слон после купания"

Когда я говорю сабж, я имею в виду примерно следующее:
69,15 КБ Read more...