Odi's astoundingly incomplete notes
New entriesCode
back | nextUsing CVS in Eclipse and from the shell
When working with Eclipse against a CVS repository it is sometimes necessary to perform certain CVS operations on the command line. A simple example is creating a diff between arbitrary tags / dates or diffing by date on a branch. Even though the Eclipse help system has an explicit page about this problem, it only tells half the story.
There are two problems to solve:
1. Make Eclipse use the
By default Eclipse uses its proprietary
Now tell Eclipse to still use its built-in SSH client, open the Preferences dialog. Under Team > CVS > Ext Connection Method select Use another connection method type and select
2. Set the
Linux users will typically just include this in
Now you can use your CVS repository from Eclipse as well as from the command line.
There are two problems to solve:
1. Make Eclipse use the
ext
method.By default Eclipse uses its proprietary
extssh
method to connect to the repository, which command line CVS does not support. Go to the CVS Perspective, select the CVS location. Right-click and select Properties from the context menu. Set the connection type to ext
. Click Apply and say yes to convert existing projects.Now tell Eclipse to still use its built-in SSH client, open the Preferences dialog. Under Team > CVS > Ext Connection Method select Use another connection method type and select
extssh
.2. Set the
CVS_RSH
environment variable to ssh
.Linux users will typically just include this in
~/.profile
or ~/.bash_profile
. Windows users have a harder time. First, they can not use Cygwin, because Cygwin's CVS client is incompatible with the Windows line endings used in the CVS meta data generated by Eclipse. So they must use a real Windows CVS client like TortoiseCVS. Tortoise has a command line client (cvs.exe
). Plus it comes with an SSH client TortoisePlink.exe
. So in the System Control Panel, under Advanced click the Environment Variables button and add the CVS_RSH
variable and set it to the path to TortoisePlink.exe
. You should also include the path to cvs.exe
into the PATH
variable.Now you can use your CVS repository from Eclipse as well as from the command line.
What's wrong with Ant
Don't get me wrong. I quite love Ant. But it has some quirks that make life not exactly easy. These quirks leave me thinking why I am not resorting to bash for build scripts. Ant is not a real programming language, since it lacks basic algorithmic structures. That may be a concious design decision but really makes complex build scripts not simpler. The worst annoyances are:
- No simple conditional execution. A simple if-else construct is missing from the basic Ant tasks. Of course there are extensions that add this functionality, but hey, this is somthing so basic!
- Immutable properties. Ant completely lacks real variables. Sometimes they are indispensable.
- The no-replace if younger behaviour of jar, war, etc. If you jar some files and update the jar in the same script with files from a different location, their modification dates control whether they are replaced in the jar or not. This is cumbersome and makes it difficult to e.g. replace config files in EJB applications.
- XML as a programming language sucks. Badly.
JSP cheat sheet
I always need a cheat sheet when coding JSPs. Especially for the EL that I am using only sporadically. This one from ndpsoftware does the job quite well.
Format Oracle plan_table
Here is a simple query that formats Oracle's
plan_table
in a useful way. No need for complex PLSQL scripts.select cost, RPAD(' ', 3*depth,' ') || operation operation, object_name, options from plan_table order by id;
bash regex and quotes
[[ "a b c" =~ "a (.) c" ]]
Bash once returned the expected results from the above statement. Due to a parser change, bash now ignores reserved regex characters in the right-hand side of =~ if quotes are used, and treats them as literals. This is how to do the above now:
[[ "a b c" =~ a\ (.)\ c ]] or V="a b c" RE="a (.) c" [[ ${V} =~ ${RE} ]]
Thank you for this note.
I suppose I should have caught this in the Release Notes or something, but you are the only person to have signaled this.
I suppose I should have caught this in the Release Notes or something, but you are the only person to have signaled this.
IE7 create table with DOM
I just noticed that IE7 is very picky when you create content via the DOM. In my image viewer I am creating a table object dynamically. However IE7 didn't show it because I did not use a
tbody
element and appended the tr
elements directly under table
. So when creating content via the DOM make sure to be extremely standards compliant. Firefox is more forgiving in this case.Thanks, that saved me :)
Spent a full day trying to figure out what was wrong before I finally stumbled on your post.
You're the man!
matt
Spent a full day trying to figure out what was wrong before I finally stumbled on your post.
You're the man!
matt
Actually W3C recommendations say that the rows of
a table *may* be gathered within <tbody> tags, they don't say *must*. So the standard doesn't
prescribe mandatory <tbody> sections in a <table>
-- Massimo
a table *may* be gathered within <tbody> tags, they don't say *must*. So the standard doesn't
prescribe mandatory <tbody> sections in a <table>
-- Massimo
thanks, dammit!!!
thanks for this post... I was scratching my head for the whole day for this issue...
Hello from 2010. Wish I'd seen this post before I spent a day on this too..
Quickly convert a timestamp to a date
Sometimes when looking through log files you come across Unix/Java timestamps. You can quickly convert those unwieldy long values into a local Date with your web browser. Just type this in the address bar:
That's quite a handy trick that every developer should know.
javascript:alert(new Date(1178096885359))
That's quite a handy trick that every developer should know.
JBoss VM parameters
The default VM parameters are not suitable to run a large J2EE application in production. For JBoss I recommend the following settings (x86 architecture):
-server -Xms512m -Xmx1024m -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=64m -XX:+UseConcMarkSweepGC -Djava.awt.headless=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.net.inetaddr.ttl=60 -Dsun.net.client.defaultConnectTimeout=30000On server machines we typically have multiple CPUs, so we select the Concurrent Mark and Sweep Garbage Collector. It provides the best performance. On 32bit architectures we have a maximum of 2GB per process. JBoss starts lots of threads which all need stack space, plus there are non-heap memory pools that need space. So we can't just assign 2GB of heap, instead we use a 1GB heap. The VM's auto tuning mechanism sets the permanent generation pool too low (64MB). Out of memory conditions would take down the system immediately. Peaking into the memory pools at runtime with jconsole or through JBoss' JMX console quickly reveals that 128MB or 256MB are more appropriate. Also the code cache should be increased because J2EE applications have many classes and EJB3 even creates new classes at runtime (e.g. lazy loading proxies). We also set the RMI GC intervals to reasonably large values to avoid unnecessary GC. Last but not least we don't want the VM to cache DNS names forever (which effectively causes a leak).
top
Over the weekend a customer got a new DB server:
top - 10:02:36 up 13 days, 21:01, 3 users, load average: 1.25, 1.50, 1.51 Tasks: 475 total, 3 running, 472 sleeping, 0 stopped, 0 zombie Cpu0 : 70.9% us, 4.9% sy, 0.0% ni, 23.3% id, 0.0% wa, 0.0% hi, 1.0% si Cpu1 : 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si Cpu2 : 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si Cpu3 : 1.0% us, 1.9% sy, 0.0% ni, 97.1% id, 0.0% wa, 0.0% hi, 0.0% si Cpu4 : 100.0% us, 0.0% sy, 0.0% ni, 0.0% id, 0.0% wa, 0.0% hi, 0.0% si Cpu5 : 6.9% us, 2.0% sy, 0.0% ni, 91.2% id, 0.0% wa, 0.0% hi, 0.0% si Cpu6 : 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si Cpu7 : 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si Mem: 32973260k total, 31965572k used, 1007688k free, 398564k buffers Swap: 9412568k total, 265368k used, 9147200k free, 27462248k cachedIt's a 4 way DualCore 2.4GHz Opteron system with 32 GB of RAM. Yummie...
External tables in Oracle
Oracle can use plain-text files and provide them to the DB engine like read-only tables. That's great for master data imports.
The syntax to declare those tables is borrowed from SQLLoader. SQLLoader as we know is very powerful. It can read practically any type of CSV-like file. The most common problems with plain text files are usually:
With external tables (or SQLLoader) you can leave this job to Oracle - and it's even damn good at it. Oracle knows practically every oh so weird character encoding used on this planet. And it can also deal with explicit or platform specific line endings if you tell it. An external table definition looks like this:
back
|
next
The syntax to declare those tables is borrowed from SQLLoader. SQLLoader as we know is very powerful. It can read practically any type of CSV-like file. The most common problems with plain text files are usually:
- You don't know the character encoding
- Platform specific line endings
iconv
and dos2unix/unix2dos
tools.With external tables (or SQLLoader) you can leave this job to Oracle - and it's even damn good at it. Oracle knows practically every oh so weird character encoding used on this planet. And it can also deal with explicit or platform specific line endings if you tell it. An external table definition looks like this:
CREATE TABLE EXT_MYTABLEThe important part is the RECORDS DELIMITED BY and CHARACTERSET parameters. Just specify it correctly and the data will appear correctly in the DB. If you are not sure about the character encoding you may want to use the Linux
(
F1 VARCHAR2(100 BYTE),
F2 VARCHAR2(100 BYTE),
F3 VARCHAR2(100 BYTE)
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY EXT_MYTABLES
ACCESS PARAMETERS
( RECORDS DELIMITED BY '\r\n' CHARACTERSET AL32UTF8
BADFILE 'mytable.bad'
DISCARDFILE 'mytable.dis'
LOGFILE 'mytable.log'
FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"'
MISSING FIELD VALUES ARE NULL
)
LOCATION (EXT_MYTABLES:'mytable.csv')
)
REJECT LIMIT UNLIMITED
NOPARALLEL
NOMONITORING;
file
command. Used with a representative file it can guess the encoding using sophisticated heuristics:bash-3.2$ file my.csvSimilarly you can determine the line endings with
my.csv: ISO-8859 text
hexdump
(0D is \r, 0A is \n):bash-3.2$ hexdump -C my.csv| head
00000000 4d fc 6e 63 68 65 6e 3b 31 30 30 3b 34 37 0a 42
00000010 e4 72 6e 3b 32 38 32 3b 32 39 0a
Once project is checked out I have normal file structure on disk (CVS/Root, CVS/Repository, CVS/Entries).
Admittedly I do get Apache lock problem
once in a while and perhaps switching method
can cure _that_, but it's a different prob.
Also, please right-click a folder or a file in Navigator view and try "Compare with another branch or version" menu item. This gives you lots of flexibility to diff your current code against tags. (There's a tricks how to make "Refresh tags" operation faster but that's again a different topic). No I'm not saying you can diff against date on branch but as for arbitrary tags looks like you can do it from Eclipse.
Anton Tagunov
Happens to me quite often. At work we maintain a couple of branches (for production systems) of several projects. Sometimes a fix or feature is needed in the branches too and you get to know this only after you have committed. Thus the need to create patch files.
Of course life would be a little easier with changesets like git has.
Odi
It's exactly what I was looking for!
Thanks!