<?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>Ivan Villareal &#187; Create a multiuser git repository with gitolite &#8211; Ivan Villareal</title>
	<atom:link href="http://ivanvillareal.com/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://ivanvillareal.com</link>
	<description>IT stuff and more...</description>
	<lastBuildDate>Tue, 01 Nov 2011 23:00:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Create a multiuser git repository with gitolite</title>
		<link>http://ivanvillareal.com/development/create-a-multiuser-git-repository-with-gitolite/</link>
		<comments>http://ivanvillareal.com/development/create-a-multiuser-git-repository-with-gitolite/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 22:57:54 +0000</pubDate>
		<dc:creator>Ivan Villareal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[repository]]></category>

		<guid isPermaLink="false">http://ivanvillareal.com/?p=253</guid>
		<description><![CDATA[I use git for almost all my developments, is fast, it works locally, and I can even use it as a quick deployment tool, by adding hooks, but when it [...]]]></description>
			<content:encoded><![CDATA[<p>I use git for almost all my developments, is fast, it works locally, and I can even use it as a quick deployment tool, by adding hooks, but when it comes to sharing a repository to other developers, I don&#8217;t like the idea of creating a user account in the system for each developer, so the easiest and fastest way to solve this issue for me is using <a href="https://github.com/sitaramc/gitolite">gitolite</a>.</p>
<p>In this post I will describe the steps needed to setup a central repository for multiple users. I&#8217;m using Centos 5.5 as server and debian as a workstation</p>
<h2>Create a user account in the server and install git</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bp ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># useradd -m git </span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bp ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># passwd git</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>bp ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># yum install git</span></pre></div></div>

<h2>Copy your public key from our workstation to the server</h2>
<p>If you don&#8217;t know how to setup an ssh passwordless login, take a look <a href="http://ivanvillareal.com/linux/setting-up-ssh-keys-for-passwordless-login/">here</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ivan<span style="color: #000000; font-weight: bold;">@</span>scorpion:~$ <span style="color: #c20cb9; font-weight: bold;">scp</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>bp.com:~<span style="color: #000000; font-weight: bold;">/</span>ivan.pub</pre></div></div>

<h2>Clone gitolite into the server</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ivan<span style="color: #000000; font-weight: bold;">@</span>scorpion:~$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>bp
<span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>bp: ~$ <span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>sitaramc<span style="color: #000000; font-weight: bold;">/</span>gitolite
<span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>bp: ~$ <span style="color: #7a0874; font-weight: bold;">cd</span> gitolite
<span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>bp: ~$ src<span style="color: #000000; font-weight: bold;">/</span>gl-system-install
<span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>bp: ~$ gl-setup ~<span style="color: #000000; font-weight: bold;">/</span>ivan.pub</pre></div></div>

<h2>Go to the workstation to manage the git repo</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ivan<span style="color: #000000; font-weight: bold;">@</span>scorpion:~$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> git<span style="color: #000000; font-weight: bold;">/</span>bprepo
ivan<span style="color: #000000; font-weight: bold;">@</span>scorpion:~$ <span style="color: #7a0874; font-weight: bold;">cd</span> git<span style="color: #000000; font-weight: bold;">/</span>bprepo
ivan<span style="color: #000000; font-weight: bold;">@</span>scorpion:~$ <span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>bp:gitolite-admin</pre></div></div>

<p>At this point we have 2 folders inside gitolite-admin conf/ and keydir/ the first one is used to create new repositories or add users to repositories the second one is for adding each user public key.</p>
<p>Once you have added new repositories and users you need to do a
<pre>git push origin master</pre>
<p> on each new repo</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanvillareal.com/development/create-a-multiuser-git-repository-with-gitolite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mysql unique keys and collations</title>
		<link>http://ivanvillareal.com/development/mysql-unique-keys-and-collations/</link>
		<comments>http://ivanvillareal.com/development/mysql-unique-keys-and-collations/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 01:10:59 +0000</pubDate>
		<dc:creator>Ivan Villareal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://ivanvillareal.com/?p=65</guid>
		<description><![CDATA[I&#8217;m working on an application that stores unique values on a field, so I used the unique index for this column, everything was ok, until I&#8217;ve started inserting&#160;multi byte&#160;characters&#160;in it. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on an application that stores unique values on a field, so I used the unique index for this column, everything was ok, until I&#8217;ve started inserting&nbsp;multi byte&nbsp;characters&nbsp;in it.</p>
<p>The charachters inserted fine, the problem was that I&#8217;m using <a href="http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html" target="_blank">INSERT &#8230; ON DUPLICATE KEY UPDATE</a>&nbsp;syntax to avoid looking if the field exists, so after debugging where the application was breaking I got this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Query failed: Cannot add or update a child row: a foreign key constraint fails 
(`trubaseek/mapKeywordName`, CONSTRAINT `fkDomainMapNameId` FOREIGN KEY (`NameId`) 
REFERENCES `names` (`nameId`) ON DELETE NO ACTION ON UPDATE NO ACTION)&amp;lt;br&amp;gt; 
SQL: INSERT INTO `mapKeywordName` (`keywordId`, `nameId`) VALUES ('1', '326');</pre></div></div>

<p>so I&#8217;ve spent about an hour changing the encodings&nbsp;without&nbsp;success, but after some testing I discovered that <strong>hôteles</strong> was the same as <strong>hotelës, </strong>I did several testing from the linux console, the mysql browser, and from a php script, and all revealed the same.</p>
<p>When I did this</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> <span style="color: #008000;">`names`</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`name`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`price`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`priceCurrency`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`bids`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`traffic`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`lastUpdate`</span><span style="color: #FF00FF;">&#41;</span> 
<span style="color: #990099; font-weight: bold;">VALUES</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'hotelës'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'0'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'$US'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'0'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'0'</span><span style="color: #000033;">,</span> <span style="color: #000099;">NOW</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#41;</span><span style="color: #FF00FF;">&#41;</span> 
<span style="color: #990099; font-weight: bold;">ON</span> <span style="color: #990099; font-weight: bold;">DUPLICATE KEY</span> <span style="color: #990099; font-weight: bold;">UPDATE</span> <span style="color: #008000;">`price`</span><span style="color: #CC0099;">=</span><span style="color: #008000;">'0'</span><span style="color: #000033;">,</span> <span style="color: #008000;">`priceCurrency`</span><span style="color: #CC0099;">=</span><span style="color: #008000;">'$US'</span><span style="color: #000033;">,</span> <span style="color: #008000;">`bids`</span><span style="color: #CC0099;">=</span><span style="color: #008000;">'0'</span><span style="color: #000033;">,</span> <span style="color: #008000;">`traffic`</span><span style="color: #CC0099;">=</span><span style="color: #008000;">'0'</span><span style="color: #000033;">,</span> <span style="color: #008000;">`lastUpdate`</span> <span style="color: #CC0099;">=</span> <span style="color: #000099;">NOW</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div>

<p>I&#8217;ve got this:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">Query OK<span style="color: #000033;">,</span> <span style="color: #008080;">2</span> rows affected <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.01</span> sec<span style="color: #FF00FF;">&#41;</span></pre></div></div>

<p>Called from a php script <strong>mysql_insert_id(); </strong>returned me an Id like if it was inserted not updated, but when if I select the returned Id, an error were thrown, because it didn&#8217;t existed.</p>
<p>So after some research, I&#8217;ve found that adding a collation <strong>utf8_bin </strong>to that column fixed this issue.</p>
<p>I haven&#8217;t tested this enough but for now it appears to be working.</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanvillareal.com/development/mysql-unique-keys-and-collations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing HTML documents with Simple Html DOM</title>
		<link>http://ivanvillareal.com/development/parsing-html-documents-whit-simple-html-dom/</link>
		<comments>http://ivanvillareal.com/development/parsing-html-documents-whit-simple-html-dom/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 23:02:34 +0000</pubDate>
		<dc:creator>Ivan Villareal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Scrapping]]></category>

		<guid isPermaLink="false">http://ivanvillareal.com/?p=45</guid>
		<description><![CDATA[I had to get some information from an XHTML document, the information required was on nested tables, I&#8217;ve started working on that and my first approach was to get the [...]]]></description>
			<content:encoded><![CDATA[<p>I had to get some information from an XHTML document, the information required was on nested tables, I&#8217;ve started working on that and my first approach was to get the needed info using regular expressions.</p>
<p>After 2 hours I&#8217;ve got a set of regex that worked pretty well, but when I received a new document, the layout was changed a little bit, and my didn&#8217;t worked as expected, the content was on the same table but this time it had nested tables, which were a really big problem.</p>
<p>I already have used the PHP DOM, but only on xml files, I didn&#8217;t was aware that it had the ability to parse HTML, so I&#8217;ve started working with this and within an hour I had it working, and this time the changes in the document didn&#8217;t affect the scrapping.</p>
<p>In about an hour I had a larger class with several methods to get all the elements I needed, but suddenly I was presented with another challenge, again with nested tables, sometimes the number of childs were shorter than expected, I&#8217;ve experimented several things until I found this <a href="http://sourceforge.net/projects/simplehtmldom/">Simple Html Dom</a>&nbsp;it is pretty straight forward, and it does an excellent job scrapping html documents, all the methods I did were replaced by this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">            <span style="color: #000088;">$html</span>   <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$dom</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> simple_html_dom<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$items</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$tabla</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'table[cellpadding^=2]'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'table[cellpadding^=2]'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tr'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$tr</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$link</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tr</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$link</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'item'</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$link</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'price'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tr</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">children</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">plaintext</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'bids'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tr</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">children</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">plaintext</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$items</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ivanvillareal.com/development/parsing-html-documents-whit-simple-html-dom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

