<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:posterous="http://posterous.com/help/rss/1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>Tips for lazy software engineers</title>
    <link>http://www.celalo.com</link>
    <description>Let's call it my lifestream</description>
    <generator>posterous.com</generator>
    <link type="application/json" rel="http://api.friendfeed.com/2008/03#sup" xmlns="http://www.w3.org/2005/Atom" href="http://posterous.com/api/sup_update#87385ada5"/>
    <atom:link rel="self" href="http://www.celalo.com/rss.xml"/>
    <atom:link rel="hub" href="http://posterous.superfeedr.com"/>
    <item>
      <pubDate>Mon, 10 Jan 2011 19:06:00 -0800</pubDate>
      <title>How to re-sync MySQL master-master replication</title>
      <link>http://www.celalo.com/how-to-fix-re-sync-mysql-master-master-replic</link>
      <guid>http://www.celalo.com/how-to-fix-re-sync-mysql-master-master-replic</guid>
      <description>
        <![CDATA[<p>
	<p>NoSQL is a topic and there are admirable technologies floating around. MySQL is an old fellow yet <a href="http://capttofu.livejournal.com/1752.html">you can have reliable master-master replication</a>. We have been using it in our production environment without hassle for a long time. It does not require much&nbsp;maintenance. Here is a short guideline to follow if you ever need to re-sync a master node to another. This is a bit like a series of notes for myself.</p>
<div>
<div><ol>
<li>[broken-master] <strong>Stop MySQL service!</strong></li>
<li><span style="background-color: #ffffcc;"><span style="font-family: courier new, monospace;">mysqldump -uroot -p <em>&lt;database&gt;</em> | gzip &gt; /home/<em>&lt;username&gt;</em>/db_backup/<em>&lt;database&gt;</em>_`/bin/date +\%Y-\%m-\%d_\%H-\%S`.sql.gz</span></span></li>
<li>[working-master] <span style="background-color: #ffffcc;"><span style="font-family: courier new, monospace;">STOP SLAVE;</span></span></li>
<li>[working-master] <span style="background-color: #ffffcc; font-family: courier new, monospace;">RESET SLAVE;</span></li>
<li>[working-master] <span style="background-color: #ffffcc;"><span style="font-family: courier new, monospace;">RESET MASTER;</span></span></li>
<li>[working-master] copy the db dump to [broken-master]&nbsp;<span style="background-color: #ffffcc;"><span style="font-family: courier new, monospace;">scp&nbsp;/home/&lt;username&gt;/db_backup/&lt;database&gt;_2010-01-09_22-37.sql.gz root@&lt;ip_address&gt;:/home/&lt;username&gt;/db_backup/&lt;database&gt;_2010-01-09_22-37.sql.gz</span></span></li>
<li>[broken-master]&nbsp;<span style="font-family: courier new, monospace; background-color: #ffffcc;">STOP SLAVE;</span></li>
<li>[broken-master]&nbsp;<span style="font-family: courier new, monospace; background-color: #ffffcc;">RESET SLAVE;</span></li>
<li>[broken-master] <span style="background-color: #ffffcc;"><span style="font-family: courier new, monospace;">DROP DATABASE&nbsp;<em>&lt;database&gt;</em>;</span></span></li>
<li>[broken-master] <span style="background-color: #ffffcc;"><span style="font-family: courier new, monospace;">CREATE DATABASE <em>&lt;database&gt;</em>;</span></span></li>
<li>[broken-master] <span style="background-color: #ffffcc;"><span style="font-family: courier new, monospace;">gunzip &lt;&nbsp;<em>&lt;database&gt;</em>_2010-01-09_22-37.sql.gz | mysql -u root -p&nbsp;&lt;database&gt;</span></span></li>
<li>[broken-master] <span style="background-color: #ffffcc;"><span style="font-family: courier new, monospace;">RESET MASTER;</span></span></li>
<li>[broken-master] <span style="background-color: #ffffcc; font-family: courier new, monospace;">START SLAVE;</span></li>
<li>[working-master] <span style="background-color: #ffffcc; font-family: courier new, monospace;">START SLAVE;</span></li>
</ol> 
<ul>
</ul>
</div>
<p />
</div>
	
</p>

<p><a href="http://www.celalo.com/how-to-fix-re-sync-mysql-master-master-replic">Permalink</a> 

	| <a href="http://www.celalo.com/how-to-fix-re-sync-mysql-master-master-replic#comment">Leave a comment&nbsp;&nbsp;&raquo;</a>

</p>]]>
      </description>
      <posterous:author>
        <posterous:userImage>http://files.posterous.com/user_profile_pics/955728/DSC00025.JPG</posterous:userImage>
        <posterous:profileUrl>http://posterous.com/people/1lxjrF0rai77</posterous:profileUrl>
        <posterous:firstName>Celal Baris</posterous:firstName>
        <posterous:lastName>Ozdemir</posterous:lastName>
        <posterous:nickName>celalo</posterous:nickName>
        <posterous:displayName>Celal Baris Ozdemir</posterous:displayName>
      </posterous:author>
    </item>
    <item>
      <pubDate>Mon, 10 Jan 2011 17:38:00 -0800</pubDate>
      <title>Netbeans macro for Internationalization</title>
      <link>http://www.celalo.com/netbeans-macro-for-internationalization</link>
      <guid>http://www.celalo.com/netbeans-macro-for-internationalization</guid>
      <description>
        <![CDATA[<p>
	<p>I recently started developing internationalization features for Trio. It feels good to be rely on <a href="http://www.symfony-project.org/jobeet/1_4/Propel/en/19">symfony</a> again. Otherwise it is hard to image to establish i18n capabilities to project after a year of development. It is&nbsp;ridiculously easy to implement. I spend half a day to get everything up and running and I am planning to finish by tomorrow to extract strings from files.</p>
<div>So I have with a few hints. First one goes now for extreme programmers! I am kind of person like to have everything under full automation and optimization. This time, extracting strings from php files requires them to be&nbsp;embraced&nbsp;with symfony's&nbsp;<span style="font-family: courier new, monospace;"><a href="http://www.symfony-project.org/api/1_4/I18NHelper#method___">__() function</a></span>. Seeking a way to &nbsp;ease my way along manually working with strings within php files end up with creating <a href="http://netbeans.org/kb/docs/ide/macro-keywords.html">NetBeans macros</a>.</div>
<div>Netbeans macros are pretty limited, yet I find it handy to have them for simple tasks right in my development environment. Yes they are very limited, I could not any documentation or tutorials (in a reasonable amount of time). I had to make my own experiments on keywords. In conclusion I created this one:&nbsp;</div>
<div><span style="background-color: #ffffcc;"><span style="font-family: courier new, monospace;">"'" selection-backward find-selection find-previous remove-selection find-previous remove-selection "__('" selection-backward find-selection "')"</span></span></div>
<div>When you just click a string (anywhere of the string! just have the cursor within the string) you call this macro to have it embraced with the required function. For example when you have <span style="background-color: #ffffcc; font-family: courier new, monospace;">'Lorem ipsum'</span> it becomes<span style="background-color: #ffffcc;"> <span style="font-family: courier new, monospace;">__('Lorem ipsum')</span></span> Note that, this is for single quote strings. You need to have another one for double-quoted strings. I don't think you can combine them. It isnot possible to make a regex search within a macro.</div>
<div>Symfony follows <a href="http://site.icu-project.org/">ICU standards</a> so I suppose this macro can be used in many other frameworks.</div>
<div><strong>Update:</strong></div>
<div>You would figure out, NetBeans a bit shaky when it comes to macros. Same macro script might not work in different file types because of the code assistance etc. For example in PHP files when you type double quote NetBeans might add another one for you in default settings. I have gone through all my needs and&nbsp;possibilities&nbsp;of NetBeans macros. They all work the same way except you have to use them according to file types and whether or not you are internationalizing single-quoted string or double quoted-string</div>
<div><ol>
<li>Wrapping a <strong>single quoted</strong> string in a <strong>PHP </strong>file by just clicking some where within the string.<br />
<div class="CodeRay">
  <div class="code"><pre>&quot;'&quot; selection-backward find-selection find-previous remove-selection find-previous remove-selection &quot;__('&quot; selection-backward find-selection &quot;'&quot; delete-previous &quot;)&quot;</pre></div>
</div>

</li>
<li>Wrapping a <strong>single quoted</strong> string in a <strong>Yaml </strong>file by just clicking some where within the string.<br />
<div class="CodeRay">
  <div class="code"><pre>&quot;'&quot; selection-backward find-selection find-previous remove-selection find-previous remove-selection &quot;__('&quot; selection-backward find-selection &quot;')&quot;</pre></div>
</div>

</li>
<li>Wrapping a <strong>double quoted</strong> string in a <strong>PHP </strong>file by just clicking some where within the string.<br />
<div class="CodeRay">
  <div class="code"><pre>&quot;'&quot; selection-backward find-selection find-previous remove-selection find-previous remove-selection &quot;__(\&quot;&quot; selection-backward find-selection &quot;\&quot;&quot; delete-previous &quot;)&quot;</pre></div>
</div>

</li>
<li>Wrapping a d<strong>ouble quoted</strong> string in a <strong>Yaml </strong>file by just clicking some where within the string.<br />
<div class="CodeRay">
  <div class="code"><pre>&quot;\&quot;&quot; selection-backward find-selection find-previous remove-selection find-previous remove-selection &quot;__(\&quot;&quot; selection-backward find-selection &quot;\&quot;)&quot;</pre></div>
</div>

</li>
</ol></div>
<p>Just assing shortcut keys then enjoy :)</p>
	
</p>

<p><a href="http://www.celalo.com/netbeans-macro-for-internationalization">Permalink</a> 

	| <a href="http://www.celalo.com/netbeans-macro-for-internationalization#comment">Leave a comment&nbsp;&nbsp;&raquo;</a>

</p>]]>
      </description>
      <posterous:author>
        <posterous:userImage>http://files.posterous.com/user_profile_pics/955728/DSC00025.JPG</posterous:userImage>
        <posterous:profileUrl>http://posterous.com/people/1lxjrF0rai77</posterous:profileUrl>
        <posterous:firstName>Celal Baris</posterous:firstName>
        <posterous:lastName>Ozdemir</posterous:lastName>
        <posterous:nickName>celalo</posterous:nickName>
        <posterous:displayName>Celal Baris Ozdemir</posterous:displayName>
      </posterous:author>
    </item>
    <item>
      <pubDate>Mon, 15 Mar 2010 07:41:00 -0700</pubDate>
      <title>Integrating jqGrid with symfony &amp; propel</title>
      <link>http://www.celalo.com/integrating-jqgrid-with-symfony-propel</link>
      <guid>http://www.celalo.com/integrating-jqgrid-with-symfony-propel</guid>
      <description>
        <![CDATA[<p>
	<p>For my latest piece of project I have been highly engaged with&nbsp;<a href="http://www.trirand.com/blog/" title="http://www.trirand.com/blog/" target="_blank">jqGrid</a>&nbsp;which is an Ajax-enabled JavaScript control that provides solutions for representing and manipulating tabular data on the web. Since the grid is a client-side solution loading data dynamically through Ajax callbacks I was able to integrate it with symfony and Propel. Well, to be honest it cost me a night without sleep. Actually there is a great&nbsp;<a href="http://www.trirand.net/demophp.aspx" title="http://www.trirand.net/demophp.aspx" rel="nofollow" target="_blank">implementation for PHP</a>&nbsp;which makes it so much easier to integrate with PHP. I tried it. I spend a whole day trying to make it work out. There were some problems in the beginning but I got great support from the&nbsp;<a href="http://www.trirand.net/forum/default.aspx?g=topics&amp;f=3" rel="nofollow" target="_blank">Trirand jqSuite forums</a>&nbsp;(where you can actually get quick help from developers of jqGrid) However, in the end I felt like stuck within the PHP implementation. I had to quit it and create my own implementation for several reasons. It was not open source and there was lack of documentation and features. jqGrid javascript library is really mature, feature rich, but I cannot say the same for PHP implementation classes. Moreover it is $299 or $449 since you need to buy a license. If you buy the expensive license you get the full source code but still it was going to hard integrate it with symfony &amp; propel since it is using raw SQL. Last but not least, I can tell you that I went over every single answer posted to&nbsp;<a href="http://stackoverflow.com/questions/159025/jquery-grid-recommendations" target="_blank">this</a>&nbsp;stackoverflow question. I am not going into details but, jqGrid is superior. Some lack features, some lack documentation, some lackmatureness, some lack active development or community. (<a href="http://www.datatables.net/" target="_blank">DataTables</a>&nbsp;was the one I attracted most)</p>
<p>Right now, I would like to share a piece of code which may give an insight about how to deal with this problem.</p>
<div class="CodeRay">
  <div class="code"><pre>if($this-&gt;request-&gt;getParameter('_search', 'dummy') == 'true') {
  $s = $this-&gt;request-&gt;getParameter('filters');
  if($s) {
    $jsona = json_decode($s,true);
    if(is_array($jsona)) {
      $gopr = $jsona['groupOp'];
      $this-&gt;filter-&gt;opr = $gopr;
      $rules = $jsona['rules'];
      foreach($rules as $key =&gt; $val) {
        $field = $val['field'];
        $op = $val['op'];
        $v = $val['data'];
        if($v &amp;&amp; $op) {
          switch ($op) {
            case 'eq':
              $comp = Criteria::EQUAL;
              break;
            case 'ne':
              $comp = Criteria::NOT_EQUAL;
              break;
            case 'lt':
              $comp = Criteria::LESS_THAN;
              break;
            case 'le':
              $comp = Criteria::LESS_EQUAL;
              break;
            case 'gt':
              $comp = Criteria::GREATER_THAN;
              break;
            case 'ge':
              $comp = Criteria::GREATER_EQUAL;
              break;
            case 'bw':
              $comp = Criteria::LIKE;
              $v = &quot;$v%&quot;;
              break;
            case 'bn':
              $comp = Criteria::NOT_LIKE;
              $v = &quot;$v%&quot;;
              break;
            case 'ew':
              $comp = Criteria::LIKE;
              $v = &quot;%$v&quot;;
              break;
            case 'en':
              $comp = Criteria::NOT_LIKE;
              $v = &quot;%$v&quot;;
              break;
            case 'cn':
              $comp = Criteria::LIKE;
              $v = &quot;%$v%&quot;;
              break;
            case 'nc':
              $comp = Criteria::NOT_LIKE;
              $v = &quot;%$v%&quot;;
              break;
            case 'in':
              $comp = Criteria::IN;
              $v = &quot;($v)&quot;;
              break;
            case 'ni':
              $comp = Criteria::NOT_IN;
              $v = &quot;($v)&quot;;
              break;
          }
          if($gopr=='AND')
            $andOr = 'And';
          elseif($gopr=='OR')
            $andOr = 'Or';
          if(!isset($search_criteria)) {
            $search_criteria = $this-&gt;default_criteria-&gt;getNewCriterion($field, $v, $comp);
          }else {
             call_user_func(array($search_criteria, &quot;add$andOr&quot;), $this-&gt;default_criteria-&gt;getNewCriterion($field, $v, $comp));
          }
        }
      }
      $this-&gt;default_criteria-&gt;addAnd($search_criteria);
    }
  }
}</pre></div>
</div>
	
</p>

<p><a href="http://www.celalo.com/integrating-jqgrid-with-symfony-propel">Permalink</a> 

	| <a href="http://www.celalo.com/integrating-jqgrid-with-symfony-propel#comment">Leave a comment&nbsp;&nbsp;&raquo;</a>

</p>]]>
      </description>
      <posterous:author>
        <posterous:userImage>http://files.posterous.com/user_profile_pics/955728/DSC00025.JPG</posterous:userImage>
        <posterous:profileUrl>http://posterous.com/people/1lxjrF0rai77</posterous:profileUrl>
        <posterous:firstName>Celal Baris</posterous:firstName>
        <posterous:lastName>Ozdemir</posterous:lastName>
        <posterous:nickName>celalo</posterous:nickName>
        <posterous:displayName>Celal Baris Ozdemir</posterous:displayName>
      </posterous:author>
    </item>
  </channel>
</rss>
