<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Amin Abbaspour&#039;s Blog</title>
	<atom:link href="http://aminsblog.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://aminsblog.wordpress.com</link>
	<description>tail -f my.life &#124; grap ^tech</description>
	<lastBuildDate>Sat, 28 Jan 2012 08:28:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='aminsblog.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/fa519f7c3be92ece461a30e463a22160?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Amin Abbaspour&#039;s Blog</title>
		<link>http://aminsblog.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://aminsblog.wordpress.com/osd.xml" title="Amin Abbaspour&#039;s Blog" />
	<atom:link rel='hub' href='http://aminsblog.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Oracle Entitlement Server (OES) Lightweight RMI Client</title>
		<link>http://aminsblog.wordpress.com/2011/11/21/oracle-entitlement-server-oes-lightweight-rmi-client/</link>
		<comments>http://aminsblog.wordpress.com/2011/11/21/oracle-entitlement-server-oes-lightweight-rmi-client/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 01:21:09 +0000</pubDate>
		<dc:creator>abbaspour</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[OES]]></category>
		<category><![CDATA[abac]]></category>
		<category><![CDATA[oes]]></category>
		<category><![CDATA[rbac]]></category>
		<category><![CDATA[rmi]]></category>
		<category><![CDATA[sm]]></category>

		<guid isPermaLink="false">http://aminsblog.wordpress.com/?p=280</guid>
		<description><![CDATA[Introduction Thanks to posts from Subbu one finds it easy to create and configure an RMI client to OES by replacing jps-config of a normal Java SM in the same host. What I want to show here is how to invoke entitlement requests remotely by an RMI client which send requests to a non-controlled RMI SM [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=280&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>Thanks to <a href="http://accessmanagement.wordpress.com/2011/07/22/oracle-entitlements-server-getting-started-with-rmi-sm/">posts from Subbu</a> one finds it easy to create and configure an RMI client to OES by replacing jps-config of a normal Java SM in the same host. What I want to show here is how to invoke entitlement requests remotely by an RMI client which send requests to a <strong>non-controlled</strong> RMI SM server. This is almost identical to a XACML/Web Service client except that it&#8217;s using RMI which is faster, more convinced an  less error prone.</p>
<p>As I said, I will try keep my RMI SM in non-controlled mode. I found it less problematic this way. Using controlled security modules you may end up in some GUI issues which prevent proper distribution.</p>
<h1>Security Module (SM)</h1>
<h2>PRP</h2>
<p>So here is my PRP file for this NC (non-controlled) RMI SM:</p>
<p><pre class="brush: plain;">
oracle.security.jps.runtime.pd.client.sm_name=Telstra_RMI_NC_SM
# Policy dustribution mode. Possible values:
oracle.security.jps.runtime.pd.client.policyDistributionMode=non-controlled
# -------- Policy Distributor connectivity information - required for controlled-push distribution mode
# Only needed for controlled-push policy distribution mode
oracle.security.jps.runtime.pd.client.RegistrationServerHost=[OES-Server]
oracle.security.jps.runtime.pd.client.RegistrationServerPort=[OES-Port]
# --Policy Store Service Configuration parameters - required only for controlled-pull or non-controlled modes
# Policy store type
oracle.security.jps.policystore.type=DB
# Policy Store URL for DB policy store
jdbc.url=jdbc:oracle:thin:@[DB-Host]:[DB-Port]/[DB-SID]
# Policy Store URL for LDAP policy store
ldap.url=
# For both LDAP and DB Policy Store
oracle.security.jps.farm.name=cn=oes_domain
oracle.security.jps.ldap.root.name=cn=jpsroot
#Communication between SM and Policy Distributor is over SSL by default
oracle.security.jps.pd.client.sslMode=true
bootstrap.security.principal.key=oes_sm_key
bootstrap.security.principal.map=oes_sm_map
jdbc.driver=oracle.jdbc.driver.OracleDriver
#---------- ONLY for RMI SM -----------------------------
# port number to accept authorization requests
oracle.security.jps.pdp.rmism.RMIRegistryPortNumber=2099
#--- Only for Java SM, WS SM, and RMI SM in controlled-push mode ---
# port to listen for policy distribution. Picked automatically by SM config tool if not specified
oracle.security.jps.runtime.pd.client.DistributionServicePort=
oracle.security.jps.runtime.pd.client.sm_type=rmi
</pre></p>
<h2>Setup</h2>
<p>You may put this in <strong>[OES-Client-Home]/oessm/SMConfigTool</strong> folder and run  <strong>[OES-Client-Home]/oessm/bin/config.sh</strong> to add SM to OES. Like this:</p>
<p><pre class="brush: bash;">
./config.sh -prpFileName ../SMConfigTool/smconfig.Telstra_RMI_NC_SM.prp
</pre></p>
<p>Now enter your database Policy Store username and password. Note that policy stores are in APM. If things all go well, you&#8217;ll have your SM folder under <strong>[OES-Client-Home]/oes_sm_instances</strong>.</p>
<h2>Logging</h2>
<p>Before we start the RMI server, it&#8217;s better to go and modify start-up script to add more logging stuff. Put a simple JUL config file in config folder and add it to Java argument in startRMIServer.sh. You&#8217;d better create a logs folder too.</p>
<p><pre class="brush: plain;">
handlers= java.util.logging.FileHandler
.level= FINER
java.util.logging.FileHandler.pattern = ./logs/log
java.util.logging.FileHandler.limit = 50000000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
</pre></p>
<p>And this is line in <strong>startRMIServer.sh</strong></p>
<p><pre class="brush: bash;">
${JAVA_HOME}/bin/java &lt;strong&gt;-Djava.util.logging.config.file=./config/logging.properties&lt;/strong&gt; -Djava.security.policy=file:${OES_INSTANCE_HOME}/config/java.policy -Doracle.security.jps.config=${OES_INSTANCE_HOME}/config/jps-config.xml com.bea.security.ssmrmi.LauncherWrapper
</pre></p>
<h2>Run</h2>
<p>Now make logs folder and run it.</p>
<p><pre class="brush: bash;">
mkdir logs
nohup ./startRMIServer.sh &amp;
tail -f nohup.out logs/log
</pre></p>
<h1>OES</h1>
<h2>SM Setup</h2>
<p>Add a new SM to OES:</p>
<p><a href="http://aminsblog.files.wordpress.com/2011/11/oes-config-sm.jpeg"><img class="aligncenter size-full wp-image-292" title="oes-config-sm" src="http://aminsblog.files.wordpress.com/2011/11/oes-config-sm.jpeg?w=497&#038;h=296" alt="" width="497" height="296" /></a></p>
<h2>Application Binding</h2>
<p>Bind this new SM to your application:</p>
<p><a href="http://aminsblog.files.wordpress.com/2011/11/oes-config-app-sm-binding.jpeg"><img class="aligncenter size-full wp-image-291" title="oes-config-app-sm-binding" src="http://aminsblog.files.wordpress.com/2011/11/oes-config-app-sm-binding.jpeg?w=497&#038;h=296" alt="" width="497" height="296" /></a></p>
<h2>Attributed Based Authorization Policy</h2>
<p>And finally an authorization policy based on resource, role and a dynamic attribute (key):</p>
<p><a href="http://aminsblog.files.wordpress.com/2011/11/oes-authorization-policy-abac.jpeg"><img class="aligncenter size-full wp-image-290" title="oes-authorization-policy-ABAC" src="http://aminsblog.files.wordpress.com/2011/11/oes-authorization-policy-abac.jpeg?w=497&#038;h=350" alt="" width="497" height="350" /></a></p>
<p>All done in OES. No need to distribute changes in policies to modules. It all will be done periodically and automatically (<a href="http://download.oracle.com/docs/cd/E21764_01/doc.1111/e14096/param.htm">see <em>waitDistributionTime</em> variable</a>).</p>
<h1>Client</h1>
<h1>Code</h1>
<p>Here is Client source code. Put it in <strong>oes/rmi/client/RmiAuthorizationServiceImpl.java</strong></p>
<p><pre class="brush: java;">
package oes.rmi.client;
import com.bea.security.ssmrmi.services.RMIAuthorizationService;
import com.bea.security.ssmrmi.socket.SocketConfiguration;
import com.bea.security.ssmrmi.socket.SocketFactory;
import com.bea.security.ssmrmi.types.*;
import weblogic.security.principal.WLSGroupImpl;
import weblogic.security.principal.WLSUserImpl;
import weblogic.security.spi.IdentityAssertionException;

import javax.naming.ServiceUnavailableException;
import javax.security.auth.Subject;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.security.Principal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

/**
 * User: Amin Abbaspour
 * A simple client for Oracle Entitlement Server (OES) RMI SM
 */
public class RmiAuthorizationServiceImpl {
    private final RMIAuthorizationService authorizationService;

    public RmiAuthorizationServiceImpl(String host, int port) throws RemoteException, NotBoundException, ServiceUnavailableException, InterruptedException {
        final Registry registry;
        try {
            registry= LocateRegistry.getRegistry(host, port);
            authorizationService = (RMIAuthorizationService) registry.lookup(&quot;ALES_Authorization_Service&quot;);
        } catch (RemoteException e) {
            throw new ExceptionInInitializerError(e);
        } catch (NotBoundException e) {
            throw new ExceptionInInitializerError(e);
        }

        SocketConfiguration socketConfiguration = new SocketConfiguration();
        socketConfiguration.setServerHost(host);
        SocketFactory.setConfiguration(socketConfiguration);
    }

    public RMIAuthenticatedSubject getUnauthenticatedSubject(String username, String... groups) {

        final Set&lt;Principal&gt; principals = new HashSet&lt;Principal&gt;(groups.length + 1);

        principals.add(new WLSUserImpl(username));
        for(final String group : groups)
            principals.add(new WLSGroupImpl(group));

        final Subject subject = new Subject(false, principals, new HashSet&lt;String&gt;(), new HashSet&lt;Object&gt;());

       RMIAuthenticatedSubject authenticatedSubject = new RMIAuthenticatedSubject();
        authenticatedSubject.addSubject(subject);

        return authenticatedSubject;
    }

    public RMIAuthenticatedSubject authenticate(RMIAuthenticatedSubject authenticatedSubject) throws ServiceUnavailableException, RemoteException {
        RMIContext rmiContext = new RMIContext(new HashMap());
        RMIAuthenticationResponse response = authorizationService.establishSession(authenticatedSubject, rmiContext);
        return response.getSubject();
    }

    public String  getActionsOnResource(RMIAuthenticatedSubject authenticatedSubject,
                                        String applicationName, String resourceType, String resource,
                                        String actionName, String namingAuthority, HashMap&lt;String, Object&gt; attributes)
            throws ServiceUnavailableException, IdentityAssertionException, RemoteException {

        RMIRuntimeAction runtimeAction = new RMIRuntimeAction(actionName, namingAuthority);
        RMIRuntimeResource runtimeResource = new RMIRuntimeResource(applicationName, resourceType, resource);
        RMIRuntimeResourceAction runtimeResourceAction = new RMIRuntimeResourceAction(runtimeResource, runtimeAction);

        return authorizationService.queryActionsOnResource(authenticatedSubject, runtimeResourceAction, new RMIContext(attributes)).toString();
    }

    public static void main(String[] args) throws RemoteException, NotBoundException, ServiceUnavailableException, InterruptedException {
        final String serverAddress = &quot;host-name-where-rmi-sm-server-is-running&quot;;
        final int port = 2099; // non-controlled one

        RmiAuthorizationServiceImpl authorizationService = new RmiAuthorizationServiceImpl(serverAddress, port);
        final HashMap&lt;String, Object&gt; attributes = new HashMap&lt;String, Object&gt;(1);
        attributes.put(&quot;key&quot;, 101);
        try {
            RMIAuthenticatedSubject unauthenticatedSubject =  authorizationService.getUnauthenticatedSubject(&quot;username&quot;, &quot;group&quot;);
            RMIAuthenticatedSubject authenticatedSubject =  authorizationService.authenticate(unauthenticatedSubject);
            final String actions =  authorizationService.getActionsOnResource(authenticatedSubject,
                    &quot;AppName&quot;, &quot;ResourceType&quot;, &quot;Resource&quot;, &quot;Action&quot;, &quot;&quot;, attributes);
            System.out.println(&quot;actions = &quot; + actions);

        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}
</pre></p>
<h2>Maven</h2>
<div>I use Maven. Keep things simple. It has very minimal dependency to only 3 files. Here is <strong>pom.xml</strong> file:</div>
<div><pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;oes-demo&lt;/groupId&gt;
    &lt;artifactId&gt;authorization-client-rmi&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;

    &lt;properties&gt;
        &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
        &lt;version.oes&gt;11.1.1&lt;/version.oes&gt;
        &lt;version.wls&gt;10.3&lt;/version.wls&gt;
    &lt;/properties&gt;

    &lt;build&gt;
        &lt;defaultGoal&gt;compile&lt;/defaultGoal&gt;
    &lt;/build&gt;

    &lt;dependencies&gt;

        &lt;!-- wls client for principals and general rmi types --&gt;
        &lt;dependency&gt;
            &lt;!-- see: http://download.oracle.com/docs/cd/E12840_01/wls/docs103/client/jarbuilder.html --&gt;
            &lt;groupId&gt;weblogic&lt;/groupId&gt;
            &lt;artifactId&gt;wlfullclient&lt;/artifactId&gt;
            &lt;version&gt;${version.wls}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;!-- RMI types and stubs --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;oracle.oes.sm.rmism&lt;/groupId&gt;
            &lt;artifactId&gt;rmi-types&lt;/artifactId&gt;
            &lt;version&gt;${version.oes}&lt;/version&gt;
            &lt;scope&gt;system&lt;/scope&gt;
            &lt;systemPath&gt;D:/project/OES/oes_client/oessm/rmism/rmi-types.jar&lt;/systemPath&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;oracle.oes.sm.rmism&lt;/groupId&gt;
            &lt;artifactId&gt;rmi-stubs&lt;/artifactId&gt;
            &lt;version&gt;${version.oes}&lt;/version&gt;
            &lt;scope&gt;system&lt;/scope&gt;
            &lt;systemPath&gt;D:/project/OES/oes_client/oessm/rmism/rmi-stubs.jar&lt;/systemPath&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;
&lt;/project&gt;
</pre></p>
</div>
<h2>Test</h2>
<p>If the connection to RMI server is OK, then run the application and enjoy. Once serverAddress, port, application name and other settings in code is correct, will result something like:</p>
<p><pre class="brush: bash;">
actions = Granted=true. Responses={oracle.security.oes.authorization.decision_reason=grant_policy_found}
</pre></p>
<div></div>
<pre></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aminsblog.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aminsblog.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aminsblog.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aminsblog.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/aminsblog.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/aminsblog.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/aminsblog.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/aminsblog.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aminsblog.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aminsblog.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aminsblog.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aminsblog.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aminsblog.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aminsblog.wordpress.com/280/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=280&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://aminsblog.wordpress.com/2011/11/21/oracle-entitlement-server-oes-lightweight-rmi-client/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/93b11ccaf90fc2d16e8a28a0291d8517?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">abbaspour</media:title>
		</media:content>

		<media:content url="http://aminsblog.files.wordpress.com/2011/11/oes-config-sm.jpeg" medium="image">
			<media:title type="html">oes-config-sm</media:title>
		</media:content>

		<media:content url="http://aminsblog.files.wordpress.com/2011/11/oes-config-app-sm-binding.jpeg" medium="image">
			<media:title type="html">oes-config-app-sm-binding</media:title>
		</media:content>

		<media:content url="http://aminsblog.files.wordpress.com/2011/11/oes-authorization-policy-abac.jpeg" medium="image">
			<media:title type="html">oes-authorization-policy-ABAC</media:title>
		</media:content>
	</item>
		<item>
		<title>N-Queen Problem: CPython 2.6.5 vs PyPy 1.5.0</title>
		<link>http://aminsblog.wordpress.com/2011/05/29/n-queen-problem-python-2-6-5-vs-pypy-1-5-0/</link>
		<comments>http://aminsblog.wordpress.com/2011/05/29/n-queen-problem-python-2-6-5-vs-pypy-1-5-0/#comments</comments>
		<pubDate>Sun, 29 May 2011 13:17:07 +0000</pubDate>
		<dc:creator>abbaspour</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://aminsblog.wordpress.com/?p=251</guid>
		<description><![CDATA[It is amazing how small and compress a Python code can be for solving 8-Queen problem. Using Python&#8217;s itertools to compute permutations and yield keyword for generators, all N-Queen problem comes to mere 8 lines of code: One may add just a bit more code to print the board like this: I used this code [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=251&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It is amazing how small and compress a Python code can be for solving <a href="http://en.wikipedia.org/wiki/Eight_queens_puzzle">8-Queen problem</a>. Using Python&#8217;s <a href="http://docs.python.org/library/itertools.html">itertools</a> to compute permutations and <strong>yield</strong> keyword for generators, all N-Queen problem comes to mere 8 lines of code:</p>
<p><pre class="brush: python;">
def hit(p):
    for i in range(len(p) - 1):
        for j in range(i + 1, len(p)):
            if j - i == abs(p[i] - p[j]): return True
    return False

def n_queen(n):
    for p in itertools.permutations(range(n)):
        if not hit(p): yield p
</pre></p>
<p>One may add just a bit more code to print the board like this:</p>
<p><pre class="brush: python;">
base_char = ord('A')

def print_board(s):
    end = len(s)
    board = ['   '.join([str(i) for i in range(1, end + 1)]) + '\n']
    for i, r in enumerate(s):
        board += &quot;%s: %s * %s\n&quot; % (chr(base_char+i), (' - ' * r), (' - ' * (end - r - 1)))
    return ''.join(board)

def solve(n):
    count = 0
    for s in n_queen(n):
        count += 1
        print &quot;==== solution %d =====&quot; % count
        print s
        print print_board(s)
    return count
</pre></p>
<p>I used this code snippet to compare Python 2.6.5 with PyPy 1.5.0 JIT. It is interesting that for this CPU intensive problem, Python does not use all 100% CPU in User space and only about 30% of CPU usage is spent in User space and the rest 70% for System and Nice while PyPy dedicated most of CPU cycles to User CPU and hence finished up much faster.</p>
<p>Here are my results in an old single core 1.7G Pentium M processor. I expect PyPy JIT to do even better in a modern SSE-2 multi-core processor.</p>
<p><pre class="brush: plain;">
# board count cpython2.6.5 pypy1.5
5 10 0.012 0.007
6 4 0.048 0.064
7 40 0.327 0.224
8 92 1.556 0.562
9 352 15.207 3.685
10 724 156.736 37.676
11 2680 1723.404 427.216
</pre></p>
<p>Bellow is the chart comparing the performance upon above benchmark:<br />
<a href="http://aminsblog.files.wordpress.com/2011/05/n-queen-python-vs-pypy.jpg"><img class="alignnone size-full wp-image-252" title="n queen python vs pypy" src="http://aminsblog.files.wordpress.com/2011/05/n-queen-python-vs-pypy.jpg?w=497&#038;h=310" alt="" width="497" height="310" /></a></p>
<p>Next I tried to speed up the code by making a minor change in <strong>hit()</strong> method. To prevent <em>len(p)</em> call I passed the length as argument and replaced <em>abs()</em> call with a check for both positive and negative results. These two simple changes as bellow made the code almost 3 times faster:</p>
<p><pre class="brush: python;">
def hit(p, n):
    for i in range(n - 1):
        for j in range(i + 1, n):
            d = p[i] - p[j]
            if j - i == d or i - j == d: return True
    return False

def n_queen(n):
    for p in itertools.permutations(range(n)):
        if not hit(p, n): yield p
</pre></p>
<p>I was expecting the PyPy fail to speed up the execution times as it did for basic code but amazingly the second code&#8217;s speed up is even better in PyPy.</p>
<p style="text-align:left;"><a href="http://aminsblog.files.wordpress.com/2011/05/n-queen-python-vs-pypy-21.jpg"><img class="aligncenter size-full wp-image-261" title="n-queen-python-vs-pypy-2" src="http://aminsblog.files.wordpress.com/2011/05/n-queen-python-vs-pypy-21.jpg?w=497&#038;h=310" alt="" width="497" height="310" /></a><strong></strong></p>
<p style="text-align:left;"><strong>Update 31 May 2011</strong> :<br />
Just one update which seemed necessary, back to some comments to this post and also in <a href="http://news.ycombinator.com/item?id=2597325">YCombinator news forum</a>, it is obvious that what I proposed above was not an optimal solution for N-Queen. In fact N-Queen is a classic backtracking problem and can be solved much efficiently using BT but what I tried to show was <strong>1st</strong> the power of Python generators and itertools to solve this problem is a few lines (while preserving simplicity) and <strong>2nd</strong> using this CPU intensive brute-force search to compare CPython and PyPy implementations.</p>
<p style="text-align:left;">So I decided to mention a backtracking implementation which solves the problem much much faster and easily covers boards of size up to 14.</p>
<p><pre class="brush: python;">
def last_one_hits(answers, size):
    i = size - 1
    x, j = answers[i], 0
    for y in answers[:i]:
        d = x - y
        if x == y or i - j == d or j - i == d: return True
        j += 1
    return False

def n_queen_bt(n):
    found = [0] * n # initiate an answer of size n
    size = 1 # in start, we have 1 queen in cloumn/row (0,0)

    while size &gt; 0:
        hits = last_one_hits(found, size) # new queen hits prevs

        if size == n and not hits: #full and does not hit
            yield found

        if size &lt; n and not hits: #not full or hit, add a new
            found[size] = 0
            size += 1
        else:
            while size &gt; 0: #move last or maybe the ones before
                found[size-1] += 1
                if found[size-1] == n: #end of this clmn,go back
                    size -= 1
                else:
                    break #did the movement job, let's continue
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aminsblog.wordpress.com/251/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aminsblog.wordpress.com/251/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aminsblog.wordpress.com/251/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aminsblog.wordpress.com/251/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/aminsblog.wordpress.com/251/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/aminsblog.wordpress.com/251/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/aminsblog.wordpress.com/251/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/aminsblog.wordpress.com/251/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aminsblog.wordpress.com/251/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aminsblog.wordpress.com/251/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aminsblog.wordpress.com/251/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aminsblog.wordpress.com/251/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aminsblog.wordpress.com/251/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aminsblog.wordpress.com/251/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=251&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://aminsblog.wordpress.com/2011/05/29/n-queen-problem-python-2-6-5-vs-pypy-1-5-0/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/93b11ccaf90fc2d16e8a28a0291d8517?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">abbaspour</media:title>
		</media:content>

		<media:content url="http://aminsblog.files.wordpress.com/2011/05/n-queen-python-vs-pypy.jpg" medium="image">
			<media:title type="html">n queen python vs pypy</media:title>
		</media:content>

		<media:content url="http://aminsblog.files.wordpress.com/2011/05/n-queen-python-vs-pypy-21.jpg" medium="image">
			<media:title type="html">n-queen-python-vs-pypy-2</media:title>
		</media:content>
	</item>
		<item>
		<title>Python Permutation Generation Algorithms Comparison</title>
		<link>http://aminsblog.wordpress.com/2011/05/24/python-permutation-generation-algorithms-comparison/</link>
		<comments>http://aminsblog.wordpress.com/2011/05/24/python-permutation-generation-algorithms-comparison/#comments</comments>
		<pubDate>Tue, 24 May 2011 05:46:29 +0000</pubDate>
		<dc:creator>abbaspour</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://aminsblog.wordpress.com/?p=248</guid>
		<description><![CDATA[In regard to ActiveState topic here:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=248&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In regard to ActiveState topic <a href="http://code.activestate.com/recipes/190465-generator-for-permutations-combinations-selections/">here</a>:</p>
<p><a href="http://aminsblog.files.wordpress.com/2011/05/perm_plot.jpeg"><img src="http://aminsblog.files.wordpress.com/2011/05/perm_plot.jpeg?w=497&#038;h=310" alt="" title="perm plot" width="497" height="310" class="alignnone size-full wp-image-249" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aminsblog.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aminsblog.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aminsblog.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aminsblog.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/aminsblog.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/aminsblog.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/aminsblog.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/aminsblog.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aminsblog.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aminsblog.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aminsblog.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aminsblog.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aminsblog.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aminsblog.wordpress.com/248/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=248&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://aminsblog.wordpress.com/2011/05/24/python-permutation-generation-algorithms-comparison/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/93b11ccaf90fc2d16e8a28a0291d8517?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">abbaspour</media:title>
		</media:content>

		<media:content url="http://aminsblog.files.wordpress.com/2011/05/perm_plot.jpeg" medium="image">
			<media:title type="html">perm plot</media:title>
		</media:content>
	</item>
		<item>
		<title>WebSphere 6.1 JMS with Standalone Java and Spring Clients</title>
		<link>http://aminsblog.wordpress.com/2011/05/23/websphere-6-1-jms-with-standalone-java-and-spring-clients/</link>
		<comments>http://aminsblog.wordpress.com/2011/05/23/websphere-6-1-jms-with-standalone-java-and-spring-clients/#comments</comments>
		<pubDate>Mon, 23 May 2011 05:13:56 +0000</pubDate>
		<dc:creator>abbaspour</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://aminsblog.wordpress.com/2011/05/23/websphere-6-1-jms-with-standalone-java-and-spring-clients/</guid>
		<description><![CDATA[There are many resources on configuring JMS based applications in IBM WebSphere but most of them do not cover stand-alone clients. Here is a very small sample J2SE standalone Java application which lookups webSphere JMS JNDI resources and interacts with them both directly classic Java and Spring 2.5 JMS API. Steup Reources: To setup JMS [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=240&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are many resources on configuring JMS based applications in IBM WebSphere but most of them do not cover stand-alone clients. Here is a very small sample J2SE standalone Java application which lookups webSphere JMS JNDI resources and interacts with them both directly classic Java and Spring 2.5 JMS API.</p>
<h1>Steup Reources:</h1>
<p>To setup JMS Queues and Connection Factories in IBM WebSphere 6.1 you<br />
may visit <a href="http://wiki.ivonet.nl/display/howto/Java+Messaging+Service+Queues+on+WebSphere+6.1">here</a>.</p>
<h1>Download J2SE Client libs:</h1>
<p>Also need to download <a href="http://www-01.ibm.com/support/docview.wss?uid=swg24012804">IBM Client for JMS on J2SE with IBM WebSphere Application Server</a>.</p>
<h1>Main Application:</h1>
<p>Now that you have JMS resources and unziped Client libraries, here is a sample code to:</p>
<p><pre class="brush: java;">
package au.com.osaglobal;

import org.apache.log4j.Logger;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Hashtable;

/**
* Note: Compile and run this with IBM JDK in ~/IBM/WebSphere6.1/java */
public class App {

private static final Logger log = Logger.getLogger(App.class);

public static void publish() {
final Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY,
&quot;com.ibm.websphere.naming.WsnInitialContextFactory&quot;);
env.put(Context.PROVIDER_URL, &quot;iiop://localhost:2810&quot;);

final Context jndiContext;
try {
jndiContext = new InitialContext(env);
} catch (NamingException e) {
log.error(&quot;Could not create JNDI API context: &quot; + e.toString(), e); System.exit(1);
return;
}

try {
ConnectionFactory connectionFactory = (ConnectionFactory) jndiContext.lookup(&quot;jms/queueConnectionFactory&quot;);
Connection qConn = connectionFactory.createConnection(); Session qSession = qConn.createSession(false,
Session.AUTO_ACKNOWLEDGE);
Queue q = (Queue) jndiContext.lookup(&quot;jms/inQueue&quot;);

MessageProducer producer = qSession.createProducer(q); TextMessage message = qSession.createTextMessage(); message.setText(&quot;test message&quot;);
producer.send(message);

producer.close();
qSession.close();
qConn.close();
} catch (Exception e) {
log.error(&quot;Could not perfrom JMS operation: &quot; + e.toString(), e); System.exit(2);
}
}

private static void spring_receiver() {
new ClassPathXmlApplicationContext(new
String[]{&quot;applicationContext.xml&quot;});
}

public static void main(String[] args) {
publish();
//spring_receiver();
}
}
</pre></p>
<h1>Spring Application Context</h1>
<p><pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
       xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot;&gt;

    &lt;bean id=&quot;jndiTemplate&quot; class=&quot;org.springframework.jndi.JndiTemplate&quot;&gt;
        &lt;property name=&quot;environment&quot;&gt;
            &lt;props&gt;
                &lt;prop key=&quot;java.naming.factory.initial&quot;&gt;com.ibm.websphere.naming.WsnInitialContextFactory&lt;/prop&gt;
                &lt;prop key=&quot;java.naming.provider.url&quot;&gt;iiop://localhost:2810&lt;/prop&gt;
            &lt;/props&gt;
        &lt;/property&gt;
    &lt;/bean&gt;

    &lt;bean id=&quot;queueConnectionFactory&quot; class=&quot;org.springframework.jndi.JndiObjectFactoryBean&quot;&gt;
        &lt;property name=&quot;jndiTemplate&quot; ref=&quot;jndiTemplate&quot;/&gt;
        &lt;property name=&quot;jndiName&quot; value=&quot;jms/queueConnectionFactory&quot;/&gt;
    &lt;/bean&gt;

    &lt;bean id=&quot;inQueue&quot; class=&quot;org.springframework.jndi.JndiObjectFactoryBean&quot;&gt;
        &lt;property name=&quot;jndiTemplate&quot; ref=&quot;jndiTemplate&quot;/&gt;
        &lt;property name=&quot;jndiName&quot; value=&quot;jms/inQueue&quot;/&gt;
    &lt;/bean&gt;

    &lt;bean class=&quot;org.springframework.jms.listener.DefaultMessageListenerContainer&quot;&gt;
        &lt;property name=&quot;destination&quot; ref=&quot;inQueue&quot;/&gt;
        &lt;property name=&quot;connectionFactory&quot; ref=&quot;queueConnectionFactory&quot;/&gt;
        &lt;property name=&quot;messageListener&quot; ref=&quot;inMessageListener&quot;/&gt;
    &lt;/bean&gt;

    &lt;bean id=&quot;inMessageListener&quot; class=&quot;au.com.osaglobal.JmsReceiver&quot;/&gt;
&lt;/beans&gt;
</pre></p>
<h1>Jms Receiver Object</h1>
<p><pre class="brush: java;">
package au.com.osaglobal;

import org.apache.log4j.Logger;

import javax.jms.Message;
import javax.jms.MessageListener;

public class JmsReceiver implements MessageListener {

private static final Logger log = Logger.getLogger(JmsReceiver.class);

public void onMessage(Message message) {
log.info(&quot;Received message: &quot; + message);
}
}
</pre></p>
<h1>Log4J Properties</h1>
<p><pre class="brush: plain;">
log4j.rootCategory=DEBUG, S

log4j.appender.S=org.apache.log4j.ConsoleAppender
log4j.appender.S.layout=org.apache.log4j.PatternLayout
log4j.appender.S.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n
</pre></p>
<h1>Maven Project pom.xml And Dependencies </h1>
<p><pre class="brush: xml;">
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

    &lt;groupId&gt;au.com.osaglobal&lt;/groupId&gt;
    &lt;artifactId&gt;sample-spring-was-jms&lt;/artifactId&gt;
    &lt;version&gt;1.0&lt;/version&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;

    &lt;name&gt;sample-spring-was-jms&lt;/name&gt;
    &lt;url&gt;http://www.osaglobal.com.au/&lt;/url&gt;

    &lt;properties&gt;
        &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
        &lt;version.spring&gt;2.5.6&lt;/version.spring&gt;
        &lt;version.was&gt;6.1&lt;/version.was&gt;
    &lt;/properties&gt;

    &lt;dependencies&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;log4j&lt;/groupId&gt;
            &lt;artifactId&gt;log4j&lt;/artifactId&gt;
            &lt;version&gt;1.2.14&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;!-- javax.jms api --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.geronimo.specs&lt;/groupId&gt;
            &lt;artifactId&gt;geronimo-jms_1.1_spec&lt;/artifactId&gt;
            &lt;version&gt;1.1.1&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;!-- Springs 2.5.6 (core, beans, jms) --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
            &lt;version&gt;${version.spring}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
            &lt;version&gt;${version.spring}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-jms&lt;/artifactId&gt;
            &lt;version&gt;${version.spring}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;!-- WebSphere 6.1 (rt, mq, mqjms, thinclient) --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.ibm.websphere&lt;/groupId&gt;
            &lt;artifactId&gt;runtime&lt;/artifactId&gt;
            &lt;version&gt;${version.was&lt;/version&gt;
            &lt;scope&gt;system&lt;/scope&gt;
            &lt;systemPath&gt;/home/amin/IBM/WebSphere6.1/AppServer1/deploytool/ itp/plugins/com.ibm.websphere.v61_6.1.0/ws_runtime.jar&lt;/systemPath&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;com.ibm.mq&lt;/groupId&gt;
            &lt;artifactId&gt;mq&lt;/artifactId&gt;
            &lt;version&gt;${version.was}&lt;/version&gt;
            &lt;scope&gt;system&lt;/scope&gt;
            &lt;systemPath&gt;/home/amin/IBM/WebSphere6.1/AppServer1/lib/WMQ/java/ lib/com.ibm.mq.jar&lt;/systemPath&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;com.ibm.mq&lt;/groupId&gt;
            &lt;artifactId&gt;mqjms&lt;/artifactId&gt;
            &lt;version&gt;${version.was}&lt;/version&gt;
            &lt;scope&gt;system&lt;/scope&gt;
            &lt;systemPath&gt;/home/amin/IBM/WebSphere6.1/AppServer1/lib/WMQ/java/ lib/com.ibm.mqjms.jar&lt;/systemPath&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;com.ibm.mq&lt;/groupId&gt;
            &lt;artifactId&gt;dhbcore&lt;/artifactId&gt;
            &lt;version&gt;${version.was}&lt;/version&gt;
            &lt;scope&gt;system&lt;/scope&gt;
            &lt;systemPath&gt;/home/amin/IBM/WebSphere6.1/AppServer1/lib/WMQ/java/ lib/dhbcore.jar&lt;/systemPath&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;com.ibm.ws.webservices&lt;/groupId&gt;
            &lt;artifactId&gt;thinclient&lt;/artifactId&gt;
            &lt;version&gt;${version.was}&lt;/version&gt;
            &lt;scope&gt;system&lt;/scope&gt;
            &lt;systemPath&gt;/home/amin/IBM/WebSphere6.1/AppServer1/runtimes/ com.ibm.ws.webservices.thinclient_6.1.0.jar&lt;/systemPath&gt;
        &lt;/dependency&gt;

        &lt;!-- IBM Client for JMS on J2SE with IBM WebSphere Application Server --&gt;
        &lt;!-- see: http://www-01.ibm.com/support/docview.wss?uid=swg24012804 --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.ibm.sibc&lt;/groupId&gt;
            &lt;artifactId&gt;sibc.jms&lt;/artifactId&gt;
            &lt;version&gt;6.1&lt;/version&gt;
            &lt;scope&gt;system&lt;/scope&gt;
            &lt;systemPath&gt;/home/amin/IBM/sibc/sibc.jms.jar&lt;/systemPath&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;com.ibm.sibc&lt;/groupId&gt;
            &lt;artifactId&gt;sibc.jndi&lt;/artifactId&gt;
            &lt;version&gt;6.1&lt;/version&gt;
            &lt;scope&gt;system&lt;/scope&gt;
            &lt;systemPath&gt;/home/amin/IBM/sibc/sibc.jndi.jar&lt;/systemPath&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;com.ibm.sibc&lt;/groupId&gt;
            &lt;artifactId&gt;sibc.orb&lt;/artifactId&gt;
            &lt;version&gt;6.1&lt;/version&gt;
            &lt;scope&gt;system&lt;/scope&gt;
            &lt;systemPath&gt;/home/amin/IBM/sibc/sibc.orb.jar&lt;/systemPath&gt;
        &lt;/dependency&gt;

    &lt;/dependencies&gt;
&lt;/project&gt;
</pre></p>
<p>Note: You will need to fix <strong>systemPath</strong> to fit your installation. Now can submit and receive simply by (un)commenting related methods in main().</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aminsblog.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aminsblog.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aminsblog.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aminsblog.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/aminsblog.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/aminsblog.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/aminsblog.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/aminsblog.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aminsblog.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aminsblog.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aminsblog.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aminsblog.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aminsblog.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aminsblog.wordpress.com/240/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=240&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://aminsblog.wordpress.com/2011/05/23/websphere-6-1-jms-with-standalone-java-and-spring-clients/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/93b11ccaf90fc2d16e8a28a0291d8517?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">abbaspour</media:title>
		</media:content>
	</item>
		<item>
		<title>IKM Java (J2SE 5.0) Test Results</title>
		<link>http://aminsblog.wordpress.com/2011/05/13/ikm-java-j2se-5-0-test-results/</link>
		<comments>http://aminsblog.wordpress.com/2011/05/13/ikm-java-j2se-5-0-test-results/#comments</comments>
		<pubDate>Fri, 13 May 2011 01:11:43 +0000</pubDate>
		<dc:creator>abbaspour</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://aminsblog.wordpress.com/?p=235</guid>
		<description><![CDATA[A few weeks ago I had a Java Programming Test via International Knowledge Measurement (IKM) institute. To be honest tests were tough each with 5 answers out of which up to 3 could be correct. I tried to focus and do my best. Just jumped over GUI programming topics to get some more time for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=235&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I had a Java Programming Test via International Knowledge Measurement (IKM) institute. To be honest tests were tough each with 5 answers out of which up to 3 could be correct. I tried to focus and do my best. Just jumped over GUI programming topics to get some more time for core questions. Code indentation in most of questions was intentionally wrong which made the analysis of code even harder. Here is my result:</p>
<p><a href="http://aminsblog.files.wordpress.com/2011/05/aminabbaspour_ikm_j2se5_result.jpg"><img class="alignnone size-full wp-image-236" title="aminabbaspour ikm j2se5 result" src="http://aminsblog.files.wordpress.com/2011/05/aminabbaspour_ikm_j2se5_result.jpg?w=497&#038;h=644" alt="" width="497" height="644" /></a></p>
<p>It is somehow even better than what I was expecting. It&#8217;s interesting that I believe to be very good at threading but I don&#8217;t know why result does not reflect this. Anyway, IMHO this is one of the good results one has achieved in IKM J2SE :) Wont believe me unless you take this hard test yourself!</p>
<p><strong>Update 17 July 2011</strong>: For those friends whom ask for sample questions, well I don&#8217;t have any but bellow documents seem of great help:</p>
<ul>
<li><a href="http://download.oracle.com/javase/1.5.0/docs/api/">Java JDK Documents (javadoc)</a></li>
<li><a href="http://www.mindview.net/Books/TIJ/">Thinking in Java</a></li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0471237515/jr_bunk-20">More Java Pitfalls</a></li>
<li><a href="http://www.javapuzzlers.com/">Java Puzzlers</a></li>
<li><a href="http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683">Effective Java</a></li>
<li><a href="http://www.amazon.com/SCJP-Certified-Programmer-Java-310-065/dp/0071591060">SCJP Sun Certified Programmer for Java 6 Exam</a></li>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aminsblog.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aminsblog.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aminsblog.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aminsblog.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/aminsblog.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/aminsblog.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/aminsblog.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/aminsblog.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aminsblog.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aminsblog.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aminsblog.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aminsblog.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aminsblog.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aminsblog.wordpress.com/235/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=235&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://aminsblog.wordpress.com/2011/05/13/ikm-java-j2se-5-0-test-results/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/93b11ccaf90fc2d16e8a28a0291d8517?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">abbaspour</media:title>
		</media:content>

		<media:content url="http://aminsblog.files.wordpress.com/2011/05/aminabbaspour_ikm_j2se5_result.jpg" medium="image">
			<media:title type="html">aminabbaspour ikm j2se5 result</media:title>
		</media:content>
	</item>
		<item>
		<title>Cheap Human Lives in My Land Iran</title>
		<link>http://aminsblog.wordpress.com/2011/01/19/cheap-human-lives-in-my-land-iran/</link>
		<comments>http://aminsblog.wordpress.com/2011/01/19/cheap-human-lives-in-my-land-iran/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 13:10:13 +0000</pubDate>
		<dc:creator>abbaspour</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://aminsblog.wordpress.com/2011/01/19/cheap-human-lives-in-my-land-iran/</guid>
		<description><![CDATA[Again a plane crashes in the holy land of Iran, and while soon after publishing this news it&#8217;s in the headline of all broadcastings around the world, it this country itself it&#8217;s not yet as important as what leader says or arresting an Israeli spy. Soon after the incident Mr.Behbahani &#8211; our superb minister finds [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=233&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Again a plane crashes in the holy land of Iran, and while soon after publishing this news it&#8217;s in the headline of all broadcastings around the world, it this country itself it&#8217;s not yet as important as what leader says or arresting an Israeli spy.</p>
<p>Soon after the incident Mr.Behbahani &#8211; our superb minister finds out the reasons:</p>
<p>&#8220;<br />
It&#8217;s a good news in fact since unlike recent crashes, this time plane did not explode and most of passengers (33 out of 105) are yet alive. Reason was merely the poor weather not our 40 years old plane nor the airport which lacks any auto pilot infrastructure.<br />
And yet US is the as responsible as bad weather since their sanctions prevents us from buying planes, hence we have to invest this budget in nuclear bombs, to force them change this behavior in the future. and by the way, martyrdomed people are as much responsible as as poor weather and Sam, since we already told them this plane has issues, but they were so eager for martyrdom that forced us hope them in the plane.<br />
he finishes his words by noting that while we handle around 30% of world plane crash share in recent years we are still among the worlds safest airlines and I am ready to go to parliament and tell this to those who don&#8217;t understand. plane crash is something normal and I am so amazed why the wanna probe it every time happens.<br />
&#8220;</p>
<p>Yes dude. this is the land I am running off. Land where alives are unimportant regular moving object and deaths are praised to its full. A good Iranian citizen is a death one.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aminsblog.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aminsblog.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aminsblog.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aminsblog.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/aminsblog.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/aminsblog.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/aminsblog.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/aminsblog.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aminsblog.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aminsblog.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aminsblog.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aminsblog.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aminsblog.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aminsblog.wordpress.com/233/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=233&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://aminsblog.wordpress.com/2011/01/19/cheap-human-lives-in-my-land-iran/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/93b11ccaf90fc2d16e8a28a0291d8517?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">abbaspour</media:title>
		</media:content>
	</item>
		<item>
		<title>A web.py ZooKeeper Browser in 50 lines!</title>
		<link>http://aminsblog.wordpress.com/2010/12/24/a-web-py-zookeeper-browser-in-50-lines/</link>
		<comments>http://aminsblog.wordpress.com/2010/12/24/a-web-py-zookeeper-browser-in-50-lines/#comments</comments>
		<pubDate>Fri, 24 Dec 2010 20:55:04 +0000</pubDate>
		<dc:creator>abbaspour</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://aminsblog.wordpress.com/?p=216</guid>
		<description><![CDATA[Since my last post, we started shifting to Apache ZooKeeper gradually. It&#8217;s a great tool for distributed computing. I committed a very simple web based zookeeper browser console into github. Source code is available at https://github.com/abbaspour/zkbrowser-lite It requires zookeeper python binding and web.py. I call it lite browser since I may commit another version with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=216&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Since my last post, we started shifting to <a href="http://hadoop.apache.org/zookeeper/">Apache ZooKeeper</a> gradually. It&#8217;s a great tool for distributed computing. </p>
<p>I committed a very simple web based zookeeper browser console into github. Source code is available at <a href="https://github.com/abbaspour/zkbrowser-lite">https://github.com/abbaspour/zkbrowser-lite</a></p>
<p>It requires zookeeper python binding and web.py. I call it lite browser since I may commit another version with more feature soon.</p>
<p>It&#8217;s interesting that the LOC is very small:<br />
<code>wc -l *.py templates/page.html<br />
  21 code.py<br />
  16 zk.py<br />
  13 templates/page.html<br />
  50 total</code></p>
<p>Here is an snapshot:<br />
<img alt="" src="http://aminsblog.files.wordpress.com/2010/12/zkbrowser-lite.png?w=468&#038;h=351" title="zookeeper browser" class="alignnone" width="468" height="351" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aminsblog.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aminsblog.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aminsblog.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aminsblog.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/aminsblog.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/aminsblog.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/aminsblog.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/aminsblog.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aminsblog.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aminsblog.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aminsblog.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aminsblog.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aminsblog.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aminsblog.wordpress.com/216/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=216&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://aminsblog.wordpress.com/2010/12/24/a-web-py-zookeeper-browser-in-50-lines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/93b11ccaf90fc2d16e8a28a0291d8517?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">abbaspour</media:title>
		</media:content>

		<media:content url="http://aminsblog.files.wordpress.com/2010/12/zkbrowser-lite.png" medium="image">
			<media:title type="html">zookeeper browser</media:title>
		</media:content>
	</item>
		<item>
		<title>JGroups; Hopes and Regrets</title>
		<link>http://aminsblog.wordpress.com/2010/10/16/jgroups-hopes-and-regrets/</link>
		<comments>http://aminsblog.wordpress.com/2010/10/16/jgroups-hopes-and-regrets/#comments</comments>
		<pubDate>Sat, 16 Oct 2010 12:16:57 +0000</pubDate>
		<dc:creator>abbaspour</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://aminsblog.wordpress.com/2010/10/16/jgroups-hopes-and-regrets/</guid>
		<description><![CDATA[Undoubtedly JGroups is a great framework. For me, it&#8217;s a hidden gem that always helps me build distributed systems. Although it&#8217;s usually considered as a building block not a high-level framework, but I&#8217;ve always preferred to use it directly rather than nice wrappers such as Coherence and JBossCache/Infinispan or GridGain. Now after running my third [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=211&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Undoubtedly JGroups is a great framework. For me, it&#8217;s a hidden gem that always helps me build distributed systems. Although it&#8217;s usually considered as a building block not a high-level framework, but I&#8217;ve always preferred to use it directly rather than nice wrappers such as Coherence and JBossCache/Infinispan or GridGain.</p>
<p>Now after running my third project project on top of it, I&#8217;ve got better feeling of it&#8217;s pros and cons.</p>
<p>You know, the great thing behind JGroups is that it hits its goal quite well. The goal is to have a Java Group Communication framework and JGroups does this very well.</p>
<p>We are setting up a large cluster for Image processing. The nodes count in the initial demo is only 128 but it may soon increase to 2K in later setups. Configuring JGroups to run in such an environment not an easy task at all. One need to have deep understanding of UDP/IP and Java internals to get the results. This is maybe one minor deficiency of JGroups but it&#8217;s bearable due.</p>
<p>The second issue is all about that big &#8216;J&#8217; :) IMHO JGroups is far beyond a framework just to be limited to Java. JGroups highly depends on Java and it&#8217;s serialization and the commiters do not seem to be much interested to standards communication stack and and permit pluggable serialization mechanism. Something somehow similar to Inifispan HotRod.</p>
<p>For example, we have noticed that our native image processing code running better in SMP machines with Python/SWIG than Java/JNA/JNI but there is almost no way to keep servers in Java and switch clients to Python.</p>
<p>This sometimes makes me think of switching to ZooKeeper/Google Protocol Buffer rather than staying with JGroups. I don&#8217;t know till when I can resist it :) Recently I saw a LinkedIn project called <a href="http://sna-projects.com/norbert/">Norbet</a> that is almost exactly what I had in mind, but will ZK give me a fast distributed hash map like JGroups? Norbet code base is young but definitely deserves a try.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aminsblog.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aminsblog.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aminsblog.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aminsblog.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/aminsblog.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/aminsblog.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/aminsblog.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/aminsblog.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aminsblog.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aminsblog.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aminsblog.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aminsblog.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aminsblog.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aminsblog.wordpress.com/211/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=211&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://aminsblog.wordpress.com/2010/10/16/jgroups-hopes-and-regrets/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/93b11ccaf90fc2d16e8a28a0291d8517?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">abbaspour</media:title>
		</media:content>
	</item>
		<item>
		<title>The waiting is over; I got Australia Immigration Visa</title>
		<link>http://aminsblog.wordpress.com/2010/10/01/the-waiting-is-over-i-got-australia-immigration-visa/</link>
		<comments>http://aminsblog.wordpress.com/2010/10/01/the-waiting-is-over-i-got-australia-immigration-visa/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 21:47:58 +0000</pubDate>
		<dc:creator>abbaspour</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://aminsblog.wordpress.com/2010/10/01/the-waiting-is-over-i-got-australia-immigration-visa/</guid>
		<description><![CDATA[Yesterday I received Australia Visa grant letter. It was a pleasant moment. A moment that I was dreaming of for years&#8230; There is a lot to be done and I should work hard before leaving, but this is great and sweet feeling. Thanks God and all whom helped me through this path&#8230;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=210&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yesterday I received Australia Visa grant letter. It was a pleasant moment. A moment that I was dreaming of for years&#8230;<br />
There is a lot to be done and I should work hard before leaving, but this is great and sweet feeling. Thanks God and all whom helped me through this path&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aminsblog.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aminsblog.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aminsblog.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aminsblog.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/aminsblog.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/aminsblog.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/aminsblog.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/aminsblog.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aminsblog.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aminsblog.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aminsblog.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aminsblog.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aminsblog.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aminsblog.wordpress.com/210/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=210&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://aminsblog.wordpress.com/2010/10/01/the-waiting-is-over-i-got-australia-immigration-visa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/93b11ccaf90fc2d16e8a28a0291d8517?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">abbaspour</media:title>
		</media:content>
	</item>
		<item>
		<title>Checking Malicious Uploaded Content in just one line of Bash</title>
		<link>http://aminsblog.wordpress.com/2010/09/22/checking-malicious-uploaded-content-in-just-one-line-of-bash/</link>
		<comments>http://aminsblog.wordpress.com/2010/09/22/checking-malicious-uploaded-content-in-just-one-line-of-bash/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 15:24:58 +0000</pubDate>
		<dc:creator>abbaspour</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://aminsblog.wordpress.com/2010/09/22/checking-malicious-uploaded-content-in-just-one-line-of-bash/</guid>
		<description><![CDATA[Today I was in Payamnour University site. They have a registration system this year in which students upload document images for further review. After I fixed performance issues preventing proper usage in the initial days of registration system (fixing mysql/php/apache/etc) I sat and wrote this small one line bash scripts which checks if all the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=200&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I was in <a href="http://tpnu.ac.ir/">Payamnour University</a> site. They have <a href="http://reg.tpnu.ac.ir/">a registration system</a> this year in which students upload document images for further review.</p>
<p>After I fixed performance issues preventing proper usage in the initial days of registration system (fixing mysql/php/apache/etc) I sat and wrote this small one line bash scripts which checks if all the uploaded files are images in fact.</p>
<p><pre class="brush: bash;">
for a in *; do file &quot;$a&quot; | grep image -i &gt; /dev/null; if [ $? != 0 ]; then echo &quot;*** $a --&gt; Check it! ***&quot;; else echo -n &quot;.&quot;; fi; done
</pre></p>
<p>Bash is a great tool :)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aminsblog.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aminsblog.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aminsblog.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aminsblog.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/aminsblog.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/aminsblog.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/aminsblog.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/aminsblog.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aminsblog.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aminsblog.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aminsblog.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aminsblog.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aminsblog.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aminsblog.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aminsblog.wordpress.com&amp;blog=3567301&amp;post=200&amp;subd=aminsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://aminsblog.wordpress.com/2010/09/22/checking-malicious-uploaded-content-in-just-one-line-of-bash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/93b11ccaf90fc2d16e8a28a0291d8517?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">abbaspour</media:title>
		</media:content>
	</item>
	</channel>
</rss>
