Restarting sequence columns in db2
It's a quickie this time. I figured i'd just make a note of how to update/restart a sequence column in db2, because it's something I use on a semi regular basis, and the syntax is ever so slightly odd. Here is how it should be done:
alter table card_transaction alter card_transaction_id restart with 923845384
- antony 18-09-2008 at 04:12AM
Allowing JDBC to access DB2 on Ubuntu Linux
One of the problems with installing the db2exc deb on Linux is that by default, it doesn't allow external (including local JDBC) connections. The way to enable this functionality is quite simple, as documented by tldp.org First, edit /etc/services
db2c_db2inst1 50001/tcp # IBM DB2 instance - db2inst1
db2 update dbm cfg using SVCENAME db2c_db2inst1 db2set DB2COMM=tcpip db2stop db2start
ibm-db2 523/tcp # IBM DB2 DAS ibm-db2 523/udp # IBM DB2 DAS
db2admin stop db2admin start
- antony 19-06-2008 at 02:24AM
Running tapestry on alternate ports
I found that it was an unneccessarily difficult task to run Tapestry T5 on a webserver which didn't run on ports 80/443, considering it's a very common requirement, and that it really should be a simple bit of xml configuration. It's a pain because the first thing that happens is that links which hit secure pages don't point to the correct port. After a long search, I found the following contribution could be placed in the project's AppModule.java to (unfortunately) hard-code some new port and url values for Tapestry to build URLs from
public void contributeAlias(Configuration<AliasContribution> configuration) {
BaseURLSource source = new BaseURLSource() {
public String getBaseURL(boolean secure) {
String protocol = secure ? "https" : "http";
int port = secure ? JettyRunner.DEFAULT_SECURE_PORT : JettyRunner.DEFAULT_PORT;
String url = "localhost";
return String.format("%s://"+url+":%d", protocol, port);
}
};
configuration.add(AliasContribution.create(BaseURLSource.class, source));
}
- antony 18-06-2008 at 08:37AM
sql-maven-plugin and random build order
I've been using codehaus' sql-maven plugin recently for rebuilding my project's database. I love it to bits, but I noticed something weird going on. I have two sets of patches, one for staging test-data, and one for the schema itself. I specify them as follows in my pom.xml
<includes> <include>buildup/*.sql</include> <include>patches/*.sql</include> </includes>
<orderFiles>descending</orderFiles>
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>sql-maven-plugin</artifactId> ... </plugin>
- antony 17-06-2008 at 02:58PM
.local domains not working on Ubuntu?
One of the first things I do when I install ubuntu at work is disable avahi-daemon. Why? For some reason, avahi-daemon takes over the .local domain and internal domains/servers simply wont resolve. I recommend (if you have .local domains) at your workplace or home:
sudo /etc/init.d/avahi-daemon stop
- antony 17-06-2008 at 02:56PM
Abstractions with JAXB
One of the less obvious things about Java's JAXB is that it is, by default (and by the virtue of the way java works) unable to intelligently map subclasses, interfaces, and abstractions. Let's say I'm trying to create an XML document which starts like this (it's for the Bibit payment provider, actually):
<paymentDetails>
<VISA-SSL>
...
<paymentDetails />
@XmlRootElement
@XmlSeeAlso({SoloGbSslPaymentDetails.class,
ElvSslPaymentDetails.class, VisaSslPaymentDetails.class})
public class PaymentDetails {
<paymentDetails> <VISA-SSL> <...
- antony 26-03-2008 at 02:51AM
Enabling SSL support on embedded Jetty
Considering Jetty, Maven, and SSL are all mature technologies, which need to be integrated often and by many people, there is a surprising lack of documentation online about how to enable SSL in the Maven2 Jetty plugin. Needless to say after a fair bit of google searching, I found the answer, and thought it best to document my findings here. First of all you need to create the certificate. There is a lot of complexity to this, as is very well documented at http://docs.codehaus.org/display/JETTY/How+to+configure+SSL#HowtoconfigureSSL-step4 however for my needs (development), only steps one and two are neccessary. I will replicate them here. First of all, run keytool to generate your certificate, keytool is provided by the JDK
keytool -keystore keystore -alias jetty -genkey -keyalg RSA
keytool -keystore keystore -alias jetty -genkey -keyalg RSA
Enter keystore password: password
What is your first and last name?
[Unknown]: jetty.mortbay.org
What is the name of your organizational unit?
[Unknown]: Jetty
What is the name of your organization?
[Unknown]: Mort Bay Consulting Pty. Ltd.
What is the name of your City or Locality?
[Unknown]:
What is the name of your State or Province?
[Unknown]:
What is the two-letter country code for this unit?
[Unknown]:
Is CN=jetty.mortbay.org, OU=Jetty, O=Mort Bay Consulting Pty. Ltd.,
L=Unknown, ST=Unknown, C=Unknown correct?
[no]: yes
Enter key password for <jetty>
(RETURN if same as keystore password): password
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
<connector implementation="org.mortbay.jetty.security.SslSocketConnector">
<port>4080</port>
<maxIdleTime>30000</maxIdleTime>
<keystore>/etc/keystore</keystore>
<password>password</password>
<keyPassword>password</keyPassword>
<truststore>/etc/keystore</truststore>
<trustPassword>password</trustPassword>
<excludeCipherSuites>
<excludeCipherSuite>SSL_RSA_WITH_3DES_EDE_CBC_SHA</excludeCipherSuite>
<excludeCipherSuite>SSL_DHE_RSA_WITH_DES_CBC_SHA</excludeCipherSuite>
<excludeCipherSuite>SSL_DHE_DSS_WITH_DES_CBC_SHA</excludeCipherSuite>
</excludeCipherSuites>
</connector>
</connectors>
- antony 07-03-2008 at 02:22AM
Genius EasyPen in Ubuntu Linux / Xorg 7
I've spent the last day or so playing with some old pen-tablets I found lying around the house. I got both of them working on an Ubuntu Linux 7.10 machine without any trouble whatsoever, but the serial-port based one needed a bit of manual intervention which I will document here. The Tevion/Medion/Aiptek USB tablet was plug and play, by the time i'd plugged it into the USB, Linux had loaded the kernel modules and was ready to go. The Genius EasyPen Serial, being a very legacy product, required some editing of my X configuration. To make it work in Xorg 7.x, add this code to xorg.conf
Section "Module" Load "summa" EndSection Section "InputDevice" Driver "summa" Identifier "EasyPen" Option "Device" "/dev/ttyS0" Option "InputFashion" "Tablet" Option "Mode" "Absolute" Option "Name" "EasyPen" Option "Compatible" "True" Option "Cursor" "Stylus" Option "Protocol" "Auto" Option "SendCoreEvents" "on" Option "Vendor" "GENIUS" EndSection
InputDevice "EasyPen" "SendCoreEvents"
aptitude install xserver-xorg-input-summa
gpm -t genitizer -m /dev/ttyS0
- antony 30-12-2007 at 09:11AM
Useful DB2 Command
If you want to allow user <user> to use explicit schemas. You wouldn't believe how hard this is to find on line.
grant IMPLICIT_SCHEMA on database to user <user>
- antony 18-12-2007 at 05:26AM
five years old
How many five year olds could you take in a fight?
<a href="http://www.justsayhi.com/bb/fight5" style="display: block; background: url(http://assets.justsayhi.com/badges/960/283/fight5.eyd544uuyz.jpg) no-repeat; width: 296px; height: 84px; font-family: Arial, sans-serif; font-size: 42px; color: #fff; text-decoration: none; text-align: center; padding-top: 145px;">23</a>
- antony 14-12-2007 at 02:56AM
branch the codelines
This piece of code approximates the inverse square root of a number. It was written during the making of Quake3. It's a very, very clever piece of code.
float InvSqrt (float x){
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i>>1);
x = *(float*)&i;
x = x*(1.5f - xhalf*x*x);
return x;
}
- antony 28-11-2007 at 03:08AM
about the breadline
I live to extravagance; and I spent all my money on expensive bread.
- antony 14-08-2007 at 08:26AM
encouraged transferral
"You don't know what it is to be a struggling author!", but by the very nature of my reply... I did.
- antony 01-08-2007 at 06:02AM
solitary confinement
Brings with it a wealth of ideas. The situation itself implies that such ideas cannot be logged nor brought to fruition. The situation is, therefore, not conducive to such thought.
- antony 30-07-2007 at 04:22PM
redesign
The web changes far too fast. I don't know why I'm trying to keep up but bam! Here's a new design.
- antony 30-07-2007 at 04:10PM