Skip to content

Instantly share code, notes, and snippets.

@huljas
huljas / animation-part-1.js
Created October 15, 2011 22:03
My very first animation with canvas
var ctx;
var canvasObj;
var fps = 30;
var stars = [];
var starCount = 30;
var Animation = {
init : function(id) {
canvasObj = document.getElementById(id);
@huljas
huljas / StringFormatTest.java
Created August 3, 2011 13:24
Most common formats for String.format(..)
import org.junit.Test;
import java.util.Date;
import static org.junit.Assert.assertEquals;
public class StringFormatTest {
@Test public void basicInteger() {
assertEquals("123456", String.format("%d", 123456));
}
@huljas
huljas / applicationContext.xml
Created May 5, 2011 05:29
Reading properties from a path defined in system property with a default value.
<?xml version="1.0" encoding="UTF-8"?>
<beans>
<bean id="applicationConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:app-dev.properties</value>
<value>${app.properties}</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
-- new table for simple entity
create table SimpleEntity (
id bigint not null auto_increment,
age integer not null,
isEternal bit not null,
name varchar(255),
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@huljas
huljas / PrintSchemaUpdate.java
Created February 12, 2011 19:45
Example on how you could use Hibernate schema update when creating database migrations for play applications.
package play.modules.migrate;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
import play.Play;
import play.db.DB;
import play.db.DBPlugin;
import play.utils.Utils;