<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7434468828198728552</id><updated>2011-04-21T21:15:57.638+02:00</updated><category term='traces'/><category term='xml'/><category term='stack'/><category term='fun'/><category term='dump'/><category term='java'/><category term='sed'/><title type='text'>null</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mitchnull.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7434468828198728552/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://mitchnull.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>mitchnull</name><uri>http://www.blogger.com/profile/17098253423227701496</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_QGDsLJ1ZCXI/SNuSjzM6ffI/AAAAAAAAAAM/fKSHxNfD0wQ/S220/mitch0.jpeg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7434468828198728552.post-6719074297727026373</id><published>2009-04-28T10:02:00.007+02:00</published><updated>2009-04-28T12:06:10.251+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='dump'/><category scheme='http://www.blogger.com/atom/ns#' term='traces'/><category scheme='http://www.blogger.com/atom/ns#' term='stack'/><title type='text'>Dump java stack traces</title><content type='html'>This is a small utility function to programmatically dump all stack traces of a java process similar to the output of kill -QUIT on unix platforms.  Use at your own peril, no warranties, no royalties :)

&lt;pre name="code" class="java:nogutter"&gt;
public static void dumpStackTraces(PrintStream out) {
    synchronized (out) {
        Map&amp;lt;Thread, StackTraceElement[]&amp;gt; sts = Thread.getAllStackTraces();
        for (Thread t : sts.keySet()) {
            StackTraceElement[] st = sts.get(t);
            out.println(t.getName() + "[" + t.getId() + "]" + "(" + t.getState() + (t.isDaemon() ? ")(DAEMON):" : "):"));
            for (int i = 0; i &amp;lt; st.length; ++i) {
                out.println("\t" + st[i]);
            }
        }
    }
}
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7434468828198728552-6719074297727026373?l=mitchnull.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mitchnull.blogspot.com/feeds/6719074297727026373/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7434468828198728552&amp;postID=6719074297727026373' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7434468828198728552/posts/default/6719074297727026373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7434468828198728552/posts/default/6719074297727026373'/><link rel='alternate' type='text/html' href='http://mitchnull.blogspot.com/2009/04/dump-java-stack-traces.html' title='Dump java stack traces'/><author><name>mitchnull</name><uri>http://www.blogger.com/profile/17098253423227701496</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_QGDsLJ1ZCXI/SNuSjzM6ffI/AAAAAAAAAAM/fKSHxNfD0wQ/S220/mitch0.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7434468828198728552.post-82611001990981432</id><published>2008-09-25T15:50:00.012+02:00</published><updated>2008-09-25T22:00:29.125+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='fun'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='sed'/><title type='text'>XML indenting with sed(1)</title><content type='html'>&lt;p&gt;Some years ago I stumbled upon SedSokoban, the sokoban game implemented as a sed script.  I found it pretty amusing, so I got interested in the more arcane uses of sed.  As an exercise, I set out to write an XML indenter sed script.&lt;/p&gt;&lt;p&gt;Now I found that script (again), and I thought it would be a nice starting post here.&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: courier new;"&gt;xmlindent.sed&lt;/span&gt; looks like this:&lt;/p&gt;
&lt;pre&gt;:a
/&amp;gt;/!N;s/\n/ /;ta
s/&amp;#09;/ /g;s/^ *//;s/  */ /g
/^&amp;lt;!--/{
:e
/--&amp;gt;/!N;s/\n//;te
s/--&amp;gt;/\n/;D;
}
/^&amp;lt;[?!][^&amp;gt;]*&amp;gt;/{
H;x;s/\n//;s/&amp;gt;.*$/&amp;gt;/;p;bb
}
/^&amp;lt;\/[^&amp;gt;]*&amp;gt;/{
H;x;s/\n//;s/&amp;gt;.*$/&amp;gt;/;s/^&amp;#09;//;p;bb
}
/^&amp;lt;[^&amp;gt;]*\/&amp;gt;/{
H;x;s/\n//;s/&amp;gt;.*$/&amp;gt;/;p;bb
}
/^&amp;lt;[^&amp;gt;]*[^\/]&amp;gt;/{
H;x;s/\n//;s/&amp;gt;.*$/&amp;gt;/;p;s/^/&amp;#09;/;bb
}
/&amp;lt;/!ba
{
H;x;s/\n//;s/ *&amp;lt;.*$//;p;s/[^&amp;#09;].*$//;x;s/^[^&amp;lt;]*//;ba
}
:b
{
s/[^&amp;#09;].*$//;x;s/^&amp;lt;[^&amp;gt;]*&amp;gt;//;ba
}
&lt;/pre&gt;&lt;p&gt;Unfortunately it chokes on some xml inputs, but I could use it to pretty-format most of the common xml files I came across (configuration files, xml-based network protocol messages, etc).&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7434468828198728552-82611001990981432?l=mitchnull.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mitchnull.blogspot.com/feeds/82611001990981432/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7434468828198728552&amp;postID=82611001990981432' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7434468828198728552/posts/default/82611001990981432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7434468828198728552/posts/default/82611001990981432'/><link rel='alternate' type='text/html' href='http://mitchnull.blogspot.com/2008/09/xml-indenting-with-sed1.html' title='XML indenting with sed(1)'/><author><name>mitchnull</name><uri>http://www.blogger.com/profile/17098253423227701496</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_QGDsLJ1ZCXI/SNuSjzM6ffI/AAAAAAAAAAM/fKSHxNfD0wQ/S220/mitch0.jpeg'/></author><thr:total>0</thr:total></entry></feed>
