<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Lysender's Daily Log Book</title>
	
	<link>http://blog.lysender.com</link>
	<description>Life, Technology, Programming and Everything in Between</description>
	<lastBuildDate>Sat, 15 Jun 2013 15:28:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/lysender" /><feedburner:info uri="lysender" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Jaqen H’ghar is Bon Clay – seems legit</title>
		<link>http://feedproxy.google.com/~r/lysender/~3/JJv6jgQLhIY/</link>
		<comments>http://blog.lysender.com/2013/06/jaqen-hghar-is-bon-clay-seems-legit/#comments</comments>
		<pubDate>Tue, 11 Jun 2013 08:07:31 +0000</pubDate>
		<dc:creator>lysender</dc:creator>
				<category><![CDATA[Personal Blog]]></category>
		<category><![CDATA[bon clay]]></category>
		<category><![CDATA[jaqen]]></category>

		<guid isPermaLink="false">http://blog.lysender.com/?p=1427</guid>
		<description><![CDATA[Both have the ability to change their faces. Theory must be true.]]></description>
				<content:encoded><![CDATA[<p>Both have the ability to change their faces. Theory must be true.</p>
<div class="wp-caption aligncenter" style="width: 410px"><a href="https://s3-us-west-2.amazonaws.com/lysender.junk/jaqen-is-bon-clay.jpg"><img src="https://s3-us-west-2.amazonaws.com/lysender.junk/jaqen-is-bon-clay-small.jpg" width="400" height="238" class /></a><p class="wp-caption-text">Jaqen H&#8217;ghar is Bon Clay</p></div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/lysender?a=JJv6jgQLhIY:9MOVTLy8A4w:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/lysender?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=JJv6jgQLhIY:9MOVTLy8A4w:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/lysender?i=JJv6jgQLhIY:9MOVTLy8A4w:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=JJv6jgQLhIY:9MOVTLy8A4w:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/lysender?i=JJv6jgQLhIY:9MOVTLy8A4w:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=JJv6jgQLhIY:9MOVTLy8A4w:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/lysender?i=JJv6jgQLhIY:9MOVTLy8A4w:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=JJv6jgQLhIY:9MOVTLy8A4w:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/lysender?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=JJv6jgQLhIY:9MOVTLy8A4w:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/lysender?i=JJv6jgQLhIY:9MOVTLy8A4w:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/lysender/~4/JJv6jgQLhIY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.lysender.com/2013/06/jaqen-hghar-is-bon-clay-seems-legit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.lysender.com/2013/06/jaqen-hghar-is-bon-clay-seems-legit/</feedburner:origLink></item>
		<item>
		<title>Slackware 14.0 – the May 20-22 2013 update – broke my Intel Graphics</title>
		<link>http://feedproxy.google.com/~r/lysender/~3/Wg9aZOtT7n0/</link>
		<comments>http://blog.lysender.com/2013/05/slackware-14-0-the-may-20-22-2013-update-broke-my-intel-graphics/#comments</comments>
		<pubDate>Tue, 28 May 2013 15:51:35 +0000</pubDate>
		<dc:creator>lysender</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Slackware]]></category>
		<category><![CDATA[intel graphics]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[mkinitrd]]></category>

		<guid isPermaLink="false">http://blog.lysender.com/?p=1417</guid>
		<description><![CDATA[Three days ago, I&#8217;ve updated my Slackware 14.0 (32 bit) due to kernel update security advisory. However, after a reboot, my box freezes up few minutes after logging in into the desktop. I searched around and ask in the forum &#8230; <a href="http://blog.lysender.com/2013/05/slackware-14-0-the-may-20-22-2013-update-broke-my-intel-graphics/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Three days ago, I&#8217;ve updated my Slackware 14.0 (32 bit) due to kernel update security advisory. However, after a reboot, my box freezes up few minutes after logging in into the desktop. I searched around and ask in the forum but end up downgrading to the original kernel version 3.2.29.</p>
<p><strong>UPDATE</strong>: Since this is a security patch, I&#8217;ll be updating to a newer kernel anytime soon and will stay away from 3.2.29. However, since it would require more work, I&#8217;ll stay in 3.2.29 a bit until I have enough time to install any of the newer kernels (perhaps this coming weekend).</p>
<p><strong>UPDATE</strong>: An updated dated June 3, 2013 was uploaded to Slackware mirrors and promised to fix the Intel issues with kernel 3.2.45 (3rd rebuild). Today, June 9, 2013, I have applied the patch and so far it works. I have uploaded some screenshot showing some Firefox 3d stuff.</p>
<div class="wp-caption aligncenter" style="width: 410px"><a href="https://s3-us-west-2.amazonaws.com/lysender.junk/new-firefox-tools-web.png"><img src="https://s3-us-west-2.amazonaws.com/lysender.junk/new-firefox-tools-small.png" width="400" height="269" class /></a><p class="wp-caption-text">Firefox 3d view is happy with the latest kernel rebuild!</p></div>
<p>Original post below.</p>
<h2>Kernel patch 3.2.45</h2>
<p>The original kernel for 14.0 was 3.2.29 and the supposed to be security patch kernel version is 3.2.45. After few days since the patch has been released, I&#8217;ve applied the patch via Slackware update. The installation went through and I&#8217;ve even updated the <code>initrd</code> so I could use the generic kernel. However, during my final reboot so I could start working on the machine, it freezes up few minutes later after logging in into KDE.</p>
<p>I&#8217;ve tried different desktop environment (XFCE) and even bare bone window managers (blackbox, fluxbox) but same issue occurs. I suspect it was the graphics driver. My Intel Graphics 3000 may not be supported or whatsoever. I&#8217;ve read the change logs and it says that there was another update few days after the kernel patch. I&#8217;m sure I got the latest patch but I still experienced the issue described. There was even a <a href="http://www.linuxquestions.org/questions/slackware-14/upgrading-slackware-14-to-kernel-3-2-45-resulted-in-black-screen-on-boot-4175462795/">discussion in the forum about the said issue</a>. </p>
<h2>Stuck due to no wifi</h2>
<p>I&#8217;m using NetworkManager for my wifi. Since I&#8217;ve configured the wifi via NetworkManager, by default I could not connect to the internet without logging into X. I was planning to downgrade but couldn&#8217;t download due to no internet connection in runlevel 3. I&#8217;ve asked around again so I could do something to save my machine.</p>
<h2>nomodeset</h2>
<p>I&#8217;ve <a href="http://www.linuxquestions.org/questions/slackware-14/upgrading-slackware-14-to-kernel-3-2-45-resulted-in-black-screen-on-boot-4175462795/">read somewhere on that forum post</a> that we could pass <code>nomodeset</code> parameter into <code>lilo</code> or any boot manager so it would bypass awesome graphics features and thus allow troubleshooting (ex: can connect to the internet but with crappy graphics quality). Since I&#8217;m using <code>lilo</code>, I do the following:</p>
<ul>
<li>Start the machine</li>
<li>At boot screen, press tab</li>
<li>Type in the name of the lilo entry for your linux, mine I have the following entries:
<ul>
<li><code>Linux</code></li>
<li><code>Linux3245</code></li>
<li><code>Windows</code></li>
</ul>
</li>
<li>After typing in the <code>lilo</code> entry, add space and type in <code>nomodeset</code>
<ul>
<li><code>Linux3245 nomodeset</code></li>
</ul>
</li>
<li>Press enter</li>
<li>Wait for the login manager to show up and login to the desktop manager</li>
<li>Once you are able to login, you can download and install the old kernel package</li>
</ul>
<h2>Downgrade kernel</h2>
<p>Now that I&#8217;m able to login to the desktop manager and connect to the internet, I was able to search further about the issue. However, my plan is clear &#8211; to downgrade to the original 14.0 kernel version 3.2.29. Since I already have a full copy of Slackware 14.0 including the source, the original kernel is also available in that copy. I just installed old kernel in the <code>slackware/a</code> directory.</p>
<pre class="brush: bash; title: ; notranslate">
cd /path/to/slackware-14.0
cd slackware/a
installpkg kernel*
</pre>
<p>Now that I have both kernel 3.2.45 and 3.2.29, I can choose to use both and play around. But I choose to just revert the default kernel to 3.2.29 and leave it as is for the next couple of months. The task is simply to re-run the <code>mkinitrd</code> command, update <code>lilo.conf</code> to point to the correct generic kernel, rerun <code>lilo</code> and rebooted. </p>
<p>I know that messing around with Linux kernel is scary but it has been done and I&#8217;ve committed the same mistake over and over again. Until the next kernel trouble my friend. For now I could go back to work instead of dealing with OS problems.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/lysender?a=Wg9aZOtT7n0:PsJL2WSmw1c:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/lysender?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=Wg9aZOtT7n0:PsJL2WSmw1c:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/lysender?i=Wg9aZOtT7n0:PsJL2WSmw1c:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=Wg9aZOtT7n0:PsJL2WSmw1c:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/lysender?i=Wg9aZOtT7n0:PsJL2WSmw1c:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=Wg9aZOtT7n0:PsJL2WSmw1c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/lysender?i=Wg9aZOtT7n0:PsJL2WSmw1c:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=Wg9aZOtT7n0:PsJL2WSmw1c:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/lysender?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=Wg9aZOtT7n0:PsJL2WSmw1c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/lysender?i=Wg9aZOtT7n0:PsJL2WSmw1c:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/lysender/~4/Wg9aZOtT7n0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.lysender.com/2013/05/slackware-14-0-the-may-20-22-2013-update-broke-my-intel-graphics/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://blog.lysender.com/2013/05/slackware-14-0-the-may-20-22-2013-update-broke-my-intel-graphics/</feedburner:origLink></item>
		<item>
		<title>Bash scripting – loops, string concatenation and passing arguments</title>
		<link>http://feedproxy.google.com/~r/lysender/~3/d_Tj0VMnkkw/</link>
		<comments>http://blog.lysender.com/2013/05/bash-scripting-loops-string-concatenation-and-passing-arguments/#comments</comments>
		<pubDate>Sun, 12 May 2013 08:49:32 +0000</pubDate>
		<dc:creator>lysender</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bash control structure]]></category>
		<category><![CDATA[bash script]]></category>
		<category><![CDATA[control structure]]></category>

		<guid isPermaLink="false">http://blog.lysender.com/?p=1407</guid>
		<description><![CDATA[I&#8217;ve just created some very basic bash script to automate my task, that is to run behat tests for several test directories. It involves passing argument from command line, doing loops on arrays and concatenating strings. See below for more &#8230; <a href="http://blog.lysender.com/2013/05/bash-scripting-loops-string-concatenation-and-passing-arguments/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve just created some very basic bash script to automate my task, that is to run <a href="http://behat.org/">behat</a> tests for several test directories. It involves passing argument from command line, doing loops on arrays and concatenating strings. See below for more details.</p>
<p><strong>UPDATE:</strong> I&#8217;ve just updated the post after discovering that the script can be further enhanced by using bash functions. See updated script at the bottom.</p>
<h2>The project</h2>
<p>The project is not that large, however, there are some 5 or 6 sites on it with multiple environments like development environments for multiple developers, staging and production. I need to run tests for all sites at specific environment. I&#8217;m using <code>behat</code> as tool for running automated tets (BDD). Below is the test directory structure.</p>
<pre class="brush: plain; title: ; notranslate">
|-- test_dir_root
    |-- site1
    |   |-- behat.yml
    |   `-- features
    |-- site2
    |   |-- behat.yml
    |   `-- features
    |-- site3
    |   |-- behat.yml
    |   `-- features
    |-- site4
    |   |-- behat.yml
    |   `-- features
    |-- site5
    |   |-- behat.yml
    |   `-- features
    `-- site6
    |   |-- behat.yml
    |   `-- features
    `-- run_tests.sh
</pre>
<h2>Strategy</h2>
<p>The strategy is simple, go to test&#8217;s root directory, loop through all directories (listed in an array) then run the tests with uniform parameters, ex: if I want to run a staging test, it should run tests against staging environment for all sites listed.</p>
<p>Since <code>behat</code>&#8216;s default behavior is to run in verbose mode, I have to pass some parameters to have a less cluttered test output. </p>
<h2>The Script</h2>
<p>I&#8217;ve put script at the root directory for the tests and name it <code>run_tests.sh</code>. Below is the code.</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/sh

if [ &quot;$1&quot; == &quot;&quot; ]; then
    echo &quot;Usage: ./run_tests.sh &lt;production|staging|development&gt;&quot; 
    echo &quot;Ex: ./run_tests.sh staging&quot; 
    exit 1
fi

TEST_ROOT_DIR=$(pwd)
SITES=(&quot;site1&quot; &quot;site2&quot; &quot;site3&quot; &quot;site4&quot; &quot;site5&quot; &quot;site6&quot;)

echo &quot;Initiating tests...&quot;

for i in &quot;${SITES[@]}&quot;
do
    :
    # Go to test root dir
    cd &quot;$TEST_ROOT_DIR&quot;
    TARGET_DIR=&quot;$TEST_ROOT_DIR/$i&quot;
    COMMAND=&quot;behat --profile $1 --format progress&quot;
    cd &quot;$TARGET_DIR&quot;
    echo &quot;Running tests for $i at $(pwd)&quot;
    $COMMAND
    echo &quot;&quot;
done
</pre>
<p>As you can see, it has some basic control structure like if statement, loops and even string concatenation. The code block:</p>
<pre class="brush: bash; title: ; notranslate">
if [ &quot;$1&quot; == &quot;&quot; ]; then
</pre>
<p>checks if the first command line argument is empty. If you are using two command line arguments, it will be at <code>$2</code>, third will be at <code>$3</code> and so on. The code block:</p>
<pre class="brush: bash; title: ; notranslate">
SITES=(&quot;site1&quot; &quot;site2&quot; &quot;site3&quot; &quot;site4&quot; &quot;site5&quot; &quot;site6&quot;)
</pre>
<p>declares an array. The array is then used for looping. The code block:</p>
<pre class="brush: bash; title: ; notranslate">
TARGET_DIR=&quot;$TEST_ROOT_DIR/$i&quot;
</pre>
<p>concatenates the string variable <code>$TEST_ROOT_DIR</code> and <code>$i</code> with <code>/</code> at the middle.</p>
<p>Let&#8217;s run it. Assuming they all passes, below will be how it will look like.</p>
<pre class="brush: plain; title: ; notranslate">
lysender@darkstar-lenovo-32:/home/data/www/huge_project/behat$ ./run_tests.sh darkstar
Initiating tests...
Running tests for site1 at /home/data/www/huge_project/behat/site1
....................

2 scenarios (2 passed)
20 steps (20 passed)
0m0.211s

Running tests for site3 at /home/data/www/huge_project/behat/site3
..............................................................

18 scenarios (18 passed)
62 steps (62 passed)
0m1.238s

Running tests for site3 at /home/data/www/huge_project/behat/site3
....................

2 scenarios (2 passed)
20 steps (20 passed)
0m0.214s

Running tests for site4 at /home/data/www/huge_project/behat/site4
.........F.........F

(::) failed steps (::)

01. ...

02. ...

2 scenarios (2 failed)
20 steps (18 passed, 2 failed)
0m0.226s

Running tests for site5 at /home/data/www/huge_project/behat/site5
.........F.........F

(::) failed steps (::)

01. ...
02. ...

2 scenarios (2 failed)
20 steps (18 passed, 2 failed)
0m0.218s

Running tests for site6 at /home/data/www/huge_project/behat/site6
....................

2 scenarios (2 passed)
20 steps (20 passed)
0m0.214s

lysender@darkstar-lenovo-32:/home/data/www/huge_project/behat$ 
</pre>
<p>That&#8217;s it. Enjoy and share.</p>
<h2>Update!</h2>
<p>After being annoyed by running all tests for all sites every single time, I decided to add an option to I could just run a test for just one site. Therefore, it will either run tests for all sites or run test for just one site. Below is the updated script.</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/sh

if [ &quot;$1&quot; == &quot;&quot; ]; then
    echo &quot;Usage: ./run_tests.sh &lt;production|staging|development&gt; &lt;optional site_name&gt;&quot; 
    echo &quot;Ex: ./run_tests.sh staging&quot; 
    echo &quot;Ex: ./run_tests.sh staging site2&quot; 
    exit 1
fi

TARGET_SITE=&quot;&quot;
if [ &quot;$2&quot; == &quot;&quot; ]; then
    SITES=(&quot;site1&quot; &quot;site2&quot; &quot;site3&quot; &quot;site4&quot; &quot;site5&quot; &quot;site6&quot;)
else
    SITES=(&quot;$2&quot;)
fi

BEHAT_PROFILE=&quot;$1&quot;
TEST_ROOT_DIR=$(pwd)

run_behat_test_on_target() {
    # $1 is root dir
    # $2 is the target site
    # $3 is the profile name
    TARGET_DIR=&quot;$1/$2&quot;
    COMMAND=&quot;behat --profile $3 --format progress&quot;
    cd &quot;$TARGET_DIR&quot;
    echo &quot;Running tests for $2 at $(pwd)&quot;
    $COMMAND
    echo &quot;&quot;
}

echo &quot;Initiating tests...&quot;

for i in &quot;${SITES[@]}&quot;
do
    :
    run_behat_test_on_target $TEST_ROOT_DIR $i $BEHAT_PROFILE
done
</pre>
<p>To run the script, we doe something like below:</p>
<pre class="brush: bash; title: ; notranslate">
# Run tests for just site 2
./run_tests.sh staging site2
# Run tests for all sites
./run_tets.sh staging
</pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/lysender?a=d_Tj0VMnkkw:v32CI7MrMHU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/lysender?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=d_Tj0VMnkkw:v32CI7MrMHU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/lysender?i=d_Tj0VMnkkw:v32CI7MrMHU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=d_Tj0VMnkkw:v32CI7MrMHU:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/lysender?i=d_Tj0VMnkkw:v32CI7MrMHU:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=d_Tj0VMnkkw:v32CI7MrMHU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/lysender?i=d_Tj0VMnkkw:v32CI7MrMHU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=d_Tj0VMnkkw:v32CI7MrMHU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/lysender?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=d_Tj0VMnkkw:v32CI7MrMHU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/lysender?i=d_Tj0VMnkkw:v32CI7MrMHU:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/lysender/~4/d_Tj0VMnkkw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.lysender.com/2013/05/bash-scripting-loops-string-concatenation-and-passing-arguments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.lysender.com/2013/05/bash-scripting-loops-string-concatenation-and-passing-arguments/</feedburner:origLink></item>
		<item>
		<title>Checking/unchecking checkbox doesn’t work in jQuery mobile</title>
		<link>http://feedproxy.google.com/~r/lysender/~3/xR3UhJYOqVQ/</link>
		<comments>http://blog.lysender.com/2013/05/checkingunchecking-checkbox-doesnt-work-in-jquery-mobile/#comments</comments>
		<pubDate>Wed, 08 May 2013 10:29:08 +0000</pubDate>
		<dc:creator>lysender</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[checkboxradio]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery mobile]]></category>
		<category><![CDATA[selectmenu]]></category>

		<guid isPermaLink="false">http://blog.lysender.com/?p=1404</guid>
		<description><![CDATA[I&#8217;m using an old school jQuery code to modify elements that has true/false attributes such as checked or selected. This appears to be not working when I tried it on jQuery mobile checkbox. I used a different method instead and &#8230; <a href="http://blog.lysender.com/2013/05/checkingunchecking-checkbox-doesnt-work-in-jquery-mobile/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m using an old school jQuery code to modify elements that has true/false attributes such as <code>checked</code> or <code>selected</code>. This appears to be not working when I tried it on jQuery mobile checkbox. I used a different method instead and it works so far without investigation why my old method does not work.</p>
<p>My old code goes like this.</p>
<pre class="brush: jscript; title: ; notranslate">
// To check
$(&quot;#some_checkbox&quot;).attr(&quot;checked&quot;, &quot;checked&quot;).checkboxradio(&quot;refresh&quot;);

// To uncheck
$(&quot;#some_checkbox&quot;).removeAttr(&quot;checked&quot;).checkboxradio(&quot;refresh&quot;);
</pre>
<p>This method, for some reason does not work for me in jQuery mobile (simulated in a desktop browser). I saw a <a href="http://api.jquerymobile.com/checkboxradio/">sample in docs</a> and tried to use it and it works flawlessly.</p>
<pre class="brush: jscript; title: ; notranslate">
// To check
$(&quot;#some_checkbox&quot;).prop(&quot;checked&quot;, true).checkboxradio(&quot;refresh&quot;);

// To uncheck
$(&quot;#some_checkbox&quot;).prop(&quot;checked&quot;, false).checkboxradio(&quot;refresh&quot;);
</pre>
<p>Note that this may require higher version of jQuery. However, using:</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;#some_select&quot;).attr(&quot;selected&quot;, &quot;selected&quot;).selectmenu(&quot;refresh&quot;);
</pre>
<p>works for select/dropdown elements. Weird.</p>
<p>I haven&#8217;t investigated further but there must be something wrong with my old code. Too lazy to investigate though.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/lysender?a=xR3UhJYOqVQ:2iD4XAIXgrQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/lysender?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=xR3UhJYOqVQ:2iD4XAIXgrQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/lysender?i=xR3UhJYOqVQ:2iD4XAIXgrQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=xR3UhJYOqVQ:2iD4XAIXgrQ:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/lysender?i=xR3UhJYOqVQ:2iD4XAIXgrQ:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=xR3UhJYOqVQ:2iD4XAIXgrQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/lysender?i=xR3UhJYOqVQ:2iD4XAIXgrQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=xR3UhJYOqVQ:2iD4XAIXgrQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/lysender?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=xR3UhJYOqVQ:2iD4XAIXgrQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/lysender?i=xR3UhJYOqVQ:2iD4XAIXgrQ:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/lysender/~4/xR3UhJYOqVQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.lysender.com/2013/05/checkingunchecking-checkbox-doesnt-work-in-jquery-mobile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.lysender.com/2013/05/checkingunchecking-checkbox-doesnt-work-in-jquery-mobile/</feedburner:origLink></item>
		<item>
		<title>Slackware nginx update – 1.4.1 – security fix</title>
		<link>http://feedproxy.google.com/~r/lysender/~3/UOlURHPXe6w/</link>
		<comments>http://blog.lysender.com/2013/05/slackware-nginx-update-1-4-1-security-fix/#comments</comments>
		<pubDate>Wed, 08 May 2013 08:13:00 +0000</pubDate>
		<dc:creator>lysender</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[advisory]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.lysender.com/?p=1400</guid>
		<description><![CDATA[A news in Ars Technica caught my attention today and it is about a widespread attack on web servers that includes Apache and nginx. My server is nginx therefore, I quickly updated my server to apply 1.4.1 version (my current &#8230; <a href="http://blog.lysender.com/2013/05/slackware-nginx-update-1-4-1-security-fix/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>A <a href="http://arstechnica.com/security/2013/05/attack-hitting-apache-sites-goes-mainstream-hacks-nginx-lighttpd-too/">news in Ars Technica</a> caught my attention today and it is about a widespread attack on web servers that includes Apache and nginx. My server is nginx therefore, I quickly updated my server to apply 1.4.1 version (my current is 1.4.0).</p>
<p>Here is the <a href="http://mailman.nginx.org/pipermail/nginx-announce/2013/000112.html">security advisory in nginx site</a>. Below are the steps I did when applying updates.</p>
<h2>Updating nginx</h2>
<p>In Slackware (mine is 14.0), nginx is not shipped as stock software. You get the source code and get a SlackBuild script and build it on your own. My build script and custom configuration is still in the server, therefore, all I have to do is put the latest source code, pass the new version and upgrade the installed nginx package.</p>
<p>Get the <a href="http://slackbuilds.org/repository/14.0/network/nginx/">SlackBuild script for nginx on SBo</a>.</p>
<pre class="brush: bash; title: ; notranslate">
cd /path/to/build/script
wget http://nginx.org/download/nginx-1.4.1.tar.gz
VERSION=1.4.1 ./nginx.SlackBuild 
upgradepkg /tmp/nginx-1.4.1-i486-1_SBo.tgz
</pre>
<p>Now that we&#8217;ve upgraded nginx, we need to check the configurations if it is still intact. If we&#8217;ve verified that we are still good with the configuration, restart the nginx server.</p>
<pre class="brush: bash; title: ; notranslate">
/etc/rc.d/rc.nginx restart
</pre>
<p>Note: My server is a VPS hosting some websites and also servers as staging server.</p>
<p>Always watch out for security advisories out there and secure your servers.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/lysender?a=UOlURHPXe6w:epgD-X5DuAk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/lysender?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=UOlURHPXe6w:epgD-X5DuAk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/lysender?i=UOlURHPXe6w:epgD-X5DuAk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=UOlURHPXe6w:epgD-X5DuAk:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/lysender?i=UOlURHPXe6w:epgD-X5DuAk:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=UOlURHPXe6w:epgD-X5DuAk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/lysender?i=UOlURHPXe6w:epgD-X5DuAk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=UOlURHPXe6w:epgD-X5DuAk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/lysender?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=UOlURHPXe6w:epgD-X5DuAk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/lysender?i=UOlURHPXe6w:epgD-X5DuAk:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/lysender/~4/UOlURHPXe6w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.lysender.com/2013/05/slackware-nginx-update-1-4-1-security-fix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.lysender.com/2013/05/slackware-nginx-update-1-4-1-security-fix/</feedburner:origLink></item>
		<item>
		<title>Django – verbose console logging in development server</title>
		<link>http://feedproxy.google.com/~r/lysender/~3/qpUZRfrZAjM/</link>
		<comments>http://blog.lysender.com/2013/05/django-verbose-console-logging-in-development-server/#comments</comments>
		<pubDate>Sun, 05 May 2013 07:02:42 +0000</pubDate>
		<dc:creator>lysender</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[verbose error]]></category>

		<guid isPermaLink="false">http://blog.lysender.com/?p=1395</guid>
		<description><![CDATA[The moment you set DEBUG = False in development server for Django, you will be clueless about what&#8217;s going on for every error your application may encounter. If you just want to show verbose error messages on the console (when &#8230; <a href="http://blog.lysender.com/2013/05/django-verbose-console-logging-in-development-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>The moment you set <code>DEBUG = False</code> in development server for Django, you will be clueless about what&#8217;s going on for every error your application may encounter. If you just want to show verbose error messages on the console (when you run the <code>manage.py</code> built-in web server for Django, follow the simple steps below.</p>
<p>In your <code>settings.py</code>, the default logging configuration may be configured for I don&#8217;t know, is it production ready? For Django starters, this will hide basic errors you may encounter. We are going to configure the <code>LOGGING</code> dict to have the required <code>formatters</code>, <code>handlers</code> and <code>loggers</code>. Below is my <code>LOGGING</code> section of <code>settings.py</code>.</p>
<pre class="brush: python; title: ; notranslate">
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s',
        },
        'simple': {
            'format': '%(levelname)s %(message)s',
        },
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose',
        },
    },
    'loggers': {
        'django.request': {
            # 'handlers': ['mail_admins'],
            'handlers': ['console'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}
</pre>
<p>Please note that this is for development mode only and for those who run the build-in web server. For production purpose, change the settings for the appropriate logging.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/lysender?a=qpUZRfrZAjM:kWnCYGGUeHk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/lysender?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=qpUZRfrZAjM:kWnCYGGUeHk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/lysender?i=qpUZRfrZAjM:kWnCYGGUeHk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=qpUZRfrZAjM:kWnCYGGUeHk:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/lysender?i=qpUZRfrZAjM:kWnCYGGUeHk:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=qpUZRfrZAjM:kWnCYGGUeHk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/lysender?i=qpUZRfrZAjM:kWnCYGGUeHk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=qpUZRfrZAjM:kWnCYGGUeHk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/lysender?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=qpUZRfrZAjM:kWnCYGGUeHk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/lysender?i=qpUZRfrZAjM:kWnCYGGUeHk:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/lysender/~4/qpUZRfrZAjM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.lysender.com/2013/05/django-verbose-console-logging-in-development-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.lysender.com/2013/05/django-verbose-console-logging-in-development-server/</feedburner:origLink></item>
		<item>
		<title>Sublime Text shortcut – convert to lowercase/uppercase</title>
		<link>http://feedproxy.google.com/~r/lysender/~3/4TbLGlmhncg/</link>
		<comments>http://blog.lysender.com/2013/05/sublime-text-shortcut-convert-to-lowercaseuppercase/#comments</comments>
		<pubDate>Sat, 04 May 2013 04:16:30 +0000</pubDate>
		<dc:creator>lysender</dc:creator>
				<category><![CDATA[Personal Blog]]></category>
		<category><![CDATA[convert lowercase]]></category>
		<category><![CDATA[convert uppercase]]></category>
		<category><![CDATA[sublime text]]></category>
		<category><![CDATA[sublime text tip]]></category>

		<guid isPermaLink="false">http://blog.lysender.com/?p=1392</guid>
		<description><![CDATA[Many times I&#8217;ve encountered a situation where I need to convert some codes/text into lowercase or uppercase while using Sublime Text. Then suddenly I thought it would be cool if there is a shortcut to convert selected text into lowercase &#8230; <a href="http://blog.lysender.com/2013/05/sublime-text-shortcut-convert-to-lowercaseuppercase/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Many times I&#8217;ve encountered a situation where I need to convert some codes/text into lowercase or uppercase while using Sublime Text. Then suddenly I thought it would be cool if there is a shortcut to convert selected text into lowercase or uppercase. Gladly there are already built-in shortcuts in Sublime Text 2.</p>
<p>I&#8217;ve found the <a href="https://gist.github.com/nuxlli/1207014">tip from a GIST</a>.</p>
<p>The shortcut is simple, select the text to convert and press the following keys.</p>
<p>For non-mac keyboards.</p>
<ul>
<li><code>CTRL+ K</code>, then <code>L</code> &#8211; for converting into lowercase</li>
<li><code>CTRL + K</code>, then <code>U</code> &#8211; for converting into uppercase</li>
</ul>
<p>Example, you have a text <code>NOFOLLOW</code> and you want to convert into <code>nofollow</code>. Select the text, press <code>CTRL</code> and <code>K</code> at the same time, then release <code>K</code> while still pressing <code>CTRL</code> then press <code>L</code>.</p>
<p>That&#8217;s it. Enjoy and share.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/lysender?a=4TbLGlmhncg:TM5_qBMGXV4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/lysender?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=4TbLGlmhncg:TM5_qBMGXV4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/lysender?i=4TbLGlmhncg:TM5_qBMGXV4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=4TbLGlmhncg:TM5_qBMGXV4:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/lysender?i=4TbLGlmhncg:TM5_qBMGXV4:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=4TbLGlmhncg:TM5_qBMGXV4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/lysender?i=4TbLGlmhncg:TM5_qBMGXV4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=4TbLGlmhncg:TM5_qBMGXV4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/lysender?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=4TbLGlmhncg:TM5_qBMGXV4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/lysender?i=4TbLGlmhncg:TM5_qBMGXV4:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/lysender/~4/4TbLGlmhncg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.lysender.com/2013/05/sublime-text-shortcut-convert-to-lowercaseuppercase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.lysender.com/2013/05/sublime-text-shortcut-convert-to-lowercaseuppercase/</feedburner:origLink></item>
		<item>
		<title>Setting up nginx + php-fpm on Slackware 14.0</title>
		<link>http://feedproxy.google.com/~r/lysender/~3/Y2fQiObSeEM/</link>
		<comments>http://blog.lysender.com/2013/05/setting-up-nginx-php-fpm-on-slackware-14-0/#comments</comments>
		<pubDate>Wed, 01 May 2013 13:50:36 +0000</pubDate>
		<dc:creator>lysender</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Slackware]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php-fpm]]></category>
		<category><![CDATA[vhost]]></category>

		<guid isPermaLink="false">http://blog.lysender.com/?p=1386</guid>
		<description><![CDATA[For Slackware 14.0, it is now easy to setup an nginx webserver with PHP support via php-fpm. If you do a full install with Slackware 14.0, you can get PHP 5.4.x and php-fpm as this packages are shipped by stock &#8230; <a href="http://blog.lysender.com/2013/05/setting-up-nginx-php-fpm-on-slackware-14-0/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>For Slackware 14.0, it is now easy to setup an <code>nginx</code> webserver with PHP support via <code>php-fpm</code>. If you do a full install with Slackware 14.0, you can get PHP 5.4.x and php-fpm as this packages are shipped by stock Slackware. However, the default webserver though is still Apache. In this guide, we are going to setup a webserver that can run PHP scripts via php-fpm.</p>
<h2>Install nginx</h2>
<p>First, we grab a <a href="http://slackbuilds.org/repository/14.0/network/nginx/">SlackBuild script for nginx</a> via Slackbuilds.org. Extract it, then grab the latest source code for nginx (currently at <code>1.4.0</code>).</p>
<pre class="brush: bash; title: ; notranslate">
wget http://slackbuilds.org/slackbuilds/14.0/network/nginx.tar.gz
tar xvzf nginx.tar.gz
cd nginx
wget http://nginx.org/download/nginx-1.4.0.tar.gz
</pre>
<p>Now that the build script and the nginx source code is ready, we need to modify the build script so that it will install the 1.4.0 version instead of whatever version is being hardcoded into it by the build script. In my case, the version used by the script is still at <code>1.2.6</code>.</p>
<p>Edit <code>nginx.SlackBuild</code> and look for the text <code>VERSION=${VERSION}:-1.2.6</code> and change it to version <code>1.4.0</code>. Next, go down the codes and look for the text <code>./configure</code> and check if <code>--with-http_realip_module</code> is present. If not, add it in the middle of the <code>./configure</code> code block.</p>
<p>Next, ensure that <code>--with-ipv6</code> is present as well. If not, add it to the <code>./configure</code> code block. These two settings allow sniffing real IP address from proxy servers or CDN like CloudFlare. The other option allows the <code>ipv6</code> syntax that we can use with <code>HttpRealipModule</code>. I needed it on my setup but you may not need it on yours. We&#8217;ll never know.</p>
<p>Now that we are finally ready building <code>nginx</code>, let&#8217;s build it now (run as root). It may take several minutes to complete.</p>
<pre class="brush: bash; title: ; notranslate">
./nginx.SlackBuild
</pre>
<p>Finally, we need to install it on our Slackware box. The package filename will be displayed by the build script after it finishes compiling nginx and it is usually put under <code>/tmp</code> directory. (Run as root).</p>
<pre class="brush: bash; title: ; notranslate">
installpkg /tmp/nginx-1.4.0-i486-1_SBo.tgz
</pre>
<h2>Configure nginx</h2>
<p>Now that we already have an <code>nginx</code> installed, let&#8217;s configure it to be our webserver. First, we set the daemon up and running and be sure we closed/disabled all other web server like Apache. If we have an Apache server running, let&#8217;s kill it and make sure it will never run again upon restart.</p>
<pre class="brush: bash; title: ; notranslate">
/etc/rc.d/rc.httpd stop
chmod -x /etc/rc.d/rc.httpd
</pre>
<p>Next, lets make <code>nginx</code> and <code>php-fpm</code> RC script enabled upon boot.</p>
<pre class="brush: bash; title: ; notranslate">
chmod +x /etc/rc.d/rc.php-fpm
chmod +x /etc/rc.d/rc.nginx
</pre>
<p>I usually use vhosts for everything, therefore, in this post, I&#8217;ll jumpt straight into making virtual hosts for nginx. Let&#8217;s start with our default virtual host which is also the <code>localhost</code>. I call my virtual host as <code>darkstar.darkstar.net</code>. The document root will be on <code>/srv/www/htdocs/darkstar.darkstar.net</code>. </p>
<p>Create the directory and put an index file <code>/srv/www/htdocs/darkstar.darkstar.net/index.html</code> and put some content like <code>It works!</code> or any content just for testing. For testing local servers, you may need to add a host file entry for <code>darkstar.darkstar.net</code> like below:</p>
<pre class="brush: bash; title: ; notranslate">
# /etc/hosts
# Other contents
# ...

127.0.0.1       darkstar.darkstar.net
</pre>
<p>Next, create an nginx conf file. Below is my conf file for <code>/etc/nginx/nginx.conf</code>.</p>
<pre class="brush: plain; title: ; notranslate">
worker_processes  1;

events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  darkstar.darkstar.net;

        #charset koi8-r;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        root /srv/www/htdocs/darkstar.darkstar.net;

        location / {
            root        /srv/www/htdocs/darkstar.darkstar.net;
            index       index.html index.htm;
        }

        access_log  /var/log/nginx/darkstar.darkstar.net-access_log combined;
        error_log   /var/log/nginx/darkstar.darkstar.net-error_log error;
    }

    # Include other config/sites
    include /etc/nginx/sites-enabled/*;
}
</pre>
<p>As you&#8217;ve noticed, we didn&#8217;t put any php related configuration here. We will skip that for now and let this vhost serve static files only. At the end of the config file, the line that says <code>include /etc/nginx/sites-elabled/*;</code> means that we can add more vhosts on that directory without messing around with the main config file. Create the directories for now and leave it with no content.</p>
<pre class="brush: bash; title: ; notranslate">
cd /etc/nginx        
mkdir sites-available
mkdir sites-enabled
</pre>
<p>Now we are ready for our first test. Run the nginx daemon and let&#8217;s see what will happen.</p>
<pre class="brush: bash; title: ; notranslate">
/etc/rc.d/rc.nginx start
</pre>
<p>Now visit <code>http://darkstar.darkstar.net</code>. You should see the text <code>It works!</code> on your browser.</p>
<h2>Configure nginx + php-fpm</h2>
<p>Now that nginx is ready, lets get PHP working. In this post, we will simply make the PHP run. Nothing fancy. We call our demo site <code>myproject.darkstar.net</code>. You must add this site in your local host file if this is a local virtual host, like what we did on darkstar.darkstar.net. Next, add a config file at <code>/etc/nginx/sites-available/myproject.darkstar.net.conf</code> with below content.</p>
<pre class="brush: plain; title: ; notranslate">
server {
    listen      80;
    server_name  myproject.darkstar.net;
    root        /srv/www/htdocs/myproject.darkstar.net;
    index       index.html index.htm index.php;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include         fastcgi_params;
        #fastcgi_param   PHP_VALUE &quot;auto_prepend_file=/home/data/scripts/common_functions.php&quot;;
    }

    location ~ /\.ht {
        deny  all;
    }

    access_log  /var/log/nginx/myproject.darkstar.net-access_log combined;
    error_log   /var/log/nginx/myproject.darkstar.net-error_log error;
}
</pre>
<p>Then make sure you sym-link the config file to the sites-enabled directory.</p>
<pre class="brush: bash; title: ; notranslate">
cd /etc/nginx/sites-enabled
ln -s ../sites-available/myproject.darkstar.net.conf myproject.darkstar.net.conf
</pre>
<p>Next, make a sample PHP script at <code>/srv/www/htdocs/myproject.darkstar.net/index.php</code> with some basic PHP code, ex:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php phpinfo() ?&gt;
</pre>
<h2>Launch</h2>
<p>Finally, let&#8217;s launch the site with a test page. Start php-fpm, restart nginx.</p>
<pre class="brush: bash; title: ; notranslate">
/etc/rc.d/rc.php-fpm start
/etc/rc.d/rc.nginx restart
</pre>
<p>Open the site <code>http://myproject.darkstar.net/</code> and you should be a violet <code>phpinfo()</code> page. By the way, with above nginx config, it allows basic rewrite feature found on frameworks like Zend Framework, Kohana, CodeIgniter and even WordPress. </p>
<p>Enjoy and share.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/lysender?a=Y2fQiObSeEM:3ISKTEQChbs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/lysender?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=Y2fQiObSeEM:3ISKTEQChbs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/lysender?i=Y2fQiObSeEM:3ISKTEQChbs:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=Y2fQiObSeEM:3ISKTEQChbs:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/lysender?i=Y2fQiObSeEM:3ISKTEQChbs:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=Y2fQiObSeEM:3ISKTEQChbs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/lysender?i=Y2fQiObSeEM:3ISKTEQChbs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=Y2fQiObSeEM:3ISKTEQChbs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/lysender?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=Y2fQiObSeEM:3ISKTEQChbs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/lysender?i=Y2fQiObSeEM:3ISKTEQChbs:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/lysender/~4/Y2fQiObSeEM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.lysender.com/2013/05/setting-up-nginx-php-fpm-on-slackware-14-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.lysender.com/2013/05/setting-up-nginx-php-fpm-on-slackware-14-0/</feedburner:origLink></item>
		<item>
		<title>Surprise – SmartBro/MyBro Fair Usage Policy</title>
		<link>http://feedproxy.google.com/~r/lysender/~3/y5EhZhJMjKU/</link>
		<comments>http://blog.lysender.com/2013/05/surprise-smartbromybro-fair-usage-policy/#comments</comments>
		<pubDate>Wed, 01 May 2013 01:08:20 +0000</pubDate>
		<dc:creator>lysender</dc:creator>
				<category><![CDATA[Personal Blog]]></category>
		<category><![CDATA[canopy]]></category>
		<category><![CDATA[mybro]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[smartbro]]></category>

		<guid isPermaLink="false">http://blog.lysender.com/?p=1384</guid>
		<description><![CDATA[MyBro (previously SmartBro canopy) has always been unlimited, no daily nor monthly limit ever known to all of us subscribers. We enjoyed the privilege for quit a year or so (a year in my case). Then suddenly, this April, my &#8230; <a href="http://blog.lysender.com/2013/05/surprise-smartbromybro-fair-usage-policy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>MyBro (previously SmartBro canopy) has always been unlimited, no daily nor monthly limit ever known to all of us subscribers. We enjoyed the privilege for quit a year or so (a year in my case). Then suddenly, this April, my connections began to slow like hell. I called the *1888 hotline and surprise! There is now a fair usage policy for SmartBro/MyBro.</p>
<p>I haven&#8217;t received any notification about this change. The <a href="http://www.pldthome.com/mybroFUP">Fair Usage Policy</a> page didn&#8217;t mentioned anything about exact GB limit but <a href="http://www.mukamo.com/smart-bro-canopy-mybro-slow-connection-2013/">according to some blog posts</a>, it is 15 GB per month. </p>
<p>Without downloaded stuff, I could easily exhaust that 15GB in less than a month. This is due to my nature of work where I read a lot, connect to some servers and transfer stuff a lot. I may adjust my workflow as I cannot connect to my VPS all the time anymore.</p>
<p>On the other hand, I just extended my contract with them for 7 months for a promo wherein you pay P100 less for 7 months. I signed up immediately but now that I know this policy, I regret. I deserve better internet.</p>
<p>The month just changed from April to May but it seems that my 15GB cap has not reset. I know they sucks but they could have sucked less.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/lysender?a=y5EhZhJMjKU:wwucdNrX_YU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/lysender?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=y5EhZhJMjKU:wwucdNrX_YU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/lysender?i=y5EhZhJMjKU:wwucdNrX_YU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=y5EhZhJMjKU:wwucdNrX_YU:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/lysender?i=y5EhZhJMjKU:wwucdNrX_YU:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=y5EhZhJMjKU:wwucdNrX_YU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/lysender?i=y5EhZhJMjKU:wwucdNrX_YU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=y5EhZhJMjKU:wwucdNrX_YU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/lysender?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=y5EhZhJMjKU:wwucdNrX_YU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/lysender?i=y5EhZhJMjKU:wwucdNrX_YU:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/lysender/~4/y5EhZhJMjKU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.lysender.com/2013/05/surprise-smartbromybro-fair-usage-policy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://blog.lysender.com/2013/05/surprise-smartbromybro-fair-usage-policy/</feedburner:origLink></item>
		<item>
		<title>Log real IP address with CloudFlare and nginx</title>
		<link>http://feedproxy.google.com/~r/lysender/~3/pM3fpz2TiE4/</link>
		<comments>http://blog.lysender.com/2013/04/log-real-ip-address-with-cloudflare-and-nginx/#comments</comments>
		<pubDate>Tue, 30 Apr 2013 10:04:10 +0000</pubDate>
		<dc:creator>lysender</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[cloudflare]]></category>
		<category><![CDATA[ip address]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[real ip address]]></category>

		<guid isPermaLink="false">http://blog.lysender.com/?p=1380</guid>
		<description><![CDATA[When you have a website behind the CloudFlare DNS (using its CDN services), chances are your nginx access logs are logging CloudFlare IP addresses. This is due to the fact that your are serving content where CloudFlare acts as proxy. &#8230; <a href="http://blog.lysender.com/2013/04/log-real-ip-address-with-cloudflare-and-nginx/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>When you have a website behind the CloudFlare DNS (using its CDN services), chances are your nginx access logs are logging CloudFlare IP addresses. This is due to the fact that your are serving content where CloudFlare acts as proxy. To log the visitor&#8217;s real IP address, you need to modify some configuration or even rebuild nginx for that purpose.</p>
<h2>To rebuild or not?</h2>
<p><code>nginx</code> has a module called <a href="http://wiki.nginx.org/HttpRealipModule">HttpRealipModule</a> where it allows setting real IP address for a given source IP by using the standard header values passed by proxy servers. This will allow us to tell nginx to pickup CloudFlare&#8217;s <code>CF-Connecting-IP</code> header value and use it as the real IP address and will be used when logging to access logs.</p>
<p>This feature requires that nginx is built with <code>--with-http-realip_module</code> build option. My current version is nginx 1.4.0 and luckily it has enabled <code>--with-http-realip_module</code> by default.</p>
<p>Since the CloudFlare documentation includes ipv6 IP addresses, we also need to ensure that our nginx can handle ipv6. This requires <code>--with-ipv6</code> option when building nginx. Unfortunately, my nginx is not built with ipv6 support. I am forced to rebuild it. Luckily, I&#8217;m using Slackbuilds.org&#8217;s nginx Slackbuild script. I just edited the script to pass <code>--with-ipv6</code> and re-installed nginx. </p>
<h2>HttpRealipModule</h2>
<p><a href="https://support.cloudflare.com/entries/22051973-Does-CloudFlare-have-an-IP-module-for-Nginx-">This is the guide</a> I used when setting up the CloudFlare real ip sniff. I&#8217;ve created a file called <code>/etc/nginx/cloudflare-real-ip.conf</code>.</p>
<pre class="brush: plain; title: ; notranslate">
# Cloudflare

set_real_ip_from   204.93.240.0/24;
set_real_ip_from   204.93.177.0/24;
set_real_ip_from   199.27.128.0/21;
set_real_ip_from   173.245.48.0/20;
set_real_ip_from   103.21.244.0/22;
set_real_ip_from   103.22.200.0/22;
set_real_ip_from   103.31.4.0/22;
set_real_ip_from   141.101.64.0/18;
set_real_ip_from   108.162.192.0/18;
set_real_ip_from   190.93.240.0/20;
set_real_ip_from   188.114.96.0/20;  
set_real_ip_from   197.234.240.0/22;
set_real_ip_from   198.41.128.0/17;
set_real_ip_from   2400:cb00::/32;
set_real_ip_from   2606:4700::/32;
set_real_ip_from   2803:f800::/32;
set_real_ip_from   2405:b500::/32;
set_real_ip_from   2405:8100::/32;
real_ip_header     CF-Connecting-IP;
</pre>
<p>Next, for all sites in your server that is CloudFlare enabled, include this config by putting a line in your vhost configuration like below:</p>
<pre class="brush: plain; title: ; notranslate">
server {
    # Some config
    # ...
    # ...

    # CloudFlare config
    include /etc/nginx/cloudflare-real-ip.conf;
}
</pre>
<p>Restart nginx and what your access logs. It should start logging real IP address from now on. Be sure to update the list of IP addresses from time to time since CloudFlare may add/remove IP address in the future.</p>
<p>Note: We didn&#8217;t actually configured nginx to allow ipv6, but instead we just make sure that our config syntax will work and not throw error. Without the ipv6 option, our config above will fail since it will not be able to understand the ipv6 syntax. However, we didn&#8217;t specifically mentioned how to allow ipv6 connections to nginx. This requires another configuration that I am not interested as of this time.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/lysender?a=pM3fpz2TiE4:9d322Xgmzns:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/lysender?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=pM3fpz2TiE4:9d322Xgmzns:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/lysender?i=pM3fpz2TiE4:9d322Xgmzns:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=pM3fpz2TiE4:9d322Xgmzns:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/lysender?i=pM3fpz2TiE4:9d322Xgmzns:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=pM3fpz2TiE4:9d322Xgmzns:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/lysender?i=pM3fpz2TiE4:9d322Xgmzns:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=pM3fpz2TiE4:9d322Xgmzns:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/lysender?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/lysender?a=pM3fpz2TiE4:9d322Xgmzns:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/lysender?i=pM3fpz2TiE4:9d322Xgmzns:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/lysender/~4/pM3fpz2TiE4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.lysender.com/2013/04/log-real-ip-address-with-cloudflare-and-nginx/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://blog.lysender.com/2013/04/log-real-ip-address-with-cloudflare-and-nginx/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.343 seconds. --><!-- Cached page generated by WP-Super-Cache on 2013-06-15 23:28:59 --><!-- Compression = gzip -->
