<?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>OrangeMico</title>
	<atom:link href="http://www.orangemico.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.orangemico.com</link>
	<description>Advance Software Services</description>
	<lastBuildDate>Sun, 20 Jun 2010 20:38:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Using hotspins in your IPhone Application</title>
		<link>http://www.orangemico.com/?p=305</link>
		<comments>http://www.orangemico.com/?p=305#comments</comments>
		<pubDate>Sun, 20 Jun 2010 20:38:17 +0000</pubDate>
		<dc:creator>César Naranjo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.orangemico.com/?p=305</guid>
		<description><![CDATA[The procedure is as follows: Main Thread First thing is to start a new Thread, the Background Loader Thread, as soon as the application starts. Load the first screen and anything else you 100% need at startup to have a functional first screen. Whenever something is referenced that may or may not have been loaded [...]]]></description>
			<content:encoded><![CDATA[<p>The procedure is as follows:</p>
<ul>
<li>Main Thread
<ul>
<li>First thing is to start a new Thread, the Background Loader Thread, as soon as the application starts.</li>
<li>Load the first screen and anything else you 100% need at startup to have a functional first screen.</li>
<li>Whenever something is referenced that may or may not have been loaded check the pointer/reference using a hotspin. If its loaded, great use it as is, otherwise you wait until the pointer is set.</li>
</ul>
</li>
<li>Background Loader Thread
<ul>
<li>Load everything you need here: Databases, images, ViewControllers, whatever&#8230;</li>
</ul>
</li>
</ul>
<h3>Starting a New Background Loader Thread, start Interface</h3>
<p><code><br />
[NSThread detachNewThreadSelector: @selector(backgroundLoad) toTarget:self withObject: nil];<br />
[window makeKeyAndVisible];<br />
</code></p>
<h3>Implementing the Background Loader Thread</h3>
<p><code><br />
- (void) backgroundLoad {<br />
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];<br />
self.takePicViewController = [[TakePhotoViewController alloc] init];<br />
self.mainInterface = [[MainInterface alloc] initWithNibName: @"MainInterface" bundle:nil];<br />
[pool release];<br />
}<br />
</code></p>
<h3>Hotspin on pointers/references</h3>
<p><code><br />
/* Will use the TakePicture View Controller */<br />
- (void) takepicture {<br />
	if( takePicViewController == nil) {<br />
		//hot spin until value is set<br />
		while( takePicViewController == nil ) { [NSThread sleepForTimeInterval: 0.01]; }<br />
	}<br />
	[self.navigationController presentModalViewController: takePicViewController animated: YES];<br />
}<br />
</code></p>
<h3>Other References</h3>
<ul>
<li>Less Hackish Spinlocks: <a href="http://www.celsiusgs.com/blog/?tag=spinlock">http://www.celsiusgs.com/blog/?tag=spinlock</a></li>
<li>Spinlocks (Wikipedia): <a href="http://en.wikipedia.org/wiki/Spinlock">http://en.wikipedia.org/wiki/Spinlock</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.orangemico.com/?feed=rss2&amp;p=305</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Mare Subiu: NYC Capoeira Women&#8217;s Event</title>
		<link>http://www.orangemico.com/?p=226</link>
		<comments>http://www.orangemico.com/?p=226#comments</comments>
		<pubDate>Tue, 02 Feb 2010 16:59:28 +0000</pubDate>
		<dc:creator>César Naranjo</dc:creator>
				<category><![CDATA[Capoeira]]></category>

		<guid isPermaLink="false">http://www.orangemico.com/?p=226</guid>
		<description><![CDATA[OrangeMico is proud to sponsor A Mare Subiu: NYC Capoeira Women&#8217;s Event. The event is organized by Capoeira Brasil New York- Instructors Joy, Tuzinho and Esquilo, the event&#8217;s workshops will seeks to raise the level, technique, and confidence of female capoeiristas, bringing top female capoeiristas from around the world to the event. Learn more about [...]]]></description>
			<content:encoded><![CDATA[<p>OrangeMico is proud to sponsor <strong>A Mare Subiu</strong>: NYC Capoeira Women&#8217;s Event. The event is organized by Capoeira Brasil New York- Instructors Joy, Tuzinho and Esquilo, the event&#8217;s workshops will seeks to raise the level, technique, and confidence of female capoeiristas, bringing top female capoeiristas from around the world to the event.</p>
<p><a href="http://www.orangemico.com/wp-content/uploads/2010/02/logo.jpg"><img src="http://www.orangemico.com/wp-content/uploads/2010/02/logo.jpg" alt="" title="Capeoira Brasil Logo" width="103" height="150" class="aligncenter size-full wp-image-228" /></a></p>
<p>Learn more about the event on the event blog: <a href="http://nycapoeirawomensevent.blogspot.com">nycapoeirawomensevent.blogspot.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.orangemico.com/?feed=rss2&amp;p=226</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Removing Accents and Tildes From Text String In Python</title>
		<link>http://www.orangemico.com/?p=181</link>
		<comments>http://www.orangemico.com/?p=181#comments</comments>
		<pubDate>Tue, 10 Nov 2009 17:36:33 +0000</pubDate>
		<dc:creator>César Naranjo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.orangemico.com/?p=181</guid>
		<description><![CDATA[# -*- coding: utf-8 -*- import unicodedata wordwithaccents = "Asociación Española" wordnoaccents = unicodedata.normalize('NFKD', wordwithaccents).encode('ASCII', 'ignore')]]></description>
			<content:encoded><![CDATA[<p><code><br />
# -*- coding: utf-8 -*-<br />
import unicodedata<br />
wordwithaccents = "Asociación Española"<br />
wordnoaccents = unicodedata.normalize('NFKD', wordwithaccents).encode('ASCII', 'ignore')<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.orangemico.com/?feed=rss2&amp;p=181</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSV Parsing</title>
		<link>http://www.orangemico.com/?p=135</link>
		<comments>http://www.orangemico.com/?p=135#comments</comments>
		<pubDate>Tue, 27 Oct 2009 00:47:39 +0000</pubDate>
		<dc:creator>César Naranjo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.orangemico.com/?p=135</guid>
		<description><![CDATA[Perl: http://codesnippets.joyent.com/posts/show/18 Python: http://docs.python.org/library/csv.html Ruby: http://www.ruby-doc.org/stdlib/libdoc/csv/rdoc/classes/CSV.html]]></description>
			<content:encoded><![CDATA[<ul>
<li>Perl: <a href="http://codesnippets.joyent.com/posts/show/18">http://codesnippets.joyent.com/posts/show/18</a></li>
<li>Python: <a href="http://docs.python.org/library/csv.html">http://docs.python.org/library/csv.html</a></li>
<li>Ruby: <a href="http://www.ruby-doc.org/stdlib/libdoc/csv/rdoc/classes/CSV.html">http://www.ruby-doc.org/stdlib/libdoc/csv/rdoc/classes/CSV.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.orangemico.com/?feed=rss2&amp;p=135</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Removing a Project from Subversion</title>
		<link>http://www.orangemico.com/?p=68</link>
		<comments>http://www.orangemico.com/?p=68#comments</comments>
		<pubDate>Sun, 06 Sep 2009 16:32:12 +0000</pubDate>
		<dc:creator>César Naranjo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.orangemico.com/?p=68</guid>
		<description><![CDATA[Whenever i have had to remove (uncheckout) a project from subversion control I use the following command. I assume there is a better way or more correct way. I would suggest you first run the find command within the back-ticks to make sure it is listing the correct files. rm -Rf `find . &#124; grep [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever i have had to remove (<em>uncheckout</em>) a project from subversion control I use the following command. I assume there is a better way or more correct way. I would suggest you first run the find command within the back-ticks to make sure it is listing the correct files.</p>
<p><code><br />
rm -Rf `find . | grep "\.svn$"`<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.orangemico.com/?feed=rss2&amp;p=68</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Word Xml in Django</title>
		<link>http://www.orangemico.com/?p=6</link>
		<comments>http://www.orangemico.com/?p=6#comments</comments>
		<pubDate>Thu, 03 Sep 2009 15:43:00 +0000</pubDate>
		<dc:creator>César Naranjo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blog.orangemico.com/?p=6</guid>
		<description><![CDATA[If you would like your django web application to generate simple word documents this article will show you how using Microsoft’s Word XML format and django’s template system to do so. Since Word 2003, Microsoft Word has had the ability to save documents in Word XML format. The first step is to start an example [...]]]></description>
			<content:encoded><![CDATA[<p>If you would like your django web application to generate simple word documents this article will show you how using Microsoft’s Word XML format and django’s template system to do so.</p>
<p>Since Word 2003, Microsoft Word has had the ability to save documents in Word XML format.</p>
<p>The first step is to start an example project, an example application, and an example data model to use within that application. We will call the project <code>wordxml</code> , the application <code>wxml</code> and the data model <code>People</code>. We&#8217;ll skip quickly through the first couple steps because I&#8217;ll assume most of you already know the basics of django and that you already know python.</p>
<p>Let&#8217;s create the project and application:</p>
<pre><code>
bash$ django-admin.py startproject wordxml
bash$ cd wordxml
bash$ python manage.py startapp wxml
</code></pre>
<p>We&#8217;ll setup the database, for this example we&#8217;ll create a sqlite database. We will also install our application as well as tell django where to find the template will use. Open <code>wordxml/settings.py</code> and change the applicable database properties, the installed apps property, and template property as follows:</p>
<pre><code>
...
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = 'test.sqlite3'
...
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'wordxml.wxml',
)
...
TEMPLATE_DIRS = (
      "/Users/username/tmp/wordxml/templates",
)
</code></pre>
<p>Now open <code>wordxml/wxml/models.py</code> and add the following code to create the data model.</p>
<pre><code>
from django.db import models

class Person(models.Model):
  fname = models.CharField(max_length=255)
  lname = models.CharField(max_length=255)
  age = models.IntegerField(max_length=255)
</code></pre>
<p>Synchronize the database with your new model. We will say no to creating a superuser since in this example it won&#8217;t be necessary.</p>
<pre><code>
bash$ python manage.py syncdb
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table wxml_person

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): no
Installing index for auth.Permission model
Installing index for auth.Message model
</code></pre>
<p>We&#8217;ll create a few objects (Alex, Cluadia, and Mike) in our database before we&#8217;ll skip over to Word. We&#8217;ll do this using the django shell.</p>
<pre><code>
bash$ python manage.py shell
Python 2.5.1 (r251:54863, Feb  6 2009, 19:02:12)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
&gt;&gt;&gt; from wordxml.wxml.models import *
&gt;&gt;&gt; person_a = Person(fname="Alex", lname="Davis", age=18)
&gt;&gt;&gt; person_a.save()
&gt;&gt;&gt; person_b = Person(fname="Claudia", lname="Smith", age=21)
&gt;&gt;&gt; person_b.save()
&gt;&gt;&gt; person_c = Person(fname="Mike", lname="Ada", age=35)
&gt;&gt;&gt; person_c.save()
&gt;&gt;&gt; quit()
<code>
</code></code></pre>
<p>Now let&#8217;s jump to Word to create our document, actually in this case OpenOffice. We will create a document that just list the names down the sheet and save it in the Word XML format.</p>
<p><a href="/wp-content/uploads/2009/09/django_word_document.png"><br />
<img class="aligncenter size-medium wp-image-49" title="django_word_document" src="/wp-content/uploads/2009/09/django_word_document-300x160.png" alt="django_word_document" width="300" height="160" /></a></p>
<p><a href="/wp-content/uploads/2009/09/djang_word_document_save.png"><br />
<img class="aligncenter size-medium wp-image-48" title="djang_word_document_save" src="/wp-content/uploads/2009/09/djang_word_document_save-300x185.png" alt="djang_word_document_save" width="300" height="185" /></a></p>
<p>* The xml file I will show the code for later contains less formatting; no different size fonts and colors.</p>
<p>Now we&#8217;ll create the view to read the xml file we just created as a template. Use the following as your <code>wxml/views.py</code>, notable lines are commented.</p>
<p><code><br />
# used to generate the return object<br />
from django.http import HttpResponse </code></p>
<p># needed for templates<br />
from django.template import Context, loader</p>
<p># the database object we created earlier, make it visable<br />
from wxml.models import Person</p>
<p>def example_view(request):<br />
#get all person<br />
people = Person.objects.all()</p>
<p># place it into the context and pass it the template loader<br />
c = Context( {&#8216;people&#8217;: people} )<br />
t = loader.get_template(&#8220;exmaple.xml&#8221;)</p>
<p># render the template<br />
render_xml = t.render(c)</p>
<p>#create and return the response object<br />
response = HttpResponse(render_xml, mimetype=&#8217;application/ms-word&#8217;)<br />
response['Content-Disposition'] = &#8216;attachment; filename=exmaple.xml&#8217;<br />
return response</p>
<p>As you may have noticed we are passing <code>people</code> and not <code>p</code> in the <code>context</code> as it is not referenced in our xml document nothing will happen (of course the same would happen if it were using a html template). We will instead go straight to the xml document and add a <code>for</code> to loop over our <code>people</code> object and list each <code>person</code> one by one. If we only wanted one name to be listed we could have just created that singular object and passed it in the <code>context</code>, for example we could chosen the first person returned by django <code>p = people[0]</code> and placed it in the <code>context</code> as follows <code>c = Context( {'p': p} )</code>.</p>
<p>Both OpenOffice and Word will create the Word XML file but with no more or less no line-breaks, its much easier to dig into the xml after some preprocessing. We will pass it through <code>xmllint</code> to make it file more human friendly. All OS X user will have <a href="http://xmlsoft.org/xmllint.html">xmllint</a> installed by default and so will most Linux user. The <code>--format</code> flag in <code>xmllint</code> does the trick, you must output it a temporary file and then change its file name to the original file.</p>
<p><code><br />
bash$ xmllint --format exmaple.xml &gt; exmaple.xml.tmp<br />
bash$ mv exmaple.xml.tmp exmaple.xml<br />
</code></p>
<p>The file is no nicely formatted. Open it in the your favorite text editor. Once opened search for double brackets <code>{{</code>, these start the section where the variable is outputted in the template.</p>
<p><code><br />
...<br />
&lt;w:p&gt;<br />
&lt;w:pPr&gt;<br />
&lt;w:pStyle w:val="Standard"/&gt;<br />
&lt;/w:pPr&gt;<br />
&lt;/w:p&gt;<br />
&lt;w:p&gt;<br />
&lt;w:pPr&gt;<br />
&lt;w:pStyle w:val="Standard"/&gt;<br />
&lt;/w:pPr&gt;<br />
&lt;w:r&gt;<br />
&lt;w:t&gt;{{ p.fname }} {{ p.lname }} {{ p.age }}&lt;/w:t&gt;<br />
&lt;/w:r&gt;<br />
&lt;/w:p&gt;<br />
&lt;w:sectPr&gt;<br />
&lt;w:type w:val="next-page"/&gt;<br />
&lt;w:pgSz w:w="12241.5302" w:h="15841.9803" w:orient="portrait"/&gt;<br />
&lt;w:pgMar w:top="1133.9978" w:bottom="1133.9978" w:left="1133.9978" w:gutter="0" w:right="1133.9978"/&gt;<br />
&lt;w:pgBorders w:offset-from="text"/&gt;<br />
&lt;/w:sectPr&gt;<br />
...<br />
</code></p>
<p>You have to play around with Word or OpenOffice to know how this xml format works, I am not sure to find good documentation. I&#8217;ll tell you right now the <code>p</code> element denotes a paragraph, we&#8217;ll create a <code>for/endfor</code> loop over that <code>p</code> xml element that is encapsulating our <code>person</code> object output.</p>
<p><code><br />
...<br />
&lt;/w:p&gt;<br />
{% for p in people %}<br />
&lt;w:p&gt;<br />
&lt;w:pPr&gt;<br />
&lt;w:pStyle w:val="Standard"/&gt;<br />
&lt;/w:pPr&gt;<br />
&lt;w:r&gt;<br />
&lt;w:t&gt;{{ p.fname }} {{ p.lname }} {{ p.age }}&lt;/w:t&gt;<br />
&lt;/w:r&gt;<br />
&lt;/w:p&gt;<br />
{% endfor %}<br />
&lt;w:sectPr&gt;<br />
...<br />
</code></p>
<p>The next step is to setup django to serve the view we just created. Add the view to <code>urlpatterns</code> in <code>urls.py</code>.</p>
<p><code><br />
from django.conf.urls.defaults import * </code></p>
<p>urlpatterns = patterns(&#8221;,<br />
(r&#8217;^exmaple.xml&#8217;, &#8216;wordxml.wxml.views.example_view&#8217;),<br />
)</p>
<p>Run the development server and then direct your browser to <code>http://localhost:8000/exmaple.xml</code>, your browser will request to the save the file to disk, do so and open it the  using Word or in my case OpenOffice.</p>
<h2>Notes</h2>
<p>Please keep in mind that the Word XML format is not same as the Office Open XML format, with a few changes, this simple technique I explain here will be applicable to that format. The Office Open XML format is essentiall a zipped file containing several xml files and other assets, using the technique above you can create the necessary xml files and assets and place then into a zip file and return that as your document; this tutorial explains only part of the process. The Word XML is currently retired but still useful and this technique can be used for other similar formats (eg: svg, Excel XML, etcetera).</p>
<h2>Limitations</h2>
<ul>
<li>Word 2004 for Mac does not support the format</li>
<li>OpenOffice will render documents differently than Word, for example OpenOffice does not handle headers and footers.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.orangemico.com/?feed=rss2&amp;p=6</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
