<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ugly Code! &#187; ugly hack</title>
	<atom:link href="http://uglycode.com/tag/ugly-hack/feed/" rel="self" type="application/rss+xml" />
	<link>http://uglycode.com</link>
	<description>c0ding is seriose busines!!!!1</description>
	<lastBuildDate>Thu, 15 Jul 2010 20:03:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Who likes ugly hacks?</title>
		<link>http://uglycode.com/2008/09/who-likes-ugly-hacks/</link>
		<comments>http://uglycode.com/2008/09/who-likes-ugly-hacks/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 21:44:41 +0000</pubDate>
		<dc:creator>analytik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ugly hack]]></category>

		<guid isPermaLink="false">http://uglycode.com/?p=3</guid>
		<description><![CDATA[According to my search, a lot of people do.

#ugly hack
self.log.info&#40;&#34;Running script&#34;&#41;
dict=&#123; 'self' : self.model,
'model' : self.model,
'interpreter': self &#125;
exec&#40;self.script,dict&#41;


// Ugly hack
Class.forName&#40;&#34;tristero.util.Conduit&#34;&#41;;
Class.forName&#40;&#34;tristero.util.Lock&#34;&#41;;
Class.forName&#40;&#34;tristero.util.PumpListener&#34;&#41;;
Class.forName&#40;&#34;tristero.util.StringUtils&#34;&#41;;


_label.Show&#40;&#41;;
_label.Hide&#40;&#41;; // Ugly hack!
base.Show&#40;&#41;;


 /*
UGLY UGLY UGLY HACK !!!
*/
QFile inFile&#40;uisFile&#41;;
if &#40;!inFile.open&#40;QIODevice::ReadOnly &#124; QIODevice::Text&#41;&#41;
return;
&#160;
QFile outFile&#40;&#34;/tmp/temp.ini&#34;&#41;;
if &#40;!outFile.open&#40;QIODevice::WriteOnly &#124; QIODevice::Text&#41;&#41;
return;
QTextStream in&#40;&#38;inFile&#41;;
QTextStream out&#40;&#38;outFile&#41;;
&#160;
while &#40;!in.atEnd&#40;&#41;&#41;
&#123;
QString line = in.readLine&#40;&#41;;
line.replace&#40;&#34;\\&#34;,&#34;\\\\&#34;);
out &#60;&#60; line &#60;&#60; endl;
}
inFile.close();
outFile.close();
/*
END OF UGLY UGLY UGLY HACK
*/


 // ugly, ugly hack
if&#40;adapterUse.getAdapterIfKnown&#40;&#41;== [...]]]></description>
			<content:encoded><![CDATA[<p>According to my search, a lot of people do.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#ugly hack</span>
self<span style="color: #339933;">.</span><span style="color: #000066;">log</span><span style="color: #339933;">.</span>info<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Running script&quot;</span><span style="color: #009900;">&#41;</span>
dict<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'self'</span> <span style="color: #339933;">:</span> self<span style="color: #339933;">.</span>model<span style="color: #339933;">,</span>
<span style="color: #ff0000;">'model'</span> <span style="color: #339933;">:</span> self<span style="color: #339933;">.</span>model<span style="color: #339933;">,</span>
<span style="color: #ff0000;">'interpreter'</span><span style="color: #339933;">:</span> self <span style="color: #009900;">&#125;</span>
<span style="color: #000066;">exec</span><span style="color: #009900;">&#40;</span>self<span style="color: #339933;">.</span>script<span style="color: #339933;">,</span>dict<span style="color: #009900;">&#41;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Ugly hack</span>
<span style="color: #000000; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;tristero.util.Conduit&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;tristero.util.Lock&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;tristero.util.PumpListener&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;tristero.util.StringUtils&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">_label.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
_label.<span style="color: #0000FF;">Hide</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// Ugly hack!</span>
<span style="color: #0600FF;">base</span>.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"> <span style="color: #ff0000; font-style: italic;">/*
UGLY UGLY UGLY HACK !!!
*/</span>
QFile inFile<span style="color: #008000;">&#40;</span>uisFile<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>inFile.<span style="color: #007788;">open</span><span style="color: #008000;">&#40;</span>QIODevice<span style="color: #008080;">::</span><span style="color: #007788;">ReadOnly</span> <span style="color: #000040;">|</span> QIODevice<span style="color: #008080;">::</span><span style="color: #007788;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
<span style="color: #0000ff;">return</span><span style="color: #008080;">;</span>
&nbsp;
QFile outFile<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;/tmp/temp.ini&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>outFile.<span style="color: #007788;">open</span><span style="color: #008000;">&#40;</span>QIODevice<span style="color: #008080;">::</span><span style="color: #007788;">WriteOnly</span> <span style="color: #000040;">|</span> QIODevice<span style="color: #008080;">::</span><span style="color: #007788;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
<span style="color: #0000ff;">return</span><span style="color: #008080;">;</span>
QTextStream in<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>inFile<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
QTextStream out<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>outFile<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>in.<span style="color: #007788;">atEnd</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
QString line <span style="color: #000080;">=</span> in.<span style="color: #007788;">readLine</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
line.<span style="color: #007788;">replace</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;\<span style="color: #000099; font-weight: bold;">\&quot;</span>,&quot;</span>\\\\<span style="color: #FF0000;">&quot;);
out &lt;&lt; line &lt;&lt; endl;
}
inFile.close();
outFile.close();
/*
END OF UGLY UGLY UGLY HACK
*/</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"> <span style="color: #666666; font-style: italic;">// ugly, ugly hack</span>
<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>adapterUse.<span style="color: #006633;">getAdapterIfKnown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span> SwaRefAdapter.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
programElement.<span style="color: #006633;">annotate</span><span style="color: #009900;">&#40;</span>XmlAttachmentRef.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// [RESULT]</span>
<span style="color: #666666; font-style: italic;">// @XmlJavaTypeAdapter( Foo.class )</span>
programElement.<span style="color: #006633;">annotate2</span><span style="color: #009900;">&#40;</span>XmlJavaTypeAdapterWriter.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">value</span><span style="color: #009900;">&#40;</span>
adapterUse.<span style="color: #006633;">adapterType</span>.<span style="color: #006633;">toType</span><span style="color: #009900;">&#40;</span>outline,EXPOSED<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Of course, these doesn&#8217;t provide fun nor educational value. But one thing is obvious: ugly code is here to stay. Hopefully I&#8217;ll be able to find some more entertaining pieces next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://uglycode.com/2008/09/who-likes-ugly-hacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
