<?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>demostene.ro &#187; programare</title>
	<atom:link href="http://demostene.ro/tag/programare/feed" rel="self" type="application/rss+xml" />
	<link>http://demostene.ro</link>
	<description>Pai daca logica nu e...</description>
	<lastBuildDate>Mon, 07 May 2012 09:06:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Limbaje de programare &#8220;interesante&#8221;</title>
		<link>http://demostene.ro/2012/04/limbaje-de-programare-interesante.html</link>
		<comments>http://demostene.ro/2012/04/limbaje-de-programare-interesante.html#comments</comments>
		<pubDate>Mon, 23 Apr 2012 07:36:16 +0000</pubDate>
		<dc:creator>demostene</dc:creator>
				<category><![CDATA[din IT]]></category>
		<category><![CDATA[limbaje de programare]]></category>
		<category><![CDATA[programare]]></category>

		<guid isPermaLink="false">http://demostene.ro/?p=2016</guid>
		<description><![CDATA[<p>Se da o problema : 99 bottles of beer. Sa vedem cum se poate scrie in <a href="http://99-bottles-of-beer.net/language-brainfuck-1718.html" target="_new" onclick="pageTracker._trackPageview('/outgoing/99-bottles-of-beer.net/language-brainfuck-1718.html?referer=');">Brainfuck</a>. Iar acum in <a href="http://99-bottles-of-beer.net/language-malbolge-995.html" target="_new" onclick="pageTracker._trackPageview('/outgoing/99-bottles-of-beer.net/language-malbolge-995.html?referer=');">Malbolge</a>. Spor la scris cod!</p>]]></description>
			<content:encoded><![CDATA[<p>Se da o problema : 99 bottles of beer. Sa vedem cum se poate scrie in <a href="http://99-bottles-of-beer.net/language-brainfuck-1718.html" target="_new" onclick="pageTracker._trackPageview('/outgoing/99-bottles-of-beer.net/language-brainfuck-1718.html?referer=');">Brainfuck</a>. Iar acum in <a href="http://99-bottles-of-beer.net/language-malbolge-995.html" target="_new" onclick="pageTracker._trackPageview('/outgoing/99-bottles-of-beer.net/language-malbolge-995.html?referer=');">Malbolge</a>. Spor la scris cod!</p>
]]></content:encoded>
			<wfw:commentRss>http://demostene.ro/2012/04/limbaje-de-programare-interesante.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exemplu simplu de deadlock</title>
		<link>http://demostene.ro/2012/02/exemplu-simplu-de-deadlock.html</link>
		<comments>http://demostene.ro/2012/02/exemplu-simplu-de-deadlock.html#comments</comments>
		<pubDate>Wed, 15 Feb 2012 09:21:25 +0000</pubDate>
		<dc:creator>demostene</dc:creator>
				<category><![CDATA[programare]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://demostene.ro/?p=1344</guid>
		<description><![CDATA[Simplu exemplu de deadlock folosind doua thread-uri in Java.]]></description>
			<content:encoded><![CDATA[<p>Simplu exemplu de deadlock folosind doua thread-uri in Java.</p>
<p><strong>TwoThreads.java</strong></p>
<pre class="wp-code-highlight prettyprint">
package ro.demostene.tests;

public class TwoThreads{

    public static void main(String[] args) {
        DeadLock dl = new DeadLock();
        Thread tr = new ThreadRead(dl, &quot;TH1&quot;);
        Thread tw = new ThreadWrite(dl, &quot;TH2&quot;);
        tr.start();
        tw.start();

    }
}
class ThreadRead extends Thread {
    DeadLock dl;
    ThreadRead(DeadLock dl, String name){
        super(name);
        this.dl=dl;
    }
    @Override
    public void run() {
        dl.lenght();
    }
}
class ThreadWrite extends Thread {
    DeadLock dl;
    ThreadWrite(DeadLock dl, String name){
        super(name);
        this.dl=dl;
    }
    @Override
    public void run() {
        dl.print();
    }
}
</pre>
<p><strong>DeadLock.java</strong></p>
<pre class="wp-code-highlight prettyprint">
package ro.demostene.tests;

public class DeadLock {

    private StringBuffer strBuf1 = new StringBuffer();
    private StringBuffer strBuf2= new StringBuffer();

    public void lenght() {
        synchronized (strBuf1) {
            try {
                Thread.sleep(200);
                } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (strBuf2) {
                System.out.println(strBuf1.length() + strBuf2.length());
            }
        }
    }

    public void print() {
        synchronized (strBuf2) {
            try {
                Thread.sleep(200);
                } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (strBuf1) {
                System.out.println(strBuf1.toString() + strBuf2);
            }
        }
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://demostene.ro/2012/02/exemplu-simplu-de-deadlock.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>De la Servlets la JSP</title>
		<link>http://demostene.ro/2012/02/de-la-servlets-la-jsp.html</link>
		<comments>http://demostene.ro/2012/02/de-la-servlets-la-jsp.html#comments</comments>
		<pubDate>Sun, 12 Feb 2012 11:43:36 +0000</pubDate>
		<dc:creator>demostene</dc:creator>
				<category><![CDATA[programare]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jee]]></category>
		<category><![CDATA[servlets]]></category>

		<guid isPermaLink="false">http://demostene.ro/?p=1790</guid>
		<description><![CDATA[Urmatorul tabel arata legatura intre API si obiectele implicite intr-o pagina JSP.]]></description>
			<content:encoded><![CDATA[<p>Urmatorul tabel arata legatura dintre API si obiectele implicite intr-o pagina JSP.</p>
<table align="right">
<tbody>
<tr>
<td><strong>API</strong></td>
<td><strong>Obiect implicit</strong></td>
</tr>
<tr>
<td>JspWriter</td>
<td>out</td>
</tr>
<tr>
<td>HttpServletRequest</td>
<td>request</td>
</tr>
<tr>
<td>HttpServletResponse</td>
<td>response</td>
</tr>
<tr>
<td>HttpSession</td>
<td>session</td>
</tr>
<tr>
<td>ServletContext</td>
<td>application</td>
</tr>
<tr>
<td>ServletConfig</td>
<td>config</td>
</tr>
<tr>
<td>Throwable</td>
<td>exception</td>
</tr>
<tr>
<td>PageContext</td>
<td>pageContext</td>
</tr>
<tr>
<td>Object</td>
<td>page</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://demostene.ro/2012/02/de-la-servlets-la-jsp.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Boolean.valueOf(String)</title>
		<link>http://demostene.ro/2011/10/boolean-valueofstring.html</link>
		<comments>http://demostene.ro/2011/10/boolean-valueofstring.html#comments</comments>
		<pubDate>Sun, 09 Oct 2011 19:07:04 +0000</pubDate>
		<dc:creator>demostene</dc:creator>
				<category><![CDATA[programare]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[ocjp]]></category>
		<category><![CDATA[scjp]]></category>

		<guid isPermaLink="false">http://demostene.ro/?p=1403</guid>
		<description><![CDATA[Se compileaza ? Daca da, ce afiseaza ?
<pre>System.out.println(Boolean.valueOf("demostene.ro"));
System.out.println(Boolean.valueOf("tRuE"));
System.out.println(Boolean.valueOf(null));</pre>
]]></description>
			<content:encoded><![CDATA[<p>Se compileaza ? Daca da, ce afiseaza ?</p>
<pre class="wp-code-highlight prettyprint">System.out.println(Boolean.valueOf(&quot;demostene.ro&quot;));
System.out.println(Boolean.valueOf(&quot;tRuE&quot;));
System.out.println(Boolean.valueOf(null));</pre>
<p><strong>Raspuns:</strong><br />
Afiseaza false, true, false.<br />
<strong> Explicatie: </strong><br />
Metoda valueOf are urmatoarea semnatura:</p>
<pre class="wp-code-highlight prettyprint">public static Boolean valueOf (String s)</pre>
<p>Valoarea returnata este true daca argumentul nu este null si este egal, ignorand literele mari, cu &#8220;true&#8221;. Altfel returneaza false.</p>
]]></content:encoded>
			<wfw:commentRss>http://demostene.ro/2011/10/boolean-valueofstring.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruleta ruseasca</title>
		<link>http://demostene.ro/2011/07/ruleta-ruseasca.html</link>
		<comments>http://demostene.ro/2011/07/ruleta-ruseasca.html#comments</comments>
		<pubDate>Tue, 26 Jul 2011 07:32:30 +0000</pubDate>
		<dc:creator>demostene</dc:creator>
				<category><![CDATA[din IT]]></category>
		<category><![CDATA[programare]]></category>
		<category><![CDATA[zambete]]></category>
		<category><![CDATA[it]]></category>
		<category><![CDATA[ruleta]]></category>
		<category><![CDATA[ruseasca]]></category>

		<guid isPermaLink="false">http://demostene.ro/?p=1323</guid>
		<description><![CDATA[<p><strong>[ $[ $RANDOM % 6 ] == 0 ] &#38;&#38; rm -rf / &#124;&#124; echo *Click*</strong></p>]]></description>
			<content:encoded><![CDATA[<p><strong>[ $[ $RANDOM % 6 ] == 0 ] &amp;&amp; rm -rf / || echo *Click*</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://demostene.ro/2011/07/ruleta-ruseasca.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Despre programare</title>
		<link>http://demostene.ro/2011/05/despre-programare.html</link>
		<comments>http://demostene.ro/2011/05/despre-programare.html#comments</comments>
		<pubDate>Tue, 03 May 2011 09:03:53 +0000</pubDate>
		<dc:creator>demostene</dc:creator>
				<category><![CDATA[din IT]]></category>
		<category><![CDATA[interesante]]></category>
		<category><![CDATA[programare]]></category>
		<category><![CDATA[sfaturi]]></category>

		<guid isPermaLink="false">http://demostene.ro/?p=1259</guid>
		<description><![CDATA[<p>&#8220;Programming as an intellectual activity is the only art form that allows you to create interactive art. You can create projects that other people can play with, and you can talk to them indirectly. No other art form is quite [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>&#8220;Programming as an intellectual activity is the <em>only </em>art form that allows you to create interactive art. You can create projects that other people can play with, and you can talk to them indirectly. No other art form is quite this interactive. Movies ﬂow to the audience in one direction. Paintings do not move. Code goes both ways.&#8221;</p></blockquote>
<p>(Mai mult  <a href="http://blamcast.net/python/advice.html" target="_blank" onclick="pageTracker._trackPageview('/outgoing/blamcast.net/python/advice.html?referer=');">aici</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://demostene.ro/2011/05/despre-programare.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gluma&#8230; proasta.</title>
		<link>http://demostene.ro/2011/03/gluma-proasta.html</link>
		<comments>http://demostene.ro/2011/03/gluma-proasta.html#comments</comments>
		<pubDate>Sun, 27 Mar 2011 20:36:10 +0000</pubDate>
		<dc:creator>demostene</dc:creator>
				<category><![CDATA[din IT]]></category>
		<category><![CDATA[programare]]></category>
		<category><![CDATA[gluma]]></category>
		<category><![CDATA[it]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://demostene.ro/?p=1183</guid>
		<description><![CDATA[<p>alias vi=’sudo rm -rf /’</p>]]></description>
			<content:encoded><![CDATA[<p>alias vi=’sudo rm -rf /’</p>
]]></content:encoded>
			<wfw:commentRss>http://demostene.ro/2011/03/gluma-proasta.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sum(var1 * var2) in Hibernate</title>
		<link>http://demostene.ro/2011/01/sumvar1-var2-in-hibernate.html</link>
		<comments>http://demostene.ro/2011/01/sumvar1-var2-in-hibernate.html#comments</comments>
		<pubDate>Fri, 07 Jan 2011 14:43:07 +0000</pubDate>
		<dc:creator>demostene</dc:creator>
				<category><![CDATA[programare]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://demostene.ro/?p=1078</guid>
		<description><![CDATA[Cum poti face o operatie in interiorul unei functii agregate pentru Hibernate Criteria? Sa luam exemplul unei sume. Daca se foloseste : setProjection(Projections.sum((&#34;amount * direction&#34;))) <p>auntci va fi aruncata o exceptie</p> org.hibernate.QueryException: could not resolve property: amount * direction ....&#34;. [...]]]></description>
			<content:encoded><![CDATA[<div>Cum poti face o operatie in interiorul unei functii agregate pentru Hibernate Criteria? Sa luam exemplul unei sume.</div>
<div>Daca se foloseste :</div>
<pre class="wp-code-highlight prettyprint"> setProjection(Projections.sum((&quot;amount * direction&quot;)))</pre>
<p>auntci va fi aruncata o exceptie</p>
<pre class="wp-code-highlight prettyprint">
org.hibernate.QueryException: could not resolve property: amount * direction ....&quot;. </pre>
<p>Solutia este urmatoarea:</p>
<pre class="wp-code-highlight prettyprint">Criteria criteria = currentSession().createCriteria(Transaction.class)
.add(Restrictions.ne(&quot;user.userId&quot;, userId))
.add(Restrictions.ge(&quot;transactionDate&quot;, dateCreated))
.setProjection(Projections.sqlProjection
(&quot;sum(cast(amount as signed)* direction) as amntDir&quot;,
new String[] {&quot;amntDir&quot;} ,
new Type[] {Hibernate.DOUBLE})
);</pre>
]]></content:encoded>
			<wfw:commentRss>http://demostene.ro/2011/01/sumvar1-var2-in-hibernate.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Evolutia programarii</title>
		<link>http://demostene.ro/2010/12/evolutia-programarii.html</link>
		<comments>http://demostene.ro/2010/12/evolutia-programarii.html#comments</comments>
		<pubDate>Wed, 01 Dec 2010 05:36:00 +0000</pubDate>
		<dc:creator>demostene</dc:creator>
				<category><![CDATA[zambete]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[programare]]></category>

		<guid isPermaLink="false">http://demostene.ro/?p=1012</guid>
		<description><![CDATA[<p>Programarea in 1980</p> <p>&#160;&#160;&#160;&#160;&#160;end;<br /> &#160;&#160;&#160;&#160;end;<br /> &#160;&#160;&#160;end;<br /> &#160;&#160;end;<br /> &#160;end.</p> <p>Programarea in 1990<br /> &#160;&#160;&#160;&#160;&#160;}<br /> &#160;&#160;&#160;&#160;}<br /> &#160;&#160;&#160;}<br /> &#160;&#160;}<br /> &#160;}</p> <p>Programarea in 2000</p> <p>&#160;&#160;&#160;&#160;&#160;&#60;/div&#62;<br /> &#160;&#160;&#160;&#160;&#60;/div&#62;<br /> &#160;&#160;&#160;&#60;/div&#62;<br /> &#160;&#160;&#60;/div&#62;<br /> &#160;&#60;/div&#62;</p>]]></description>
			<content:encoded><![CDATA[<p>Programarea in 1980</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br />
&nbsp;&nbsp;&nbsp;&nbsp;end;<br />
&nbsp;&nbsp;&nbsp;end;<br />
&nbsp;&nbsp;end;<br />
&nbsp;end.</p>
<p>Programarea in 1990<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
&nbsp;}</p>
<p>Programarea in 2000</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&lt;/div&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://demostene.ro/2010/12/evolutia-programarii.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inversarea variabilelor</title>
		<link>http://demostene.ro/2010/11/inversarea-variabilelor.html</link>
		<comments>http://demostene.ro/2010/11/inversarea-variabilelor.html#comments</comments>
		<pubDate>Wed, 17 Nov 2010 20:21:35 +0000</pubDate>
		<dc:creator>demostene</dc:creator>
				<category><![CDATA[programare]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[ocjp]]></category>
		<category><![CDATA[variabile]]></category>

		<guid isPermaLink="false">http://demostene.ro/?p=1008</guid>
		<description><![CDATA[<p>Doua metode de a inversa valorile a doua variabile fara a folosi o a treia variabila auxiliara:</p> <p>Avem date :  </p> int a=5, b=10; <p><strong>Metoda 1</strong> </p> a=a+b; b=a-b; a=a-b; <p><strong>Metoda 2</strong> </p> a = a ^ b; b = a ^ b; a = [...]]]></description>
			<content:encoded><![CDATA[<p>Doua metode de a inversa valorile a doua variabile fara a folosi o a treia variabila auxiliara:</p>
<p>Avem date :  </p>
<pre class="wp-code-highlight prettyprint">
int a=5, b=10;
</pre>
<p><strong>Metoda 1</strong> </p>
<pre class="wp-code-highlight prettyprint">
a=a+b; b=a-b; a=a-b;
</pre>
<p><strong>Metoda 2</strong> </p>
<pre class="wp-code-highlight prettyprint">
a = a ^ b; b = a ^ b; a = a ^ b;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://demostene.ro/2010/11/inversarea-variabilelor.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

