<?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> &#187; programming</title>
	<atom:link href="http://blog.kfirbreger.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.kfirbreger.com</link>
	<description></description>
	<lastBuildDate>Tue, 24 Jan 2012 09:47:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The finer points of respondsToSelector</title>
		<link>http://blog.kfirbreger.com/2011/05/27/the-finer-points-of-respondstoselector/</link>
		<comments>http://blog.kfirbreger.com/2011/05/27/the-finer-points-of-respondstoselector/#comments</comments>
		<pubDate>Fri, 27 May 2011 11:46:33 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=327</guid>
		<description><![CDATA[Cocoa&#8217;s object model is something I really like. Coming from Java, being able to declare a property and have the getters and setters auto generated is really wonderful. The key value way to interact with an object is also a very powerful tool. The problem is what happens when these two collide. For a project [...]]]></description>
			<content:encoded><![CDATA[<p>Cocoa&#8217;s object model is something I really like. Coming from Java, being able to declare a property and have the getters and setters auto generated is really wonderful. The key value way to interact with an object is also a very powerful tool. The problem is what happens when these two collide.</p>
<p>For a project at work I needed to parse some XML. The xml contained several entries of entries. Only part of the information given for each entry was actually needed by the software. Therefor the object used did not have a property for each field in the entry. Just doing the follow code will not work:</p>
<p><code><br />
[currentObject setValue:(id)elemValue forKey:objProperty];<br />
</code></p>
<p>This will raise an exception as soon as an attempt is made to set a property that does not exist. Wrapping the setter in a check to see if the object has this property will solve this problem. Using responseToSelector a test can be made to see if the object reacts to a selector</p>
<p><code><br />
if ([currentObject responseToSelector:NSSelectorFromString(objProperty)]) {<br />
	[currentObject setValue:(id)elemValue forKey:objProperty];<br />
}<br />
</code></p>
<p>This should do it. Except it doesn&#8217;t completely. If your object has a function that is named like objProperty, responseToSelector will return true, because your object does response to it. Its just not a property that is set-able, but instead, a method. Actually, reponseToSelector only controls for function. Since synthesizing a property creates a method with the name of the property, it works for detecting properties as well. To avoid getting an exception on setting values for keys. Make sure that objProperty does not contain a value equal to a method in currentObject that does not represent a property.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2011/05/27/the-finer-points-of-respondstoselector/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>jQuery animation problem in ie7</title>
		<link>http://blog.kfirbreger.com/2010/05/28/jquery-animation-problem-in-ie7/</link>
		<comments>http://blog.kfirbreger.com/2010/05/28/jquery-animation-problem-in-ie7/#comments</comments>
		<pubDate>Fri, 28 May 2010 11:24:30 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[ie problems]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/2010/05/28/jquery-animation-problem-in-ie7/</guid>
		<description><![CDATA[For one of our projects, I was creating a photo bar. When the mouse was over one of the photos it was ment to increase in size and decrease back to original size when the mouse left. Unfortunately the client for which this was developed uses ie7 exclusively. This has brought two problems: 1. ie7 [...]]]></description>
			<content:encoded><![CDATA[<p>For one of our projects, I was creating a photo bar. When the mouse was over one of the photos it was ment to increase in size and decrease back to original size when the mouse left. Unfortunately the client for which this was developed uses ie7 exclusively. This has brought two  problems:<br />
1. ie7 does not support the mouseleave event. I needed to replace it with mouseout event.<br />
2. ie7 does not accept the position property in the jQuery animate function. Giving the position as a parameter will cause an error.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2010/05/28/jquery-animation-problem-in-ie7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Namespacing and setTimeOut in Javascript</title>
		<link>http://blog.kfirbreger.com/2010/05/11/namespacing-and-settimeout-in-javascript/</link>
		<comments>http://blog.kfirbreger.com/2010/05/11/namespacing-and-settimeout-in-javascript/#comments</comments>
		<pubDate>Tue, 11 May 2010 10:39:47 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[Me]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/2010/05/11/namespacing-and-settimeout-in-javascript/</guid>
		<description><![CDATA[It is good practice to put all of your javascript code in its own namespace. When doing so in combination with setTimeOut timer function it is important to remember that the object evoking the function will be the DOM window and not your namespace object. Therefore it is needed to add the namespace before the [...]]]></description>
			<content:encoded><![CDATA[<p>It is good practice to put all of your javascript code in its own namespace. When doing so in combination with setTimeOut timer function it is important to remember that the object evoking the function will be the DOM window and not your namespace object. Therefore it is needed to add the namespace before the name of the function called.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2010/05/11/namespacing-and-settimeout-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to truly disable drupal cache</title>
		<link>http://blog.kfirbreger.com/2009/05/29/how-to-truly-disable-drupal-cache/</link>
		<comments>http://blog.kfirbreger.com/2009/05/29/how-to-truly-disable-drupal-cache/#comments</comments>
		<pubDate>Fri, 29 May 2009 10:26:05 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[guide]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=168</guid>
		<description><![CDATA[Drupal, like most CMSes uses cache intensively to speed things up. In a production site that is exactly what you what. However when developing, cache can cause you much pain. If your an expert in drupal you probably already realized when you need to clear the cache in order to see changes and when not [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>
Drupal, like most CMSes uses cache intensively to speed things up. In a production site that is exactly what you what. However when developing, cache can cause you much pain.</p>
</div>
<div>
<p>
If your an expert in drupal you probably already realized when you need to clear the cache in order to see changes and when not too. the developer module even makes it quite easy to do. However for me, and I am quite sure to quite a lot of other people it is not that clear.
</p>
</div>
<div>
<p>&#8220;Wait&#8221;, you might say. &#8220;Drupal has a disable cache setting&#8221;. You would be right to say that. Only it doesn&#8217;t completely disable the cache, only part of the cache, namely the page caching. To truly disable cache you need to do a bit of a hacking to the cache code. Yes I know they say to never hack core (cache is part of the core drupal release). for me this was worth it. I figure as long as you remember its there and don&#8217;t use it in production you should be fine. The following piece of code needs to be added in <code>include/cache.inc</code>. There are two functions there that you need to edit:</p>
<ul>
<li><code>cache_get</code></li>
<li><code>cache_set</code></li>
</ul>
<p>In <code>cache_get</code> place the code right after the <code>global $user</code>. In <code>cache_set</code>  place it at the start of the function. Here is the code that you need to add.<br />
<code><br />
if(variable_get('cache', CACHE_DISABLED) == CACHE_DISABLED) {<br />
    return 0;<br />
}<br />
</code><br />
Kudos for this hack goes to Rolf van de Krol. Cheers mate.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2009/05/29/how-to-truly-disable-drupal-cache/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Secret software</title>
		<link>http://blog.kfirbreger.com/2008/08/07/secret-software/</link>
		<comments>http://blog.kfirbreger.com/2008/08/07/secret-software/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 11:17:40 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[it]]></category>
		<category><![CDATA[spyware]]></category>
		<category><![CDATA[thinking]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=76</guid>
		<description><![CDATA[An interesting talk about secret software and why it should not be allowed in the public sector]]></description>
			<content:encoded><![CDATA[<div>
<p>
An interesting talk about secret software and why it should not be allowed in the public sector
</p>
</div>
<p>
<embed src="http://blip.tv/play/AcSDRIT3Pg" type="application/x-shockwave-flash" width="240" height="200" allowscriptaccess="always" allowfullscreen="true"></embed> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2008/08/07/secret-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Django on Dreamhost</title>
		<link>http://blog.kfirbreger.com/2008/05/19/installing-django-on-dreamhost/</link>
		<comments>http://blog.kfirbreger.com/2008/05/19/installing-django-on-dreamhost/#comments</comments>
		<pubDate>Mon, 19 May 2008 10:29:44 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=73</guid>
		<description><![CDATA[Dreamhost appears on the django site as one of the django friendly hosting services. Unfortunately, dreamhost does not officially support django. It does not have mod_python installed. Django is instead deployed using FastCGI. Hopefully sometime in the future mod_python will be added. There are a few good guides I have found, that explain how to [...]]]></description>
			<content:encoded><![CDATA[<p>Dreamhost appears on the django site as one of the django friendly hosting services. Unfortunately, dreamhost does not officially support django. It does not have mod_python installed. Django is instead deployed using FastCGI. Hopefully sometime in the future mod_python will be added. There are a few good guides I have found, that explain how to setup django on a dreamhost account:</p>
<li>Jeff Croft has a good guide on his <a href="http://jeffcroft.com/blog/2006/may/11/django-dreamhost/">blog</a></li>
<li>Gordon Tillman also has a good informative <a href="http://www.gordontillman.info/Development/DjangoDreamhost">page</a></li>
<li>The dreamhost wiki also has a <a href="http://wiki.dreamhost.com/index.php/Django">guide</a></li>
<p>Between the three of them you can probably find all the information needed for installing django for use on a dreamhost account. I will not repeat what they explain but instead add some from my own experience.</p>
<h2>Python</h2>
<p>Dreamhost, at the moment of writing, is running python 2.4. Luckily it is possible for you to locally install python. I highly recommend it as it will enable you to setup the python environment exactly the way you want it, and it will make it easier to upgrade to future versions of python.</p>
<p><code><br />
cd ~/soft<br />
wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz<br />
tar xvfz Python-2.5.2.tgz<br />
cd Python-2.5.2<br />
./configure --prefix ~/install/dir --enable-shared<br />
make<br />
make install<br />
</code></p>
<p>Where <code>~/install/dir</code> is the directory you want python installed in. I followed dreamhost&#8217;s <a href="http://wiki.dreamhost.com/Unix_account_setup">Unix account setup guide</a> and installed it under run. I recommend you do to, as it is easier to have full control over you <code>/usr/local</code>.<br />
Also adding setuptools makes future installs easier</p>
<p><code><br />
cd ~/soft<br />
wget http://peak.telecommunity.com/dist/ez_setup.py<br />
~/path/to/yourpython/python ez_setup.py<br />
</code></p>
<p>This will add the <code>easy_install</code> script which will simplify adding packages to your own python install. The final step is adding the new MySQLdb package</p>
<p><code><br />
cd ~/soft<br />
svn co https://mysql-python.svn.sourceforge.net/svnroot/mysql-python/trunk/MySQLdb MySQLdb<br />
easy_install MySQLdb<br />
</code></p>
<p>This is assuming easy_install is in your PATH. If it is not it needs to be added.</p>
<p>Your now ready to install django using your very own Python installation. That is detailed enough so I will move to two problems I met after the installation.</p>
<h2>Post Installation Problems</h2>
<p>I met with two problems that had frustrated me for a few hours. To save you the future installer some pain here they are in case you experience something similar</p>
<p><strong>syncdb after admin activation:</strong> This should have been very obvious to me but for some reason it escaped me. After enabling the admin page you must run <code>django-admin.py syncdb</code> in your project home page. What happened was that I ran it before I enabled the admin application. This lead to the creation of the needed tables in the MySQL database, but no tables for the admin application. After enabling the admin application, more tables need to be created to accommodate the new application data. The errors I got gave me the impression that there was an error in the MySQLdb egg, so I reinstalled it, then tried to find some workaround. Eventually I realized that I&#8217;m just missing the admin tables.</p>
<p><strong>.htacess:</strong> This was the real mind bender. I kept getting an internal server error saying that it reached maximum internal allowed redirects. It was obviously a configuration error so I compared my .htaccess with that of the guides and it looked the same. So I looked else, but I kept coming back to the conclusion it has to be in the .htaccess. Yet no matter how often I looked at it I couldn&#8217;t find what was wrong. I need to point out that I am no expret when it comes to apache and that maybe if I knew more about it this would have been simple, but I didn&#8217;t so I got some gray hairs before I realized I&#8217;m missing a space between the &#8211; and the [L]. A bloody white space! I was feeling furious and incredibly stupid at the same time.</p>
<p>Django is now up and running, and I like it so far. I sure is a lot nicer to work with then with JSP and servlets. Enjoy your python</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2008/05/19/installing-django-on-dreamhost/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

