<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[NonBlog]]></title>
  <link href="http://home.j3ff.co/blog/atom.xml" rel="self"/>
  <link href="http://home.j3ff.co/blog/"/>
  <updated>2013-07-23T08:16:07-04:00</updated>
  <id>http://home.j3ff.co/blog/</id>
  <author>
    <name><![CDATA[CyberRodent]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[genx]]></title>
    <link href="http://home.j3ff.co/blog/blog/2013/07/22/genx/"/>
    <updated>2013-07-22T20:59:00-04:00</updated>
    <id>http://home.j3ff.co/blog/blog/2013/07/22/genx</id>
    <content type="html"><![CDATA[<p>Born in 1969 I am a member of the so called &#8220;Generation X&#8221;.</p>

<p>I recall at one point that Madison Ave. had given up on trying to reach Generation X.</p>

<p>But it didn&#8217;t really give up - it adapted.  Sort of.</p>

<p>But I (and my generation) adapted too. Sort of.</p>

<p>And I buy things I think I need from companies wth whom [1] I might have ethical, moral or other reasons not to do business.</p>

<!-- more -->


<p>I know these companies lie to me and to others about the quality and efficacy of their product,</p>

<p>about how waste byproducts of the production and distribution of these goods affects our country, our world, and us as a species.</p>

<p>The government committes tasked to regulate these companies and the
safety of those goods are also known to lie to the public.</p>

<p>&#8220;Dubitat emptor&#8221; - skeptical buyer</p>

<p>Generation X knew the tricks that advertisers used to influence purchasing decisions.</p>

<p>We know all know why the milk and eggs are in the back of the grocery store.</p>

<p>Despite how corporations treat us
   we continue to relate to them.
And knowing all that we know about
   Exxon, and BP, and Verizon, and McDonalds, Frito Lay or almost any company&#8230;
About the conditions and treatment of the workers who make our clothing.</p>

<p>We know and yet we buy.</p>

<p>Because at the end of the day we need stuff.</p>

<p>And we can only pick from what&#8217;s in the store[2].</p>

<p>Because that&#8217;s how this system works.</p>

<p>&#8211;</p>

<p>[1] using a personal pronoun with companies to indicate them being treated as if the are people.</p>

<p>[2] lately more options to have things made for us or to make them for ourselves are available!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[War of the Worlds]]></title>
    <link href="http://home.j3ff.co/blog/blog/2012/04/15/war-of-the-worlds/"/>
    <updated>2012-04-15T02:33:00-04:00</updated>
    <id>http://home.j3ff.co/blog/blog/2012/04/15/war-of-the-worlds</id>
    <content type="html"><![CDATA[<p>I remember as a kid being fascinated by the story around the <a href="http://en.wikipedia.org/wiki/The_War_of_the_Worlds_(radio_drama">radio broadcast of &#8220;The War of the Worlds&#8221;</a>.</p>

<p>It shows how strong media can be in affecting people&#8217;s beliefs.   Since then, media has only gotten better, more pervasive, more persuasive, more trusted, more
ubiquitous.  The War of the Worlds incident showed that media has to be careful to not abuse the power of the medium.</p>

<p>And people like stories.  We get so fascinated by them . We believe them &#8211; we want to believe them.  They pull us out of this &#8220;real&#8221; world to a place that is in any number
of ways better.</p>

<p>I guess in small ways people do this all the time on a smaller personal level.  We are each like little media outlets - &#8220;broadcasting&#8221; out a message that we kinda know or hope will get interpreted in a certain way.  Sometimes we do this to help the communication, and sometimes to mislead or create a false impression.</p>

<p>This reminds me of the Seinfeld where George realizes that if he acts angry at work then his coworkers will think he&#8217;s working really hard and too busy to be bothered
with new stuff.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[vim-and-such]]></title>
    <link href="http://home.j3ff.co/blog/blog/2012/04/12/vim-and-such/"/>
    <updated>2012-04-12T03:14:00-04:00</updated>
    <id>http://home.j3ff.co/blog/blog/2012/04/12/vim-and-such</id>
    <content type="html"><![CDATA[<p>I had all these windows open that I intended to read and study. Here is a snip from each one.</p>

<ul>
<li><a href="http://eagain.net/articles/git-for-computer-scientists/#history">Git for Computer Scientists</a> In simplified form, git object storage is &#8220;just&#8221; a Directed Acyclic Graph of objects &#8230;  So, armed with that knowledge on how git stores the version history, how do we visualize things like merges?</li>
<li><a href="http://www.thegeekstuff.com/2009/04/vi-vim-editor-search-and-replace-examples/">Vim Find and replace examples</a>
Example 11. Alter sequence number in a numbered list while inserting a new item.  This can be achieved by the following vim substitution command.  <code>:4,$s/\d\+/\=submatch(0) + 1/</code></li>
<li><a href="http://www.bigsmoke.us/readline/shortcuts">Readline shortcuts</a> Transpose
<pre>
 keys    Action          Scope                   Direction/Place
 Ctrl-t  Transpose/drag  char. before the cursor ↷ over the character at the cursor
 Alt-t   Transpose/drag  word before the cursor  ↷ over the word at/after the cursor</pre></li>
<li><a href="http://code.google.com/p/iterm2/wiki/Keybindings#Word_jumping">iTerm2 keybindings</a> Readline also supports jumping between words, that is re-positioning the cursor before or after the current/next word.  The default binding for this is <code>ESC-f</code> for forward jumping and <code>ESC-b</code> for backward jumping.</li>
<li><a href="http://vimgolf.com/">VimGolf</a> Real Vim ninjas count every keystroke - do you? (Danger! Quicksand.)</li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[readline cheatsheet and vim golf]]></title>
    <link href="http://home.j3ff.co/blog/blog/2012/03/31/readline-cheatsheet/"/>
    <updated>2012-03-31T05:17:00-04:00</updated>
    <id>http://home.j3ff.co/blog/blog/2012/03/31/readline-cheatsheet</id>
    <content type="html"><![CDATA[<p><a href="http://www.bigsmoke.us/readline/shortcuts">Readline cheatsheet</a> Makes for better shell.</p>

<p>I&#8217;ve also started playing <a href="http://vimgolf.com/">vim golf</a> so I might not post here for a while :)</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[MMM master-master-mysql]]></title>
    <link href="http://home.j3ff.co/blog/blog/2012/03/24/mmm-master-master-mysql/"/>
    <updated>2012-03-24T01:11:00-04:00</updated>
    <id>http://home.j3ff.co/blog/blog/2012/03/24/mmm-master-master-mysql</id>
    <content type="html"><![CDATA[<p>I starting trying to set up a test environment for feeling out master-master replication with mysql. I can do all this on one
machine by running 2 mysqld processes from different configurations, on different ports, sockets, data directories, users
etcetera.</p>

<!-- more -->


<p>All the stuff for the &#8220;A&#8221; side will be &#8220;-a&#8221; and &#8220;B&#8221; &#8220;-b&#8221;</p>

<pre><code>cp /etc/my.cnf /etc/my-a.cnf /etc/my-b.cnf 
mkdir /var/lib/mysql-a
mkdir /var/lib/mysql-b
</code></pre>

<p>Then edit your cnf files for each side.</p>

<pre><code># Note this is not meant to be pasted in as you whole conf file! These are the params you need to find and change.
user            = mysql
socket          = /var/run/mysqld/mysqld-a.sock
port            = 3310
basedir         = /usr
datadir         = /var/lib/mysql-a
tmpdir          = /tmp/mysql-a
</code></pre>

<p>Before we get into setting up the actual replication lets that we can run these 2 mysqlds at the same time.  Try to start one side.</p>

<pre><code>mysqld --defaults-file=/etc/mysql/my-a-side.cnf &amp;
</code></pre>

<p>Apparmor! Arg.  Add this for a and b sides:</p>

<pre><code>/var/lib/mysql-a/ r,
/var/lib/mysql-a/** rwk,
/var/run/mysqld/mysqld-a.pid w,
/var/run/mysqld/mysqld-a.sock w,
</code></pre>

<p>Try to start up both. Wrap that exec up into a script and make one for the b side too.</p>

<pre><code>./start-a-sides.sh &amp;&amp; ./start-b-sides.sh
</code></pre>

<p>and to shut them down</p>

<pre><code>mysqladmin -u root -P 3310 -h 127.0.0.1 shutdown
</code></pre>

<p>We&#8217;ll need to setups the datadirs - or if you have a data to start with you can put it in the data dir. Or else something like
this for each of your $DATADIRs.</p>

<pre><code>mysql_install_db --user=mysql --datadir=$DATADIR 
</code></pre>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Turning on apc.stat]]></title>
    <link href="http://home.j3ff.co/blog/blog/2012/03/10/turning-on-apc-dot-stat/"/>
    <updated>2012-03-10T06:12:00-05:00</updated>
    <id>http://home.j3ff.co/blog/blog/2012/03/10/turning-on-apc-dot-stat</id>
    <content type="html"><![CDATA[<p>It is common in an LAMP setup to setup APC with the <code>apc.stat = 0</code> set so that once your opcodes are loaded into the cache they stay there &#8211; till you flush the cache or restart the web server.  This makes sense if you have relatively infrequent updates.  At jobX we are deploying dozens of times a day, but generally, each deploy consists of changes to just a small number of files.  Despite this we send Apache a graceful after each deploy which flushes the APC cache. This isn&#8217;t causing any big problems but we can do this a bit better.</p>

<p>We actually want <code>apc.stat = 1</code>.</p>

<p>There were all sorts of fear and doubts about doing this.  It seemed the exact opposite of what you should do on a large site.  We feared that all that all those extra stat calls would slow things down or even cause the site to crash.  But rather than rely on our intuition about this we decided to actually try it out and see what actually happens.</p>

<p>First we confirmed that apc.stat (and apc.stat_ctime) would behave the way we expected when we dropped new code on the server. Relatively easy and worked as expected.  Next we needed to figure out how big our cache should be and if we wanted a ttl or not.  In order to do that I needed a bit of a deeper understanding of how APC operates.</p>

<p>Its pretty well documented that when APC fills up, it dumps the whole cache and starts over.  Generally you want to avoid this - for similar reasons as to why we wanted to get away from doing graceful restarts.  What was less well documented was how apc.ttl really works.  Most of what I read encouraged <code>apc.ttl = 0</code> to avoid fragmentation.</p>

<p>If you have <code>apc.ttl = 0</code> apc will not purge anything from your cache (unless the cache fills up, at which point APC will purge everything from the cache and start over).  It may not be obvious but with <code>apc.stat = 1</code> and <code>apc.ttl = 0</code>, that means that APC will hold onto older versions of files that have changed. If you&#8217;ve got lots of frequent changes, this could quickly lead to your cache filling up with old versions of your opcodes.</p>

<p>This behavior changes when setting apc.ttl to something larger than zero.  APC will not do any cleanup unless it needs to.  So if you set your ttl to 3600 that does not mean that apc will automatically dump all files older than an hour.  APC will remove items older that ttl&#8230;</p>

<ul>
<li>if it needs the space for other new items.</li>
<li>if a newer version of the same file gets inserted and an old version is older than the ttl.</li>
</ul>


<p>For example, your config.php is cached and you make a change and deploy a new config.php. APC will cache the new version of the file and it will also hold onto the previous version of the file.  However, if apc.ttl is > 0, apc will opportunistically check to see if it can clear out any of those old versions of that file.  This helps keep cache size in check but it comes at a cost, namely fragmentation.</p>

<p>As old items are purged from the cache you start to get fragmentation.  If fragmentation gets too high (more than 50%) you&#8217;re likely to start to see some performance impact.  One way to keep fragmentation in check is to have a large enough cache.  Some of the research I found suggests that a cache size about twice as large as the size of your files will go a long way towards keeping fragmentation low. I&#8217;m not sure but it sounds like APC might do some relocation of items in the cache which goes easier when it has large empty blocks to use for reshuffling.</p>

<p>Armed with this understanding I took a look at our historical graphs of APC (you do have graphs for everything, right?) to see how big the cache should be.  Over the weekends, when there generally aren&#8217;t any deploys, the cache grows to just under 200M.  Our cache was sized at 384M to start. I wanted to keep the cache comfortably large so I started ours at 500M.</p>

<p>To get a ttl to start with I looked at our deploy frequency, which files change most frequently and how many files change per deploy and went with 3600.</p>

<p>Here are a set of articles with details about apc:</p>

<ul>
<li><a href="http://lampzone.wordpress.com/2010/03/26/how-does-apc-work/">How Does APC Work</a></li>
<li><a href="http://abcphp.com/out/understanding-apc/">Understanding APC</a></li>
<li><a href="http://alouche.net/2009/10/21/lamp-php-opcodes-cached-with-apc-part-1/">LAMP php opcodes cache Part 1</a></li>
<li><a href="http://alouche.net/2009/10/21/lamp-php-opcodes-cached-with-apc-part-2/">LAMP php opcodes cache Part 2</a></li>
<li><a href="http://www.lecentre.net/blog/archives/1311">Monitoring PHP APC cache usage</a></li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[apc]]></title>
    <link href="http://home.j3ff.co/blog/blog/2012/03/06/apc/"/>
    <updated>2012-03-06T22:29:00-05:00</updated>
    <id>http://home.j3ff.co/blog/blog/2012/03/06/apc</id>
    <content type="html"><![CDATA[<p>I had to do a fairly deep dive into apc for some setup changes at work. These were related to our deployment process which requires us to gracefully restart apache after each deploy to deal with clearing apc.  We&#8217;ve got a large code base and lots of deploys per day (30+), so while lots of files change every day, there are more that stay the same.  Allowing the cache to endure through deloys is what we want so we actually want to change from apc.stat = 0 to apc.stat = 1.
With that comes making sure our cache size is large enough and setting a reasonable ttl.</p>

<p>Here are a set of articles with details about apc:</p>

<ul>
<li><a href="http://lampzone.wordpress.com/2010/03/26/how-does-apc-work/">How Does APC Work</a></li>
<li><a href="http://abcphp.com/out/understanding-apc/">Understanding APC</a></li>
<li><a href="http://alouche.net/2009/10/21/lamp-php-opcodes-cached-with-apc-part-1/">LAMP php opcodes cache Part 1</a></li>
<li><a href="http://alouche.net/2009/10/21/lamp-php-opcodes-cached-with-apc-part-2/">LAMP php opcodes cache Part 2</a></li>
<li><a href="http://www.lecentre.net/blog/archives/1311">Monitoring PHP APC cache usage</a></li>
</ul>


<p>On a pool of 75, 3 soon started showing increased fragmentation. Turns out those 3
servers didn&#8217;t have our app loaded on the ram disk (tmpfs) but were reading from the disk.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[design patterns]]></title>
    <link href="http://home.j3ff.co/blog/blog/2012/03/05/design-patterns/"/>
    <updated>2012-03-05T15:21:00-05:00</updated>
    <id>http://home.j3ff.co/blog/blog/2012/03/05/design-patterns</id>
    <content type="html"><![CDATA[<p>Found what looks to be an usefule reference for desing patterrn.</p>

<ul>
<li><a href="http://c2.com/cgi/wiki?DesignPatterns">Design Patterns</a></li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[interview questions]]></title>
    <link href="http://home.j3ff.co/blog/blog/2012/03/05/interview-questions/"/>
    <updated>2012-03-05T15:10:00-05:00</updated>
    <id>http://home.j3ff.co/blog/blog/2012/03/05/interview-questions</id>
    <content type="html"><![CDATA[<p>Someday in the future I&#8217;ll have to interview programmers again. This page collects some good articles with ideas
for good questions :</p>

<ul>
<li><a href="http://weblog.raganwald.com/2006/06/my-favourite-interview-question.html">My favourite interview question</a></li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[chef]]></title>
    <link href="http://home.j3ff.co/blog/blog/2012/02/28/chef/"/>
    <updated>2012-02-28T19:48:00-05:00</updated>
    <id>http://home.j3ff.co/blog/blog/2012/02/28/chef</id>
    <content type="html"><![CDATA[<p>I set up this server to be managed (or manageable) by chef using the hosted opscode platform. This post is for
some notes about how things are set up here.</p>

<p>I basically followed the quick-start guide from OpsCode.</p>

<p>I cloned the OpsCode repo skeleton and its sitting in /home/jkolber/chef-repo.  All the settings are in .chef
directory inside of that dir:  /home/jkolber/chef-repo/.chef</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[open library]]></title>
    <link href="http://home.j3ff.co/blog/blog/2012/02/22/open-library/"/>
    <updated>2012-02-22T00:21:00-05:00</updated>
    <id>http://home.j3ff.co/blog/blog/2012/02/22/open-library</id>
    <content type="html"><![CDATA[<p>Nora, for complicated reasons, made a list of about 120 or so ISBN numbers of books we
have here in the house.  Having this list in an Exel Spreadsheet was burning a hole in
my pocket so I starting writing up some code to try to do something with this.</p>

<!-- more -->


<p>I found a free book lookup API at <a href="http://openlibrary.org/">Open Library</a> and soon had
a script that would collect the information about our book list from this site. Of the
120 ISBNs I got info for about 100 books.  The info varied but included the title, author,
publisher, and sometimes things like the number of pages or links to small, medium and
large images of the book cover.  This is off to a decent start.</p>

<p>Since the data comes back as JSON, I thought it would be easy and fun to store this in
a mongo database. Also since I didn&#8217;t exactly know what I was going to do with it, and
since each book seemed to have slightly different data available, using mongo allows me
to avoid having to design a schema yet.</p>

<p>I wrote up some more ruby to run over the saved JSON files and insert each book into a
mongo db.  Next up, write up <a href="http://home.j3ff.co/books/books">a quick Sinatra front end</a>  to allow me to browse and then
perhaps add more data to each book.</p>

<p>Also interested in finding other data providers for ISBN lookups to fill in the gaps of
Open Library.</p>

<p><a href="http://openlibrary.org/developers/api">Open Library API Documentation</a></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[tcp latency]]></title>
    <link href="http://home.j3ff.co/blog/blog/2012/02/22/tcp-latency/"/>
    <updated>2012-02-22T00:03:00-05:00</updated>
    <id>http://home.j3ff.co/blog/blog/2012/02/22/tcp-latency</id>
    <content type="html"><![CDATA[<p>This was the remedy for high latency connections to my ubuntu server.  After doing this
RTT dropped from average of a good couple hundred ms down to 1 to 2 ms.</p>

<pre><code># echo 1 &gt; /proc/sys/net/ipv4/tcp_low_latency
# echo 1 &gt; /proc/sys/net/ipv4/tcp_sack
# echo 1 &gt; /proc/sys/net/ipv4/tcp_timestamps
# echo 1 &gt; /proc/sys/net/ipv4/tcp_window_scaling
</code></pre>

<p>and once latency went down I did this to get it to stick across reboots:</p>

<pre><code># echo 'net.ipv4.tcp_low_latency = 1' &gt;&gt; /etc/sysctl.conf
# echo 'net.ipv4.tcp_window_scaling = 1' &gt;&gt; /etc/sysctl.conf
# echo 'net.ipv4.tcp_timestamps = 1' &gt;&gt; /etc/sysctl.conf
# echo 'net.ipv4.tcp_sack = 1' &gt;&gt; /etc/sysctl.conf
</code></pre>

<h1>UPDATE</h1>

<p>So the latency came back a little while later and reappying these
commands again might have brough some relief but the latency kept
jumping back up.  After <strong>swapping the network cable</strong> things seem to
hovering at a brisk 1ms. Lesson learned: It&#8217;s not always your
configuration.</p>

<p><img src="http://home.j3ff.co/blog/images/render.png" title="Latency Falls" alt="Latency drop" /></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[zmq: Zero MQ post]]></title>
    <link href="http://home.j3ff.co/blog/blog/2012/02/21/zmq/"/>
    <updated>2012-02-21T15:04:00-05:00</updated>
    <id>http://home.j3ff.co/blog/blog/2012/02/21/zmq</id>
    <content type="html"><![CDATA[<p>Finally got to installing zmq on ubunutu today.</p>

<p>I found a suggestion to add someone&#8217;s repo to apt but there was some sort of
build error when I tried to install these so I opted to build from source.</p>

<pre><code>wget http://download.zeromq.org/zeromq-2.1.11.tar.gz
./configure --with-pgm
make
sudo make install
</code></pre>

<p>There are a few other languages that zmq supports but this is enough to get
me started.</p>

<p>Built language support for python</p>

<pre><code>sudo apt-get install python-dev
sudo easy_install pyzmq
</code></pre>

<p>and php</p>

<pre><code>sudo apt-get install php-pear
sudo pear channel-discover pear.zero.mq
sudo pecl install zero.mq/zmq-beta 
</code></pre>

<p>and ruby</p>

<pre><code># I use rvm so don't sudo gem
gem install zmq
</code></pre>

<p>and perl</p>

<pre><code>sudo apt-get install libperl-dev
cpan ZeroMQ
</code></pre>

<p>which turned into a yak hunt as I hadn&#8217;t get up cpan before.
cpan install YAML</p>

<p>TODO: Build something with zmq!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[First Post]]></title>
    <link href="http://home.j3ff.co/blog/blog/2012/02/15/first-post/"/>
    <updated>2012-02-15T03:47:00-05:00</updated>
    <id>http://home.j3ff.co/blog/blog/2012/02/15/first-post</id>
    <content type="html"><![CDATA[<p>This is the first post in my explorations of Octopress.</p>

<blockquote><p>Flying is learning how to throw yourself at the ground and miss.</p><footer><strong>Douglas Adams</strong> <cite>The Hichhikers Guide to the Galaxy</cite></footer></blockquote>


<p>Watch out ground.</p>
]]></content>
  </entry>
  
</feed>
