<?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>Bratech&#039;s Tips and Tricks</title>
	<atom:link href="http://www.bratech.ro/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.bratech.ro/blog</link>
	<description>Find out (mostly) software tips and tricks we use...</description>
	<lastBuildDate>Sat, 19 Jun 2010 21:37:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Automatically compress local JavaScript files (on an Apache server)</title>
		<link>http://www.bratech.ro/blog/?p=16</link>
		<comments>http://www.bratech.ro/blog/?p=16#comments</comments>
		<pubDate>Sat, 19 Jun 2010 21:37:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[optimizations]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://www.bratech.ro/blog/?p=16</guid>
		<description><![CDATA[One of the most recommended (and easiest to implement) techniques for web pages optimization is compressing the CSS and JavaScript files used. While this is not a particularly difficult thing to do manually (for example, using the YUI compressor found here), when releasing a new version on the live server, it would be much easier [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most recommended (and easiest to implement) techniques for web pages optimization is compressing the CSS and JavaScript files used.</p>
<p>While this is not a particularly difficult thing to do manually (for example, using the YUI compressor found <a title="Online YUI Compressor" href="http://www.refresh-sf.com/yui/" target="_blank">here</a>), when releasing a new version on the live server, it would be much easier to use an automated method that allows you to write the JavaScript in your own development style (using comments and a more loose formatting), and serve it directly compressed to the browser, on request.</p>
<p>Well&#8230; wonder no more! We&#8217;re going to present an easy and bullet-proof method of doing just that, on an Apache web server. For this purpose, we&#8217;re going to use <a title="/packer/" href="http://dean.edwards.name/packer/" target="_blank">Dean Edwards JavaScript&#8217;s Packer class</a>, more precisely its PHP version, &#8220;translated&#8221; by <a title="Packer JavaScript in PHP" href="http://joliclic.free.fr/php/javascript-packer/en/" target="_blank">Nicolas Martin</a>.</p>
<p>You&#8217;re going to have to add it to your JavaScript folder (assuming you have such a folder in your project, otherwise&#8230; add it in your common folder, or&#8230; wherever you want). In the same folder, you have to add an index.php file that will load this PHP class and use it to dynamically compress your JS files.</p>
<p>The content of the JS folder&#8217;s index.php file should be something like</p>
<blockquote><p>if(!empty($_GET['script']) &amp;&amp; is_file($_GET['script'] . &#8216;.js&#8217;)){<br />
require_once &#8216;/relative/path/to/JavaScriptPacker.class.php&#8217;;</p>
<p>$script = file_get_contents($_GET['script'] . &#8216;.js&#8217;);</p>
<p>$packer = new JavaScriptPacker($script, 62, true, false); // Default configuration<br />
$script = $packer-&gt;pack();</p>
<p>header(&#8216;content-type:application/javascript&#8217;);<br />
echo $script;<br />
}</p></blockquote>
<p>This, as you may notice, will receive a <em><strong>script</strong></em> parameter (type <strong>GET</strong>) and, if it will fit a file in your JS folder named as its value (plus the <em><strong>.js</strong></em> extension), will compress and output it.</p>
<p>In order to automatically call the index.php page with the JS file&#8217;s name (without the <em><strong>.js</strong></em> extension), you need some .htaccess commands. These are:</p>
<blockquote><p>Options All -Indexes # Disabled direct access to your JS folder&#8217;s content</p>
<p>&lt;IfModule mod_rewrite.c&gt;<br />
RewriteEngine On<br />
RewriteBase /path/to/your/JavaScript/folder/</p>
<p>RewriteRule ^(.*)\.js$ ?script=$1 [L] # Here you instruct the server to pass any JS file called directly, to index.php as its <em><strong>script</strong></em> parameter<br />
&lt;/IfModule&gt;</p></blockquote>
<p>As you may see, you must have the mod_rewrite module installed and active for this method to work.</p>
<p>If you have followed and understood all of the above&#8230; you now should access ONLY compressed JS files when calling them directly from your address bar (for example, try accessing http://your.domain.name/path/to/your/js/file.js &#8211; you should see something beginning with</p>
<blockquote><p>eval(function(p,a,c,k,e,d){ &#8230;</p></blockquote>
<p>So&#8230; that&#8217;s it! You now serve compressed (and somewhat &#8220;encoded&#8221;) JavaScript files, thus minimizing the traffic and the time needed for the browsers to load your scripts.</p>
<p>One way of seeing the effects of this change is using either <a title="Page Speed" href="http://code.google.com/speed/page-speed/" target="_blank">Page Speed</a> or <a title="Yahoo! YSlow for Firebug" href="http://developer.yahoo.com/yslow/" target="_blank">YSlow</a> <a title="Firebug" href="http://getfirebug.com/" target="_blank">Firebug</a> plug-ins. Try testing your web page without this compression method, and then, with it enabled. Depending on the size of your original script(s), you should be able to increase your ratings between 2-3 and up to 10 points.</p>
<p>Of course, you could go one step further, and try concatenating all of your scripts (in case you use more than one &#8211; and this is usually the case), and THEN compress it &#8211; you should gain up to 15 points in the performance rankings. But&#8230; I&#8217;ll let you do that yourselves. <img src='http://www.bratech.ro/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.bratech.ro/blog/?feed=rss2&amp;p=16</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using custom fonts in web</title>
		<link>http://www.bratech.ro/blog/?p=10</link>
		<comments>http://www.bratech.ro/blog/?p=10#comments</comments>
		<pubDate>Mon, 05 Apr 2010 19:01:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[browser]]></category>

		<guid isPermaLink="false">http://www.bratech.ro/blog/?p=10</guid>
		<description><![CDATA[Have you ever wanted to use custom, &#8220;fancy&#8221; fonts (like the ones you have installed yourself on your system, or your designer may have used in some slick layout), in your web pages, but were forced to use images of that writing, instead? Well, whine no more&#8230; Today I&#8217;ll give you a short (but comprehensive) [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wanted to use custom, &#8220;fancy&#8221; fonts (like the ones you have installed yourself on your system, or your designer may have used in some slick layout), in your web pages, but were forced to use images of that writing, instead? Well, whine no more&#8230;</p>
<p>Today I&#8217;ll give you a short (but comprehensive) insight into how you can build-in custom fonts into any webpage. It&#8217;s only a matter of CSS (and its less-familiar @font-face syntax). That is,</p>
<blockquote><p>@font-face {<br />
font-family: &#8216;Custom family name&#8217;;<br />
src: url(&#8216;/path/to/customfont.eot&#8217;);<br />
src: local(&#8216;Full System Custom Font Name&#8217;), local(&#8216;PostScript Custom Font Name&#8217;), url(&#8216;/path/to/customfont.ttf&#8217;);<br />
}</p></blockquote>
<p>So what does all this mean? Well, the &#8220;@font-face&#8221; block allows you to define new font families (you know &#8211; the things that enable you to write with a certain font face in certain web page elements&#8230;). Its font-family property is where you define the new font family&#8217;s name (custom, of course, since your users will most probably not have your fancy font installed).</p>
<p>The first src property is meant for embedding the EOT type font. You will get such a font file, for your special fancy font, using a font converter, of course. The best I found is <a title="Font Squirrel" href="http://www.fontsquirrel.com/fontface/generator" target="_blank">Font Squirrel</a>, but there are others (both online and offline). You just upload in your existing font, and it will output any font you might need for different browser types (it even embeds the font into CSS, so you won&#8217;t have to walk around with different external font files). EOT (Embedded OpenType) is the only font format Internet Explorer recognize (so far), and it&#8217;s the only way of displaying custom fonts in IE (of course&#8230; it HAD to be &#8220;special&#8221;!).</p>
<p>The following src property is meant for overwriting the first one (by those browsers that use TrueType fonts &#8211; that is, everyone BUT Internet Explorer), and it uses a &#8220;normal&#8221; TTF type font as the custom font family face. The &#8220;local&#8221; parameters are used in case your visitors actually HAVE your font installed on their systems (they represent, correspondingly, the system&#8217;s font name, and the PostScript font name &#8211; for such browsers as Safari under OS X).</p>
<p>REMEMBER! Always use this order when declaring fonts (first Internet Explorer&#8217;s EOT type, then the other browsers&#8217; TTF / OTF types), otherwise they will overlap, and you will only be able to see the custom font in Internet Explorer&#8230;</p>
<p>This being told&#8230; that&#8217;s it! You may now use this custom web font in any of your web page elements, just as</p>
<blockquote><p>&#8230;</p>
<p>font-family: &#8216;Custom family name&#8217;, &#8216;Regular font&#8217;, etc&#8230;;</p>
<p>&#8230;</p></blockquote>
<p>You can read more about embedding custom fonts in web pages <a title="@font-face - MDC" href="https://developer.mozilla.org/en/CSS/@font-face" target="_blank">here</a> and <a title="@font-face browser support" href="http://webfonts.info/wiki/index.php?title=%40font-face_browser_support" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bratech.ro/blog/?feed=rss2&amp;p=10</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Building mobile websites (especially for iPhone)</title>
		<link>http://www.bratech.ro/blog/?p=5</link>
		<comments>http://www.bratech.ro/blog/?p=5#comments</comments>
		<pubDate>Fri, 22 Jan 2010 22:18:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[browser]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.bratech.ro/blog/?p=5</guid>
		<description><![CDATA[Lately we were involved in some &#8220;mobile&#8221; projects, and since the iPhone is the most successful mobile device, we have focused mostly on developing &#8220;for&#8221; iPhone (this sounds almost as funny as those &#8217;90s websites &#8220;optimized for Internet Explorer at 800&#215;600 pixels&#8221;, huh? ). So, if you&#8217;re also involved (or would like to be) in [...]]]></description>
			<content:encoded><![CDATA[<p>Lately we were involved in some &#8220;mobile&#8221; projects, and since the iPhone is the most successful mobile device, we have focused mostly on developing &#8220;for&#8221; iPhone (this sounds almost as funny as those &#8217;90s websites &#8220;optimized for Internet Explorer at 800&#215;600 pixels&#8221;, huh? <img src='http://www.bratech.ro/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ).</p>
<p>So, if you&#8217;re also involved (or would like to be) in developing mobile websites, you should know some tricks that will make your &#8220;mobile programmer&#8221; life a bit easier.</p>
<p>First of all &#8211; the device. It&#8217;s kind of hard to build stuff that you cannot test periodically (and accurately), and owning an iPhone (or more) is not always possible. So&#8230; you need an emulator of some sort. And here comes Genuitec&#8217;s &#8220;iPhone Emulator for Windows&#8221; (as they call it) &#8211; <a title="iPhone Emulator for Windows" href="http://www.genuitec.com/mobile/" target="_blank">MobiOne</a>.</p>
<p>Personally I found it very user-friendly, complete and &#8220;honest&#8221; from the first test I&#8217;ve put it through. It&#8217;s true that it&#8217;s not a &#8220;complete&#8221; emulator (as <a title="Android SDK" href="http://developer.android.com/sdk/index.html" target="_blank">Google&#8217;s Android</a> one &#8211; that is quite a hustle to use, by the way) &#8211; meaning that you cannot install and test iPhone applications on it, but other than that&#8230; there&#8217;s nothing I can ask of it. It comes with an accelerometer emulator, some JavaScript libraries that could be used to interact with its &#8220;mobile functionality&#8221;, and since its latest version (milestone 6, at the time this article was written), it has even a &#8220;designer mode&#8221; (useful if you&#8217;re interested in drawing some iPhone-type interfaces for future projects &#8211; or for pitching on investors <img src='http://www.bratech.ro/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ). I&#8217;ll let you discover the rest of its functionality on you own&#8230;</p>
<p>Next: if you develop in php (as we do), you may also need a quick and reliable way of determining if the client accessing your website / web application comes from a mobile device or not. Well, we found that the &#8220;mobile_device_detect()&#8221; function from <a title="Detect Mobile Browsers" href="http://detectmobilebrowsers.mobi/" target="_blank">http://detectmobilebrowsers.mobi/</a> does this job brilliantly. It could be used very simple (just call the function and evaluate its response) or with various parameters, for very accurate results. Enjoy!</p>
<p>If you, as we did, find that the default mobile browser&#8217;s screen size is not enough for all your fancy web pages, you may use a nice trick to hide the browser&#8217;s address bar (well, you&#8217;ll save about 60 pixels in height!). Just add the</p>
<blockquote><p>&lt;meta name=&#8221;apple-mobile-web-app-capable&#8221; content=&#8221;yes&#8221; /&gt;</p></blockquote>
<p>tag in your page&#8217;s head, and you&#8217;re all set. It doesn&#8217;t even mess up your valid HTML code <img src='http://www.bratech.ro/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>There are more tips and tricks related to mobile web development that we know and use, but&#8230; if you&#8217;re interested in more, ask us to write a &#8220;part two&#8221; on this topic. That&#8217;s it for now&#8230;!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bratech.ro/blog/?feed=rss2&amp;p=5</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Building a custom browser search engine</title>
		<link>http://www.bratech.ro/blog/?p=1</link>
		<comments>http://www.bratech.ro/blog/?p=1#comments</comments>
		<pubDate>Fri, 22 Jan 2010 16:56:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[XML]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[search engine]]></category>

		<guid isPermaLink="false">http://www.bratech.ro/blog/?p=1</guid>
		<description><![CDATA[We&#8217;ll start this blog by presenting a neat trick: how to create and embed a browser search engine (you know, the box you see in the top-right corner of your [Mozilla Firefox or Internet Explorer] browsers), to be used for searching in any website that has a search capability. First, you should have a basic [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ll start this blog by presenting a neat trick: how to create and embed a browser search engine (you know, the box you see in the top-right corner of your [Mozilla Firefox or Internet Explorer] browsers), to be used for searching in any website that has a search capability.</p>
<p>First, you should have a basic understanding of programming (as in &#8220;what is a tag&#8221;, &#8220;what is a variable&#8221;, a &#8220;token&#8221;&#8230; those kinds of things) to follow this article.</p>
<p>So, if that is the case, start by creating a new XML-type document (in any text editor you like, even Notepad, Wordpad will do), and add the following lines:</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;OpenSearchDescription xmlns=&#8221;http://a9.com/-/spec/opensearch/1.1/&#8221; xmlns:moz=&#8221;http://www.mozilla.org/2006/browser/search/&#8221;&gt;<br />
&lt;ShortName&gt;Your Search Engine Short Name&lt;/ShortName&gt;<br />
&lt;Description&gt;Your search engine&#8217;s description&#8230;&lt;/Description&gt;<br />
&lt;InputEncoding&gt;utf-8&lt;/InputEncoding&gt;<br />
&lt;Image width=&#8221;16&#8243; height=&#8221;16&#8243; type=&#8221;image/vnd.microsoft.icon&#8221;&gt;http://my.searched-website.com/theWebsitesIcon.ico&lt;/Image&gt;<br />
&lt;Url type=&#8221;text/html&#8221; method=&#8221;get&#8221; template=&#8221;http://my.searched-website.com/?search={searchTerms}&#8221; /&gt;<br />
&lt;moz:SearchForm&gt;http://my.searched-website.com/?search&lt;/moz:SearchForm&gt;<br />
&lt;/OpenSearchDescription&gt;</p></blockquote>
<p>Now, for what it all means. You should start, obviously, with an XML declaration.</p>
<p>Then, the OpenSearchDescription tag is simply a definition of the XLS document&#8217;s purpose (for the application trying to use the XML document). It shouldn&#8217;t bother you too much&#8230; just keep it that way!</p>
<p>The ShortName tag is the text you will see in the search box, as you should see by default &#8220;Google&#8221; or &#8220;Yahoo&#8221;. Try to keep it short.</p>
<p>The Description&#8230; to be honest, I don&#8217;t know where you use or will see this text. But as long as it&#8217;s in the &#8220;specs&#8221;&#8230; let&#8217;s keep it (and add a meaning to it).</p>
<p>InputEncoding represents the encoding of your search&#8217;s characters. I&#8217;m assuming you&#8217;re using the default English ASCII characters, so&#8230; also, keep it as it is. If you want to search using any other type of characters (latin, slavic, etc.), set the encoding correspondingly (if you know it <img src='http://www.bratech.ro/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ).</p>
<p>The Image tag holds your search engine&#8217;s icon (that you&#8217;ll see in the search box, after setting your engine as the default). I recommend you use the searched website&#8217;s favicon image (if applicable), else&#8230; don&#8217;t set it. You will see a default no-icon symbol.</p>
<p>The Url is the most important tag. It transmits the search query itself to the website you&#8217;re actually searching on. It has to contain that website&#8217;s search path, and as the search parameter you will use the predefined {searchTerms} token. You may set here how that website&#8217;s handling the searches (by GET or POST methods).</p>
<p>The moz:SearchForm tag is a Mozilla-specific tag, and it sets the search page&#8217;s main URL, to which it submits your search criteria.</p>
<p>So, this are the basic knowledge you&#8217;ll need to set up a custom browser search engine. Next, in order to install it in a browser&#8217;s search box, you&#8217;ll need another thing: to have a web page where to declare it, and from where to install it.</p>
<p>For this, you just need to add a simple line of code in the &lt;head&gt; section of any web page:</p>
<blockquote><p>&lt;link rel=&#8221;search&#8221; type=&#8221;application/opensearchdescription+xml&#8221; title=&#8221;Search my website using this fancy custom browser search engine&#8221; href=&#8221;http://my.own-webpage.com/mySearchEngineFile.xml&#8221; /&gt;</p></blockquote>
<p>Of course, you need to modify (in both my code samples above) the &#8220;funny&#8221; values with real, proper ones. Once you did all that&#8230; the sky is the limit! <img src='http://www.bratech.ro/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  Now you can search through any website in just one or two clicks (depending if you set your custom search engine as the default one or not <img src='http://www.bratech.ro/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ).</p>
<p>For a real-life example, we built an <a title="The Internet Movie Data Base" href="http://www.imdb.com/" target="_blank">IMDb</a> search engine, so we could search easily for movies. To install it, just one the search engines icons (by pressing the currently selected one&#8217;s icon), and select &#8220;Add MySearchEngine&#8217;sTitle&#8221; (or &#8220;Add Search Providers&#8221; &gt; &#8220;My Search Engine&#8217;s Title&#8221; &#8211; depending on your browser). <a title="IMDB custom browser search engine" href="http://www.bratech.ro/imdb/" target="_blank">Try it</a> yourself, if it sounds good!</p>
<p>This is not the &#8220;limit&#8221; of what can be done with custom browser search engines. For complete and detailed specs on using the OpenSearch format, follow this link: <a title="OpenSearch format specifications" href="http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document" target="_blank">http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bratech.ro/blog/?feed=rss2&amp;p=1</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
