Pure goodness, right up there with PEP-8 and PEP-20.
Back to flipping out...
The Home for People Who Like to Flip Out and Write Code
Posted by
Hank Gay
at
11:50
View Comments
Labels: python, sneak_attack
Low. Bush league.Disgraceful. The Atlanta Braves have opted to let John Smoltz go to the Red Sox. The face of the franchise, a man who altered his career multiple times to help the team, who took hometown discounts, and who pitched through pain to help them win, has gone to another team because the organization didn't think he was worth a $5.5 million flyer. This from the same organization that just made a contract offer to Mike Hampton! John Smoltz deserved better; he earned better. As an organization that has always prided itself on doing things The Right Way™, the Braves should be better. I can't remember ever being ashamed of the Braves in my entire life… until now.
We now return you to your regularly (or not) scheduled programming blog updates.
Posted by
Hank Gay
at
07:50
View Comments
Labels: non-programming
Back to flipping out...
Posted by
Hank Gay
at
04:52
View Comments
Labels: sneak_attack
R is seriously cool. Unfortunately for me, I only use it about once a year, so I can never remember how to do anything; hence the cheatsheet.
users_usergroups <- read.csv(file="dev/users-per-group.csv", sep=",", head=TRUE)
boxplot(users_usergroups$NUM_OF_USERS)
hist(users_usergroups$NUM_OF_USERS)
Back to flipping out...
Posted by
Hank Gay
at
16:28
View Comments
Labels: R, statistics
The Zen of Python teaches us Explicit is better than implicit.
BDFL GvR made variable declarations implicit.
Back to flipping out...
Posted by
Hank Gay
at
21:00
View Comments
Labels: python
Flexjson has been good to me, but every once in a while it jumps up and surprises me. Here's an example.
abstract class AbstractFoo {
private Float a = 1.1f;
private Float b = 2.2f;
private Float c = 3.3f;
public Float getA() {
return a;
}
public Float getB() {
return b;
}
public Float getC() {
return c;
}
}
import flexjson.JSONSerializer;
public final class Foo extends AbstractFoo {
public static void main(final String[] args) {
final Foo myFoo = new Foo();
final JSONSerializer serializer = new JSONSerializer();
System.out.println(serializer.serialize(myFoo));
}
}
Can you guess what you're going to get when you compile this and run java Foo? If you guessed:
{"a":1.1,"b":2.2,"c":3.3,"class":"Foo"}
you were wrong. You really get:
Exception in thread "main" flexjson.JSONException: Error trying to serialize path: [ a ]
at flexjson.JSONSerializer$ObjectVisitor.bean(JSONSerializer.java:603)
at flexjson.JSONSerializer$ObjectVisitor.json(JSONSerializer.java:471)
at flexjson.JSONSerializer$ObjectVisitor.visit(JSONSerializer.java:435)
at flexjson.JSONSerializer.serialize(JSONSerializer.java:222)
at Foo.main(Foo.java:7)
Caused by: java.lang.IllegalAccessException: Class flexjson.JSONSerializer$ObjectVisitor can not access a member of class AbstractFoo with modifiers "public"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
at java.lang.reflect.Method.invoke(Method.java:578)
at flexjson.JSONSerializer$ObjectVisitor.bean(JSONSerializer.java:579)
... 4 more
It appears that Flexjson's serialization algorithm can't handle a package-visible, abstract super class. Changing it to public fixes the problem and you can continue on your merry way.
Back to flipping out...
Posted by
Hank Gay
at
13:15
View Comments
Labels: Java