Jason’s Ranting & Raving

Those who don’t read have no advantage over those who can’t.

Archive for April, 2009

Hard Work = Success

Posted by jaystile on April 29, 2009

There is one lesson that everyone needs to know: Hard work leads to success. This should be the mantra for school aged children (and for adults too). It is a theme that has repeatedly demonstrated itself in the real world.

My sister-in-law who is attending college recently revealed that she was surprised at how well she did in school when she studied hard. Not studying just enough to get by, but really studying and learning the material and being interested.

My daughter can read at 4.5 years old. This was the result of 6 months of reading lessons (see my book review Teach Your Child to Read in 100 Easy Lessons) that was hard on both her and Dad. But she now has a huge head start against her peers which may lead to more success.

There have been numerous studies concerning experts which I tend to categorize as expert theory. Malcolm Gladwell wrote an entire book on the subject. The summation is that it takes 10000 hours of practice and learning in a field to become an expert, whether that field is chess, chemistry, music, martial arts, etc.

Then I read an article on wired about a woman who has super memory! It turns out she is just a really hard worker. But this work is attributed to OCD (obsessive compulsive disorder) because she keeps rigorous notes of her life and reviews them often. Which also happens to be the driving force behind Super Memo (Want to remember forever?)!

I’ve been looking for a source for a quote (and google hasn’t helped) can you help me find it? Paraphrased as “There is no such thing as genius, only interest. Now, if I was only interested in something.

Posted in Cool Stuff, Parenting | Tagged: , , , , , | Leave a Comment »

The Joy of Parenting: An Early Snow

Posted by jaystile on April 19, 2009

A bugs life.

A bug's life.

It was November and the first snow of 2008 had arrived. At 7am before I am even finished getting ready for work my daughters are already dressed in their snowsuits and outside. As I am enjoying the sight of the freshly fallen snow and the joy on my daughters faces, my youngest (2yrs) picks up a chunk of snow and throws it in her sisters face and yells “YOU FIRED! HA HA HA!”

Posted in Funny, Parenting | Tagged: , , , | Leave a Comment »

The Joy of Parenting: The Ball Pit (Dad’s Point of View)

Posted by jaystile on April 18, 2009

I took my family to the Greek Festival at the local Greek church. It’s a great time. There is lots of dancing in traditional dress. We had a craving for some gyros and saganaki a.ka. flaming cheese. We enjoyed our food while the hot Colorado sun tried to burn our skin. Let’s hear it for the SPF 45. They also had entertainment for the kids. A bunch of little carnival rides and such. My oldest daughter was 3 at the time her only option was the ball pit. She went in and we can hear her screaming with delight. I seen a ball come bouncing out of the tent. There was an under dressed attractive carny girl with crooked teeth who bent over way to far to pick up the ball and toss it back in. I was thinking to myself, she couldn’t be more than 16 and she shouldn’t be wearing clothes that are so revealing. Another ball comes bouncing out. She bends over right in front of me and I try not to stare (lest my wife catch my eye). But I could see her belly button from between her cleavage. Another ball come flying out and she bends at the hips the other way and 4 inches of white lace thong and rear end is revealed. One or two balls usually pop out but now too many are coming out and the carny girl peaks into the pit and yells at the kids not to throw the balls out. From my vantage point I can see my daughter against the far wall and as soon as the carny turns her back she lobs another ball out the opening and laughs. Dad doesn’t say ‘No, Honey, don’t throw the balls!’ He gets to view another couple of inappropriate bends thanks to carny girl before she ends the ‘ride’ early and kicks the kids out. That was worth the $4 for my daughter to play in the ball pit for 5 minutes.

Posted in Funny, Parenting | Tagged: , , , | Leave a Comment »

Book Review: Teach Your Child to Read in 100 Easy Lessons

Posted by jaystile on April 13, 2009

My daughter and I have finished working through ‘Teach Your Child to Read in 100 Easy Lessons’ by Siegfried Engelmann, Phyllis Haddox, and Elaine Brune. The book delivers on it’s promise.

We started lessons with my daughter when she turned 4 years old. The book gives step by step instructions to the adult for teaching. It introduces the concepts and skills at a descent rate while reinforcing skills that were learned in earlier modules. The child starts by learning sounds and rhyming and then practicing writing the letters. The characters are ‘sounds’, so you don’t bother to teach them the letter names. This book uses a custom orthography to represent long versus short vowel sounds, also, they are used for the different diphthongs like ‘sh’, ‘ch’, ‘th’, so the child only has to learn one character for one sound. These custom characters are removed from the reading gradually in the lessons. The book also works on reading comprehension by having the adult ask questions about what the child has just read.

The book has some detractions. I noticed a few mistakes in the orthography where they would not use their customer characters. The subtext on the cover says ‘In only 20 minutes a day, this remarkable step-by-step program teaches your child to read…’. Yeah, that’s bullshit. Like every parent I think I have the smartest child in the world and it usually took between 40 minutes to an hour. Maybe if your child is in 1st grade and has already experienced reading and learning to read it might be that short. The first couple of lessons took 20 minutes. Also, this book comes with demands once you start you need to have a lesson at least every other day otherwise the child starts reverting and has trouble with the skills. Also there is stress added to the parent and child because the work is hard and it takes a long time. Sometimes the child just doesn’t want to go through it. But the hard work is worth it. The preschool teachers are amazed when she reads a book she hasn’t seen before. She also writes letters to her teachers, grandma, and friends. There are traces of the custom orthography in her writing and it’s cute. I think we haven given her a great head start. I LOVE TO HEAR HER READ!

So in the end it took us about 6 months to finish the program. Now, I’m taking time to recharge my batteries before I start the lessons with her little sister. She’ll be 3 soon and I don’t want to rush it, but she acts like she is ready.

Posted in Book Review, Parenting | Tagged: , , , | 1 Comment »

Bad Science – Autism, Vaccinations and Jenny McCarthy

Posted by jaystile on April 4, 2009

I support skepticism. But I do not support skepticism when it is confronted with a mountain of contrary evidence. (e.g. global warming deniers) I also don’t appreciate people getting undo media attention because they are famous for something that has nothing to do with skill or talent. Especially, when their message reaches so many people are limited in their understanding of the scientific method and scientific evidence.

People who stop vaccinating their kids cause a danger to the population and to their offspring. There are no statisical links between autism and vaccinations. I’m sorry people have autistic children. They really need our support, but lashing out at vaccinations is only hurting not helping. Follow the link to see the body count.

http://www.jennymccarthybodycount.com/Jenny_McCarthy_Body_Count/Home.html When I wrote this post the number of preventable cases was 720 and the number of lives lost was 142.

In June 2007 Jenny McCarthy began promoting anti-vaccination rhetoric. Because of her celebrity status she has appeared on several television shows and has published multiple books advising parents not to vaccinate their children. This has led to a dramatic increase in the number of vaccine preventable illnesses as well as an increase in the number of vaccine preventable deaths.

Posted in Outrage | Tagged: , , | Leave a Comment »

Postgres 8.3, JDBC, JPA, and Hibernate example setup.

Posted by jaystile on April 1, 2009

I wanted to access my local postgresql database with JDBC and JPA in the J2SE environment. Refer to my previous post about setting up Postgres 8.3 on Ubuntu 8.04.

If you can’t tell, I’m using java. I’m compiling to java 5. I’m building my project with maven. Inside of a larger maven project which creates my ear file, I created a test project ‘runner’. This creates a jar.

<project> <modelVersion>4.0.0</modelVersion> <groupId>org.myproject</groupId> <artifactId>runner</artifactId> <packaging>jar</packaging> <name>JAR Runner</name> <version>1.0</version> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </pluginManagement> </build> <dependencies> <dependency> <groupId>org.myproject</groupId> <artifactId>util</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>postgresql</groupId> <artifactId>postgresql</artifactId> <version>8.3-603.jdbc4</version> </dependency> <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>ejb3-persistence</artifactId> <version>1.0.2.GA</version> </dependency> <dependency> <!-- Note this added other dependencies - hibernate-commons-annotations-3.1.0.GA.jar - slf4j-api.1.4.2.jar - exclude this because it is bunk and causes exceptions. - hibernate-annotations-3.4.0.GA.jar - antlr-2.7.6.jar - commons-collections-3.1.jar - dom4j-1.6.1.jar - xml-apis-1.0.b2.jar - jta-1.1.jar - javassit-3.4.GA.jar --> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager </artifactId> <version>3.4.0.GA</version> <exclusions> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </exclusions> </dependency> <!-- The org.slf4j needed to be included because the one included in org.hibernate.ejb3-persistence did not work --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.5.6</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.5.6</version> </dependency> </dependencies> </project>

runner/src/main/resources/META-INF/persistence.xml file
The core of JPA uses the persistence.xml file to set up the database and entity mappings. I tried using Sun’s example but I found it to hard to configure. I know that hibernate provides a JPA implementation so I used that instead of the glassfish example. It was easy to add because it exists in the maven 2 repository. This persistence.xml is configured to talk to the postgresql 8.3 database. It also contains a mapping for my Entity.

<?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="pu1" transaction-type="RESOURCE_LOCAL"> <class>org.myproject.runner.MapEntity</class> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/> <!-- <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/> --> <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/> <property name="hibernate.connection.username" value="myuser"/> <property name="hibernate.connection.password" value="mypassword"/> <property name="hibernate.connection.url" value="jdbc:postgresql://localhost/mydb"/> <property name="hibernate.max_fetch_depth" value="3"/> <!-- cache configuration --> <!-- This was blowing up -v <property name="hibernate.ejb.classcache.org.hibernate.ejb.test.Item" value="read-write"/> <property name="hibernate.ejb.collectioncache.org.hibernate.ejb.test.Item.distributors" value="read-write, RegionName"/> --> <!-- alternatively to <class> and <property> declarations, you can use a regular hibernate.cfg.xml file --> <!-- property name="hibernate.ejb.cfgfile" value="/org/hibernate/ejb/test/hibernate.cfg.xml"/ --> </properties> </persistence-unit> </persistence>

Our database is populated by some sql.

create table map ( pk_id int unique primary key, width int, height int, name varchar(256), last_updated timestamp ); GRANT ALL ON map TO PUBLIC; INSERT INTO map (pk_id, width, height, name, last_updated) VALUES (1, 100, 200, 'test_map', CURRENT_TIMESTAMP);

Next, we have an entity to use against our database. It only maps one field, but this was just for testing purposes.

package org.myproject.runner; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name="MAP") public class MapEntity { private long id; @Id @Column(name="PK_ID") public long getId() { return id; } public void setId(long id) { this.id = id; } }

Finally, we have a java class that can call the database via JDBC or JPA

package org.myproject.runner; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; public class DatabaseAccess { /**
  • @param args
  • /
public static void main(String[] args) { testJdbc(); testJpa(); } public static void testJdbc() { String url = "jdbc:postgresql://localhost/mydb"; Properties props = new Properties(); props.setProperty("user","myuser"); props.setProperty("password","mypassword"); Connection conn = null; try { conn = DriverManager.getConnection(url, props); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("select * from map"); while(rs.next()) { long id = rs.getLong(1); System.out.println("ID:" + id); } } catch (SQLException e) { e.printStackTrace(); } finally { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } public static void testJpa() { // Use persistence.xml configuration EntityManagerFactory emf = Persistence.createEntityManagerFactory("pu1"); EntityManager em = emf.createEntityManager(); // Retrieve an application managed entity manager // Work with the EM MapEntity map = new MapEntity(); map.setId(5); EntityTransaction transaction = em.getTransaction(); transaction.begin(); em.persist(map); transaction.commit(); em.close(); emf.close(); //close at application end // Create EntityManagerFactory for persistent unit named "pu1" // to be used in this test } }

Posted in Programming | Tagged: , | 4 Comments »