<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Useful Stuff.</title>
	<atom:link href="http://yuji.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://yuji.wordpress.com</link>
	<description>If I find something useful, somebody else probably does too.</description>
	<lastBuildDate>Mon, 30 Jan 2012 14:32:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='yuji.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Useful Stuff.</title>
		<link>http://yuji.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://yuji.wordpress.com/osd.xml" title="Useful Stuff." />
	<atom:link rel='hub' href='http://yuji.wordpress.com/?pushpress=hub'/>
		<item>
		<title>S3 and Django Staticfiles collectstatic command upload only changed files</title>
		<link>http://yuji.wordpress.com/2012/01/26/s3-and-django-staticfiles-collectstatic-command-upload-only-changed-files/</link>
		<comments>http://yuji.wordpress.com/2012/01/26/s3-and-django-staticfiles-collectstatic-command-upload-only-changed-files/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 23:53:13 +0000</pubDate>
		<dc:creator>Yuji</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://yuji.wordpress.com/?p=1181</guid>
		<description><![CDATA[I just revisited a problem getting S3 and collectstatic to play nicely via django-storages. I spent an hour wondering what had changed in django or django-storages that started to force the collectstatic command to always upload all images. I did &#8230; <a href="http://yuji.wordpress.com/2012/01/26/s3-and-django-staticfiles-collectstatic-command-upload-only-changed-files/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1181&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just revisited a problem getting S3 and collectstatic to play nicely via django-storages. </p>
<p>I spent an hour wondering what had changed in django or django-storages that started to force the collectstatic command to always upload all images. </p>
<p>I did a line by line code comparison between my two django and storages installations and couldn&#8217;t find anything odd.</p>
<p>I started to google more.</p>
<h3>Hello, me!</h3>
<p>I ended up on this site: http://c4urself.posterous.com/djangos-collectstatic-with-s3boto which actually linked to a few of my original posts. </p>
<p>For the record this happens to me on a daily basis (my memory sucks) but this was rather unexpected in the vastness of the world wide internets.</p>
<h3>You MUST install python-dateutill==1.5</h3>
<p>Collectstatic will silently fail trying to detect the modified time of the S3 files, and consequently will always upload a new file. Since there was no error, I had no idea something was failing until I read the above post which pointed to the specific function (mentioned by me originally, apparently). </p>
<p>If your collectstatic command is always uploading all files, make sure you have python-dateutil==1.5 installed!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yuji.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yuji.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yuji.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yuji.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yuji.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yuji.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yuji.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yuji.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yuji.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yuji.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yuji.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yuji.wordpress.com/1181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yuji.wordpress.com/1181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yuji.wordpress.com/1181/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1181&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yuji.wordpress.com/2012/01/26/s3-and-django-staticfiles-collectstatic-command-upload-only-changed-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Yuchan</media:title>
		</media:content>
	</item>
		<item>
		<title>&#8216;str&#8217; object has no attribute &#8216;get&#8217;</title>
		<link>http://yuji.wordpress.com/2012/01/24/str-object-has-no-attribute-get/</link>
		<comments>http://yuji.wordpress.com/2012/01/24/str-object-has-no-attribute-get/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 08:07:15 +0000</pubDate>
		<dc:creator>Yuji</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://yuji.wordpress.com/?p=1179</guid>
		<description><![CDATA[Got this error when accidentally returning a string instead of an HttpResponse class in an admin view.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1179&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Got this error when accidentally returning  a string instead of an HttpResponse class in an admin view.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yuji.wordpress.com/1179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yuji.wordpress.com/1179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yuji.wordpress.com/1179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yuji.wordpress.com/1179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yuji.wordpress.com/1179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yuji.wordpress.com/1179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yuji.wordpress.com/1179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yuji.wordpress.com/1179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yuji.wordpress.com/1179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yuji.wordpress.com/1179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yuji.wordpress.com/1179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yuji.wordpress.com/1179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yuji.wordpress.com/1179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yuji.wordpress.com/1179/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1179&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yuji.wordpress.com/2012/01/24/str-object-has-no-attribute-get/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Yuchan</media:title>
		</media:content>
	</item>
		<item>
		<title>Shopify JSON API example using Python Requests</title>
		<link>http://yuji.wordpress.com/2012/01/20/shopify-json-api-example-using-python-requests/</link>
		<comments>http://yuji.wordpress.com/2012/01/20/shopify-json-api-example-using-python-requests/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 00:16:56 +0000</pubDate>
		<dc:creator>Yuji</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://yuji.wordpress.com/?p=1175</guid>
		<description><![CDATA[Shopify API XML and JSON example using Python Requests I didn&#8217;t find any full examples of using the Shopify API in either XML or JSON. I tried using the Shopify Python library but had trouble identifying the currently saved one &#8230; <a href="http://yuji.wordpress.com/2012/01/20/shopify-json-api-example-using-python-requests/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1175&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Shopify API XML and JSON example using Python Requests</p>
<p>I didn&#8217;t find any full examples of using the Shopify API in either XML or JSON. </p>
<p>I tried using the Shopify Python library but had trouble identifying the currently saved one to many objects (the Product Variants).</p>
<p>I could easily upload NEW variants, but I could not tell which python object variants received which shopify IDs which I absolutely needed as I was using the API for two way synchronization (pushing and pulling changes). </p>
<p>To put the long story short, the culprit was not having the correct Content-Type header for PUT and POST requests.</p>
<p>Using text/json, shopify was returning an unhelpful 500 error with the error message: &#8220;Errors: error&#8221; &#8211; not helpful! I started wondering if I was using the wrong urls&#8230; their template suggesting admin/#{id}.json was a bit confusing too. Why not just write admin/{id}.json ?</p>
<h2>Set up authentication</h2>
<p>Using the python requests library makes this extremely easy.</p>
<p><pre class="brush: python;">
request = requests.Session(auth=(settings.SHOPIFY_API_KEY, settings.SHOPIFY_API_PASSWORD))
print json.loads(request.get('http://myshop.myshopify.com/admin/assets.json').content)
</pre></p>
<h2>Create a product</h2>
<p><pre class="brush: python;">
payload = '''{
	  &quot;product&quot;: {
	    &quot;body_html&quot;: &quot;&lt;strong&gt;Good snowboard!&lt;/strong&gt;&quot;,
	    &quot;product_type&quot;: &quot;Snowboard&quot;,
	    &quot;title&quot;: &quot;Burton Custom Freestlye 151&quot;,
	    &quot;variants&quot;: [
	      {
	        &quot;price&quot;: &quot;10.00&quot;,
	        &quot;option1&quot;: &quot;First&quot;
	      },
	      {
	        &quot;price&quot;: &quot;20.00&quot;,
	        &quot;option1&quot;: &quot;Second&quot;
	      }
	    ],
	    &quot;vendor&quot;: &quot;Burton&quot;
	  }
	}'''

response = request.post('http://myshop.myshopify.com/admin/products', 
	data=payload,
	headers={'
		'Content-Type': 'application/json', # this is the important part.
	},)
print response.status_code, response.content
</pre></p>
<h2>Modify an existing product</h2>
<p><pre class="brush: python;">
payload = '''{
	  &quot;product&quot;: {
	    &quot;published&quot;: false,
	    &quot;id&quot;: 632910392
	  }
	}'''
response = request.put('http://myshop.myshopify.com', data=payload, headers={'Content-Type': 'application/json'})
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yuji.wordpress.com/1175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yuji.wordpress.com/1175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yuji.wordpress.com/1175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yuji.wordpress.com/1175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yuji.wordpress.com/1175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yuji.wordpress.com/1175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yuji.wordpress.com/1175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yuji.wordpress.com/1175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yuji.wordpress.com/1175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yuji.wordpress.com/1175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yuji.wordpress.com/1175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yuji.wordpress.com/1175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yuji.wordpress.com/1175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yuji.wordpress.com/1175/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1175&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yuji.wordpress.com/2012/01/20/shopify-json-api-example-using-python-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Yuchan</media:title>
		</media:content>
	</item>
		<item>
		<title>Shopify Behind an Nginx Reverse Proxy</title>
		<link>http://yuji.wordpress.com/2012/01/11/shopify-behind-an-nginx-reverse-proxy/</link>
		<comments>http://yuji.wordpress.com/2012/01/11/shopify-behind-an-nginx-reverse-proxy/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 02:21:50 +0000</pubDate>
		<dc:creator>Yuji</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://yuji.wordpress.com/?p=1167</guid>
		<description><![CDATA[For SEO Purposes and a general move away from the Shopify platform, we at Grove have finally implemented a reverse proxy via Nginx. Previously, our DNS records for www.grovemade.com pointed directly at grove.myshopify.com, while team.grovemade.com pointed to our linode.com VPS. &#8230; <a href="http://yuji.wordpress.com/2012/01/11/shopify-behind-an-nginx-reverse-proxy/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1167&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For SEO Purposes and a general move away from the Shopify platform, we at Grove have finally implemented a reverse proxy via Nginx.</p>
<p>Previously, our DNS records for www.grovemade.com pointed directly at grove.myshopify.com, while team.grovemade.com pointed to our linode.com VPS. The problem with this approach is SEO &#8211; search engines rank subdomains as separate entities. team.grovemade.com is competing with www.grovemade.com.</p>
<p>Let&#8217;s face it &#8211; at the end of the day, Shopify is an amazingly useful platform. It does as well as a general solution can. We used the best of both worlds: Shopify would serve the e-commerce pages, and Linode would serve our custom django project. </p>
<h3>The solution to our problem? Enter the proxy server.</h3>
<p>Set the DNS records to point all traffic to grovemade.com to our nginx server at linode, and have the nginx server proxy specific URLs to Shopify and the rest to our linode servers.</p>
<p>That means when you access www.grovemade.com/collections/foobar, nginx proxies the request to grove.myshopify.com and returns the data to your browser seamlessly. </p>
<p>When you access www.grovemade.com/foobar/, nginx proxies the request to a local apache server hosting our django project.</p>
<h3>Nginx proxy configuration</h3>
<p>Here&#8217;s the configuration. It was pretty painless once I realized I could proxy to a subdomain already mapped to Shopify. </p>
<p>Note that if you do not proxy_pass to a domain Shopify knows about via the Shopify admin DNS settings you must manually set the Host parameter via nginx `proxy_set_header Host mystore.myshopify.com`</p>
<p><pre class="brush: bash;">
# index url
# ---------
location = / {
    proxy_pass http://shopify.grovemade.com;

    client_max_body_size    10m;
    client_body_buffer_size     128k;
    proxy_connect_timeout 90;
}


# grove urls
# ----------
location / {
    proxy_pass http://127.0.0.1:8080/;
    proxy_redirect off;

    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

    client_max_body_size       10m;
    client_body_buffer_size    128k;

    proxy_connect_timeout      90; # time to connect to upstream server
    proxy_send_timeout         120; # time to wait for upstream to accept data
    proxy_read_timeout         120; # time to wait for upstream to return data

    proxy_buffer_size          4k;
    proxy_buffers              4 32k;
    proxy_busy_buffers_size    64k;
    proxy_temp_file_write_size 64k;
}




# shopify urls
# ------------
location ~ ^/(collections|cart|products|shopify|pages|blogs|checkout|admin)/? {
    proxy_pass http://shopify.grovemade.com;

    client_max_body_size    10m;
    client_body_buffer_size     128k;
    proxy_connect_timeout 90;
}
</pre></p>
<p>Restart your nginx server and watch your traffic proxied!</p>
<h3>Extra useful stuff you can do when you share the same domain</h3>
<p>When your django servers and Shopify share the same domain name, you get more than just SEO. You get access to the Shopify cookies&#8230; which means we can programmatically make requests to Shopify to enter checkout, or read the contents of the cart.</p>
<p>I&#8217;ve just started to mess around with this, but it appears that Shopify sets a `cart` cookie with an ID string that you can easily read in django via `request.COOKIES.get(&#8216;cart&#8217;)` . </p>
<p>Add this to the headers when you make a GET request or POST request, and you can manually enter checkout, use the &#8220;js&#8221; API from python, etc. We&#8217;ll be using this to literally only use their checkout page for our site.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yuji.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yuji.wordpress.com/1167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yuji.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yuji.wordpress.com/1167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yuji.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yuji.wordpress.com/1167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yuji.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yuji.wordpress.com/1167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yuji.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yuji.wordpress.com/1167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yuji.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yuji.wordpress.com/1167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yuji.wordpress.com/1167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yuji.wordpress.com/1167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1167&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yuji.wordpress.com/2012/01/11/shopify-behind-an-nginx-reverse-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Yuchan</media:title>
		</media:content>
	</item>
		<item>
		<title>Django &#8212; dictionary update sequence element #0 has length 1; 2 is required</title>
		<link>http://yuji.wordpress.com/2011/12/28/django-dictionary-update-sequence-element-0-has-length-1-2-is-required/</link>
		<comments>http://yuji.wordpress.com/2011/12/28/django-dictionary-update-sequence-element-0-has-length-1-2-is-required/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 21:17:08 +0000</pubDate>
		<dc:creator>Yuji</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://yuji.wordpress.com/?p=1164</guid>
		<description><![CDATA[This error appears if you accidentally pass a string to the url function. I was trying to name my url and forgot it&#8217;s a kwarg.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1164&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This error appears if you accidentally pass a string to the url function.</p>
<p>I was trying to name my url and forgot it&#8217;s a kwarg. </p>
<p><pre class="brush: python;">
url(r'^$', 'foo', 'this_is_invalid'),
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yuji.wordpress.com/1164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yuji.wordpress.com/1164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yuji.wordpress.com/1164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yuji.wordpress.com/1164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yuji.wordpress.com/1164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yuji.wordpress.com/1164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yuji.wordpress.com/1164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yuji.wordpress.com/1164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yuji.wordpress.com/1164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yuji.wordpress.com/1164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yuji.wordpress.com/1164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yuji.wordpress.com/1164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yuji.wordpress.com/1164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yuji.wordpress.com/1164/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1164&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yuji.wordpress.com/2011/12/28/django-dictionary-update-sequence-element-0-has-length-1-2-is-required/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Yuchan</media:title>
		</media:content>
	</item>
		<item>
		<title>Bash &#8212; Escape spaces in results of `pwd` command</title>
		<link>http://yuji.wordpress.com/2011/12/28/bash-escape-spaces-in-results-of-pwd-command/</link>
		<comments>http://yuji.wordpress.com/2011/12/28/bash-escape-spaces-in-results-of-pwd-command/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 20:29:36 +0000</pubDate>
		<dc:creator>Yuji</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://yuji.wordpress.com/?p=1160</guid>
		<description><![CDATA[Just wrap the `pwd` in quotes to escape spaces. It&#8217;s just literally wrapping the output of pwd in a string &#8220;&#8221;.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1160&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just wrap the `pwd` in quotes to escape spaces. It&#8217;s just literally wrapping the output of pwd in a string &#8220;&#8221;. </p>
<p><pre class="brush: bash;">
$ &gt; scp `pwd`/my_file.png foo # reads pwd spaces as argument separator
$ &gt; scp &quot;`pwd`&quot;/my_file.png foo 
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yuji.wordpress.com/1160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yuji.wordpress.com/1160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yuji.wordpress.com/1160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yuji.wordpress.com/1160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yuji.wordpress.com/1160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yuji.wordpress.com/1160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yuji.wordpress.com/1160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yuji.wordpress.com/1160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yuji.wordpress.com/1160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yuji.wordpress.com/1160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yuji.wordpress.com/1160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yuji.wordpress.com/1160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yuji.wordpress.com/1160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yuji.wordpress.com/1160/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1160&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yuji.wordpress.com/2011/12/28/bash-escape-spaces-in-results-of-pwd-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Yuchan</media:title>
		</media:content>
	</item>
		<item>
		<title>When Python Packages Time Out (PIP / easy_install) use mirrors</title>
		<link>http://yuji.wordpress.com/2011/12/16/when-python-packages-time-out-pip-easy_install-use-mirrors/</link>
		<comments>http://yuji.wordpress.com/2011/12/16/when-python-packages-time-out-pip-easy_install-use-mirrors/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 20:17:11 +0000</pubDate>
		<dc:creator>Yuji</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://yuji.wordpress.com/?p=1157</guid>
		<description><![CDATA[http://jacobian.org/writing/when-pypi-goes-down/ pip install &#8211;use-mirrors $PACKAGE<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1157&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>http://jacobian.org/writing/when-pypi-goes-down/</p>
<p>pip install &#8211;use-mirrors $PACKAGE</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yuji.wordpress.com/1157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yuji.wordpress.com/1157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yuji.wordpress.com/1157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yuji.wordpress.com/1157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yuji.wordpress.com/1157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yuji.wordpress.com/1157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yuji.wordpress.com/1157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yuji.wordpress.com/1157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yuji.wordpress.com/1157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yuji.wordpress.com/1157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yuji.wordpress.com/1157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yuji.wordpress.com/1157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yuji.wordpress.com/1157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yuji.wordpress.com/1157/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1157&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yuji.wordpress.com/2011/12/16/when-python-packages-time-out-pip-easy_install-use-mirrors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Yuchan</media:title>
		</media:content>
	</item>
		<item>
		<title>Django Storages, Boto, and Amazon S3 Slowness on manage.py collectstatic command fixed</title>
		<link>http://yuji.wordpress.com/2011/12/09/django-storages-boto-and-amazon-s3-slowness-on-manage-py-collectstatic-command-fixed/</link>
		<comments>http://yuji.wordpress.com/2011/12/09/django-storages-boto-and-amazon-s3-slowness-on-manage-py-collectstatic-command-fixed/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 03:42:27 +0000</pubDate>
		<dc:creator>Yuji</dc:creator>
				<category><![CDATA[Grove]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://yuji.wordpress.com/?p=1150</guid>
		<description><![CDATA[I&#8217;ve had a few issues moving everything to Amazon S3. First, django&#8217;s collectstatic management command wasn&#8217;t even detecting modified files, so the command would re-upload all files to amazon every invocation. Django-Storages v1.1.3 fixed this problem, but now I noticed &#8230; <a href="http://yuji.wordpress.com/2011/12/09/django-storages-boto-and-amazon-s3-slowness-on-manage-py-collectstatic-command-fixed/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1150&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a few issues moving everything to Amazon S3. </p>
<p>First, django&#8217;s collectstatic management command wasn&#8217;t even detecting modified files, so the command would re-upload all files to amazon every invocation.</p>
<p>Django-Storages v1.1.3 fixed this problem, but now I noticed a new problem: modified files were taking less time to detect, but still far too long given that one call was returning the meta data Amazon S3.</p>
<p>After some digging, I found the problem in the modified_time method where the fallback value is being called even if it&#8217;s not being used. I moved the fallback to an if block to be executed only if get returns None</p>
<p><pre class="brush: python;">
entry = self.entries.get(name, self.bucket.get_key(self._encode_name(name))) 
# notice the function being called to populate the default value, regardless
# of whether or not a default is required.
</pre></p>
<p>That code should be wrapped in an if statement and only fire the expensive function if the get function fails.</p>
<p><pre class="brush: python;">
    entry = self.entries.get(name)
    if entry is None:
        entry = self.bucket.get_key(self._encode_name(name))
</pre></p>
<p>This change spurred me to create a bitbucket account and learn some basic Mercurial commands : ) </p>
<p>Hope it helps somebody else out there with many more than 1k files to sync.</p>
<h3>The results</h3>
<p>I benchmarked the difference on my local machine between the two functions.</p>
<p>For 1000 files, the new version took less than .1s vs the old function which took 11.5 seconds.</p>
<p>https://bitbucket.org/yuchant/django-storages/overview</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yuji.wordpress.com/1150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yuji.wordpress.com/1150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yuji.wordpress.com/1150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yuji.wordpress.com/1150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yuji.wordpress.com/1150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yuji.wordpress.com/1150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yuji.wordpress.com/1150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yuji.wordpress.com/1150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yuji.wordpress.com/1150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yuji.wordpress.com/1150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yuji.wordpress.com/1150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yuji.wordpress.com/1150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yuji.wordpress.com/1150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yuji.wordpress.com/1150/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1150&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yuji.wordpress.com/2011/12/09/django-storages-boto-and-amazon-s3-slowness-on-manage-py-collectstatic-command-fixed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Yuchan</media:title>
		</media:content>
	</item>
		<item>
		<title>Python &#8212; add suffix if string slice truncated contents</title>
		<link>http://yuji.wordpress.com/2011/12/08/python-add-suffix-if-string-slice-actually-truncated-contents/</link>
		<comments>http://yuji.wordpress.com/2011/12/08/python-add-suffix-if-string-slice-actually-truncated-contents/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 00:58:34 +0000</pubDate>
		<dc:creator>Yuji</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://yuji.wordpress.com/?p=1144</guid>
		<description><![CDATA[A common design pattern: truncate a string to X chars if the string is long, and show a &#8216;&#8230;&#8217; to indicate the string has been truncated. What&#8217;s the shortest way to write this code? http://stackoverflow.com/questions/2872512/python-truncate-a-long-string<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1144&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A common design pattern: truncate a string to X chars if the string is long, and show a &#8216;&#8230;&#8217; to indicate the string has been truncated.</p>
<p>What&#8217;s the shortest way to write this code? </p>
<p>http://stackoverflow.com/questions/2872512/python-truncate-a-long-string</p>
<p><pre class="brush: python;">
x[:10] + (x[:10] and '...')
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yuji.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yuji.wordpress.com/1144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yuji.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yuji.wordpress.com/1144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yuji.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yuji.wordpress.com/1144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yuji.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yuji.wordpress.com/1144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yuji.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yuji.wordpress.com/1144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yuji.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yuji.wordpress.com/1144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yuji.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yuji.wordpress.com/1144/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1144&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yuji.wordpress.com/2011/12/08/python-add-suffix-if-string-slice-actually-truncated-contents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Yuchan</media:title>
		</media:content>
	</item>
		<item>
		<title>jQuery UI Draggable Table Rows Gotchas</title>
		<link>http://yuji.wordpress.com/2011/12/02/jquery-ui-draggable-table-rows-gotchas/</link>
		<comments>http://yuji.wordpress.com/2011/12/02/jquery-ui-draggable-table-rows-gotchas/#comments</comments>
		<pubDate>Sat, 03 Dec 2011 04:39:04 +0000</pubDate>
		<dc:creator>Yuji</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://yuji.wordpress.com/?p=1139</guid>
		<description><![CDATA[I ran into a few Gotchas while dragging table rows. One was an easy fix, the other took some guesswork. Can&#8217;t drag individual TR elements If you set a &#8220;TR&#8220; element to &#8220;draggable()&#8220;, it will not work because we don&#8217;t &#8230; <a href="http://yuji.wordpress.com/2011/12/02/jquery-ui-draggable-table-rows-gotchas/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1139&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I ran into a few Gotchas while dragging table rows. One was an easy fix, the other took some guesswork. </p>
<h3>Can&#8217;t drag individual TR elements</h3>
<p>If you set a &#8220;TR&#8220; element to &#8220;draggable()&#8220;, it will not work because we don&#8217;t know how to handle a moving TR element (TRs must be in a table to render properly). </p>
<p>To fix this, wrap the TR in a table temporarily while dragging via the helper option. </p>
<p><pre class="brush: jscript;">
            $(&quot;.tr_row&quot;).draggable({
                helper: function(event) {
                    return $('&lt;div class=&quot;drag-row&quot;&gt;&lt;table&gt;&lt;/table&gt;&lt;/div&gt;')
  .find('table').append($(event.target).closest('tr').clone()).end();
                },
            });
</pre></p>
<h3>Sortable / Droppable doesn&#8217;t work on TR elements, or TR elements disappear during drag</h3>
<p>The second problem I ran into was a little more obscure. Your droppable and sortable selectors MUST be applied to a &#8220;&lt;tbody&gt;&#8220; tag.</p>
<p>I noticed that when I had the normal &#8220;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&#8220; structure and dragged, jQuery created a &lt;tbody&gt; element to contain the rows.</p>
<p><pre class="brush: jscript;">
 $(&quot;#my_selector tbody&quot;).droppable().draggable();
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yuji.wordpress.com/1139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yuji.wordpress.com/1139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yuji.wordpress.com/1139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yuji.wordpress.com/1139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yuji.wordpress.com/1139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yuji.wordpress.com/1139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yuji.wordpress.com/1139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yuji.wordpress.com/1139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yuji.wordpress.com/1139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yuji.wordpress.com/1139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yuji.wordpress.com/1139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yuji.wordpress.com/1139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yuji.wordpress.com/1139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yuji.wordpress.com/1139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yuji.wordpress.com&amp;blog=3514052&amp;post=1139&amp;subd=yuji&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yuji.wordpress.com/2011/12/02/jquery-ui-draggable-table-rows-gotchas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Yuchan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
