So you copy an entire project into a new directory. The old one was source-controlled in SVN, and you're not sure about what you want to do with the new one, and your IDE keeps bugging you about committing the new stuff.
Well, say no more!!
From the command line, at the project root, run this:
find . -name .svn -exec rm -rf {} \;
Not much help though if you're running Winders. Sorry.
1/25/09
SVN No More
Posted by
J. Edgar
at
8:38 AM
0
comments
Labels: SVN
9/19/08
Browsering
Stolen from this guy.
public void openURL(String url)
{
try
{
String osName = System.getProperty("os.name");
if (osName.startsWith("Mac OS"))
{
Class fileMgr =
Class.forName("com.apple.eio.FileManager");
Method openURL =
fileMgr.getDeclaredMethod("openURL",
new Class[]{String.class});
openURL.invoke(null, new Object[]{url});
}
else if (osName.startsWith("Windows"))
{
String windowsExec =
"rundll32 url.dll, FileProtocolHandler " + url;
Runtime.getRuntime().exec(windowsExec);
}
else
{
// assume Unix or Linux
String[] browsers =
{
"firefox", "opera", "konqueror",
"epiphany", "mozilla", "netscape"
};
String browser = null;
for (int i = 0;
i < browsers.length && browser == null; i++)
{
String[] candidateBrowser =
new String[]{"which", browsers[i]};
Process exec =
Runtime.getRuntime().exec(candidateBrowser);
if (exec.waitFor() == 0)
{
browser = browsers[i];
}
}
if (browser != null)
{
Runtime.getRuntime().exec(new String[]
{browser, url});
}
else
{
String message =
"You sure you have web browser?";
throw new RuntimeException(message);
}
}
}
catch (Exception e)
{
// Ha, ha, ha.
// ClassNotFoundException, SecurityException,
// NoSuchMethodException, IOException
// InterruptedException, IllegalArgumentException,
// IllegalAccessException and InvocationTargetException
LOGGER.error(e);
throw new RuntimeException(e);
}
}
Note that the url has to be fully qualified, e.g., http://www.abbablows.blogspot.com.
Posted by
J. Edgar
at
7:32 AM
0
comments
Labels: Browsers
7/23/08
-XX:MaxPermSize=256
Running a Tomcat or JBoss webapp?
Finding that after a certain number of deploys the thing throws an OutOfMemoryError?
Read all about it: Garbage collection, permgen, and classloader memory leaks.
Posted by
J. Edgar
at
8:03 AM
0
comments
Labels: Garbage collection, JBoss, Tomcat
4/29/08
SchemaExport
Nutty. Hibernate will generate its own database schema creation scripts.
SchemaExport:
public void doSchema()
{
Configuration hibernateConfig =
new Configuration().configure();
//For SQLServer, e.g.
String dialect = "org.hibernate.dialect.SQLServerDialect";
hibernateConfig.setProperty(Environment.DIALECT,
dialect);
SchemaExport export =
new SchemaExport(hibernateConfig);
export.setOutputFile("outputFileName");
export.setDelimiter("endOfStatementDelimiter");
// Don't print to console
// Don't export to database
export.create(false, false);
}
Posted by
J. Edgar
at
5:57 PM
0
comments
Labels: hibernate
3/26/08
Bird's-Eye
This isn't a low-level idea; hell, it's about as high level as you can get:
...wouldn’t it be neat if we could do a weekly bird’s-eye printout of the source code and pin it up on the wall, giving a nice simple visual representation of the simplification of the code?Having visibility over all the code does sound mighty useful. It can be difficult to see the overall patterns in the source when working on a single area. The more visibility, the better, right?
Granted, what you can see from this bird's-eye view might not be that useful. At such a small scale, really all that might be possible is spotting the various rat's nests of code. Those big blocks of if-if-if-else-if-else-if-if-else-else-ad-nausium spaghetti code certainly would be easy to see and, hence, make for easy refactoring targets. Once the process of identification and refactoring is done the actual pictures of code is pretty uninformative - the code may look clean, but the text is still too small to given any detail about structure.
Of course, the author suggests this as a method for easing the refactoring of legacy code. After the project has moved beyond the legacy-code phase, the value of the bird's-eye method is diminished to a simple tool for preventing spaghetti code. A lot of paper updates, for a little gain.
Posted by
Peter Schwarz
at
9:21 AM
0
comments
Labels: process, refactoring
3/24/08
Once Bitten; Twice Shy
SimpleDateFormat:
"Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally."
Posted by
J. Edgar
at
5:34 PM
0
comments
3/23/08
Equals, HashCode And Hibernate
Background, from Bloch.
What the folks at Hibernate say.
This guy has another suggestion, though it won't work very well if you don't have (or can't add) an id column in a table somewhere. As well, having a public setId() method allowing any Tom, Dick or Harry to change the object's id seems to defeat the purpose of whole concept to begin with. Maybe moving setId() out of the interface into the abstract class and making it private?
More Hibernate stuff here.
Posted by
J. Edgar
at
8:19 PM
1 comments