<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><title>Atlas365.com - Blog</title><link>http://www.atlas365.com</link><pubDate>Tue Apr 26 07:27:21 PDT 2011</pubDate><language>en</language><image><link>http://www.atlas365.com</link><url>http://www.atlas365.com/images/blog.png</url></image><item><title>Perl, How to Load parameters from config file</title><link>http://www.atlas365.com/blog/2011/perl-how-to-load-parameters-from-config-file</link><pubDate>Tue Apr 26 07:27:21 PDT 2011</pubDate><description>&lt;p&gt;The easy solution for Perl to have any configuration parameters of your application in a file&lt;/p&gt;
&lt;pre&gt;#!/usr/bin/perl

my %config = load_config(&quot;/etc/perl_application.conf&quot;);

sub load_config {
        my $conf_name = $_[0];
        my %config = {};
        open(CFG, &quot;&amp;lt;&quot;.$conf_name);
        while() {
                chomp;
                my ($var, $val) = split(/\s*\=\s*/);
                if ($val eq 'true') { $config{$var} = true; }
                if ($val eq 'false') { $config{$var} = false; }
                if (($var=~/^\#/is) || ($var eq '')) { } else { $config{$var} = $val; }
        }
        close(CFG);

# Dump config file

        foreach my $key (keys %config) {
        if ($key=~/^HASH/is) { } else {
                      print $key.&quot;: &quot;.$config{$key}.&quot;\n&quot;;
              }
        }
        return %config;
}

&lt;/pre&gt;
&lt;p&gt;perl_application.conf&lt;/p&gt;
&lt;pre&gt;# MongoDB Settings
mongo_host = 127.0.0.1
mongo_port = 27017
mongo_database = atlas365
mongo_auth = false

# MySQL Settings
mysql_host = 127.0.0.1
mysql_port = 3306
mysql_database = atlas365
mysql_username = mysqlusr
mysql_password = mysqlpswd
&lt;/pre&gt;</description></item><item><title>How to change DOCUMENT_ROOT for PHP</title><link>http://www.atlas365.com/blog/2011/how-to-change-document-root-for-php</link><pubDate>Fri Apr 22 01:22:49 PDT 2011</pubDate><description>&lt;p&gt;If you are running into issues with the $_SERVER[&quot;DOCUMENT_ROOT&quot;]  variable showing &quot;/usr/local/data/www/&quot;; when using  PHP5 and need to have it point to your correct document root for your application, here is a simple tutorial for changing it.&lt;/p&gt;
&lt;p&gt;Create a file document_root.php into your root application directory with follow the code:&lt;/p&gt;
&lt;pre&gt;&amp;lt;?
$_SERVER[&quot;DOCUMENT_ROOT&quot;]  = &quot;/vhosts/domain.com/&quot;
?&amp;gt;&lt;/pre&gt;
&lt;p&gt;Add to your root application directory .htaccess with follow the code&lt;/p&gt;
&lt;pre&gt;php_value	auto_prepend_file	&quot;/vhosts/domain.com/document_root.php&quot;&lt;/pre&gt;
&lt;p&gt;This tells Apache to parse the document_root.php file before doing  anything else.&lt;/p&gt;</description></item><item><title>Adding SPF support for Exim</title><link>http://www.atlas365.com/blog/2011/adding-spf-support-for-exim</link><pubDate>Mon Apr 18 11:08:28 PDT 2011</pubDate><description>&lt;p&gt;Adding SPF (Sender Policy Framework) support for &lt;a href=&quot;http://www.exim.org&quot; target=&quot;_blank&quot;&gt;Exim&lt;/a&gt; version 4.75&lt;/p&gt;
&lt;p&gt;To learn more about SPF, visit &lt;a href=&quot;http://www.openspf.org&quot; target=&quot;_blank&quot;&gt;http://www.openspf.org&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Before implement SPF in your Exim mail system, compile and install Exim with &lt;a href=&quot;http://www.libspf2.org/&quot; target=&quot;_blank&quot;&gt;libspf2&lt;/a&gt; library. &lt;a href=&quot;http://www.google.com/search?q=exim+install+libspf2&quot; target=&quot;_blank&quot;&gt;Google&lt;/a&gt; will help you :-)&lt;/p&gt;
&lt;p&gt;&lt;em&gt;You can now run SPF checks in incoming SMTP by using the &quot;spf&quot; ACL condition in either the MAIL, RCPT or DATA ACLs. When using it in the RCPT ACL, you can make the checks dependend on the RCPT address (or domain), so you can check SPF records only for certain target domains. This gives you the possibility to opt-out certain customers that do not want their mail to be subject to SPF checking.&lt;/em&gt;&lt;/p&gt;</description></item><item><title>Perl Net::DNS / Querying DNS Servers</title><link>http://www.atlas365.com/blog/2011/perl-net-dns-querying-dns-servers</link><pubDate>Mon Apr 18 10:33:21 PDT 2011</pubDate><description>&lt;p&gt;Perl &lt;a href=&quot;http://www.net-dns.org/&quot; target=&quot;_blank&quot;&gt;Net::DNS&lt;/a&gt; library can be used to write powerful web or OS system applications involving DNS lookups and queries. In this tutorial I will show you how to write a DNS diagnostic application involving DNS and resolver.&lt;/p&gt;</description></item><item><title>How to encode and decode Base64 in Grails, Groovy or Java</title><link>http://www.atlas365.com/blog/2011/how-to-encode-and-decode-base64-in-grails%2C-groovy-or-java</link><pubDate>Fri Mar 25 11:54:19 PDT 2011</pubDate><description>&lt;p&gt;I don't know why, but function &lt;strong&gt;decodeBase64&lt;/strong&gt; in Grails doesn't work correctly. And I found other solution. See below&lt;/p&gt;
&lt;p&gt;Now we include the base64 library&lt;/p&gt;
&lt;pre&gt;import org.apache.commons.codec.binary.Base64
&lt;/pre&gt;
&lt;p&gt;Our encode function&lt;/p&gt;
&lt;pre&gt;def encodeBase64(String text) {
	return new String(Base64.encodeBase64(text.getBytes()))
}
&lt;/pre&gt;
&lt;p&gt;Our decode function&lt;/p&gt;
&lt;pre&gt;def decodeBase64(String text) {
	return new String(Base64.decodeBase64(text))
}
&lt;/pre&gt;
&lt;p&gt;That's all&lt;/p&gt;</description></item><item><title>How to parse JSON in Grails</title><link>http://www.atlas365.com/blog/2011/how-to-parse-json-in-grails</link><pubDate>Thu Mar 24 13:49:07 PDT 2011</pubDate><description>&lt;p&gt;1. include JSON library&lt;/p&gt;
&lt;pre&gt;import grails.converters.JSON&lt;/pre&gt;
&lt;p&gt;2. use JSON library&lt;/p&gt;
&lt;pre&gt;def jsonString = '{&quot;syntax&quot;:true,&quot;email&quot;:&quot;test@test.local&quot;,&quot;status&quot;:true,&quot;domain&quot;:true}'
def json = JSON.parse(jsonString)
println json
&lt;/pre&gt;
&lt;p&gt;All records are serializabled&lt;/p&gt;
&lt;p&gt;happy end :-)&lt;/p&gt;</description></item><item><title>HTTP Request in Grails</title><link>http://www.atlas365.com/blog/2011/http-request-in-grails</link><pubDate>Thu Mar 24 04:39:53 PDT 2011</pubDate><description>&lt;p&gt;Simple function how you can make HTTP request in Grails&lt;/p&gt;
&lt;pre&gt;def httpPostRequest(String address, String data, String referer = &quot;http://www.google.com&quot;, method = &quot;POST&quot;, userAgent = &quot;Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13&quot;) {
	method = method?.toString()?.toUpperCase()
	if (method != &quot;GET&quot;) { method = &quot;POST&quot; }
	try {
		def url = new URL(address)
		def conn = url.openConnection()
		conn.setRequestMethod(method)
		conn.setRequestProperty(&quot;User-Agent&quot;, userAgent)
		conn.setRequestProperty(&quot;Referer&quot;, referer)
		conn.doOutput = true
		Writer wr = new OutputStreamWriter(conn.outputStream)
		wr.write(data)
		wr.flush()
		wr.close()
		conn.connect()
		return conn?.content?.text
	} catch (e) {
		println e
		return false
	}
}&lt;/pre&gt;
&lt;p&gt;Now, try to use our function&lt;/p&gt;
&lt;pre&gt;def content = httpPostRequest(&quot;http://www.atlas365.com&quot;, &quot;test=my%20first%20test&quot;)
if (content) { println content } else { println &quot;Error!&quot; }
&lt;/pre&gt;
&lt;p&gt;This example show us &quot;How we can get the web page http://www.atlas365.com/ by POST request with &lt;strong&gt;test&lt;/strong&gt; parameter&quot;. The &lt;strong&gt;test&lt;/strong&gt; parameter is equal &quot;&lt;strong&gt;my first test&lt;/strong&gt;&quot;&lt;/p&gt;</description></item><item><title>Grails email address validation</title><link>http://www.atlas365.com/blog/2011/grails-email-address-validation</link><pubDate>Wed Mar 23 06:43:27 PDT 2011</pubDate><description>&lt;p&gt;Perfect &lt;a href=&quot;http://www.grails.org&quot; target=&quot;_blank&quot;&gt;Grails&lt;/a&gt; plugin &quot;&lt;a href=&quot;https://github.com/tomaslin/grails-email-validator&quot; target=&quot;_blank&quot;&gt;grails email validator&lt;/a&gt;&quot;&lt;/p&gt;
&lt;p&gt;This plugin&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Check if domain exist in DNS&lt;/li&gt;
&lt;li&gt;Check domain MX records&lt;/li&gt;
&lt;li&gt;Check if email address is exist and valid&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The plugin is available on GitHub: &lt;a href=&quot;https://github.com/tomaslin/grails-email-validator&quot; target=&quot;_blank&quot;&gt;https://github.com/tomaslin/grails-email-validator&lt;/a&gt;&lt;/p&gt;</description></item><item><title>How To Get URL Parts in JavaScript</title><link>http://www.atlas365.com/blog/2011/how-to-get-url-parts-in-javascript</link><pubDate>Wed Mar 23 05:27:21 PDT 2011</pubDate><description>&lt;p&gt;The &lt;strong&gt;window.location&lt;/strong&gt; object is a JavaScript class that is used to store URLs. It comes with properties that represent each part of the URL, and can be updated by changing the &lt;strong&gt;href&lt;/strong&gt; property. The key properties that this article deals with are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;window.location.href - the full URL address&lt;/li&gt;
&lt;li&gt;window.location.protocol - the protocol what you use http or https&lt;/li&gt;
&lt;li&gt;window.location.host - the hostname (for example localhost or www.atlas365.com or different)&lt;/li&gt;
&lt;li&gt;window.location.pathname - the parts of the URL (for example index.html)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition there are various methods that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;window.location.reload() - the function for reload current webpage&lt;/li&gt;
&lt;li&gt;window.location.replace(url) - the function for change URL address // for example&nbsp;window.location.replace(&quot;http://www.atlas365.com&quot;);&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>input field restricting to numbers only</title><link>http://www.atlas365.com/blog/2011/input-field-restricting-to-numbers-only</link><pubDate>Tue Mar 22 16:14:12 PDT 2011</pubDate><description>&lt;p&gt;This page shows a technique for restricting the field to just numbers. The script also allows you to automatically jump to the next field if the user presses the decimal key.&lt;/p&gt;
&lt;p&gt;Put this JavaScript to head tag in your HTML page&lt;/p&gt;
&lt;pre&gt;&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
&amp;lt;!--
function numbersonly(inputfield, e, dec) {
	var key;
	var keychar;
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);
	if ((key == null) || (key == 0) || (key == 8) ||
		(key == 9) || (key == 13) || (key == 27))
		return true;
	else if (((&quot;0123456789&quot;).indexOf(keychar) &amp;gt; -1))
		return true;
	else if (dec &amp;amp;&amp;amp; (keychar == &quot;.&quot;)) {
		inputfield.form.elements[dec].focus();
		return false;
	}
	else
		return false;
}
//--&amp;gt;
&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Now, we will use our script in HTML form&lt;/p&gt;
&lt;pre&gt;&amp;lt;form action=&quot;/signup&quot; method=&quot;post&quot;&amp;gt;
	&amp;lt;label&amp;gt;U.S. ZIP Code:&amp;lt;/label&amp;gt;&amp;lt;input type=&quot;text&quot; name=&quot;zip&quot; size=&quot;5&quot; maxlength=&quot;5&quot; value=&quot;&quot; onKeyPress=&quot;return numbersonly(this, event)&quot;/&amp;gt;
	&amp;lt;button type=&quot;submit&quot;&amp;gt;Submit&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/pre&gt;</description></item></channel></rss>
