<?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"
	>

<channel>
	<title>Ninjacipher</title>
	<atom:link href="http://www.ninjacipher.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ninjacipher.com</link>
	<description></description>
	<pubDate>Mon, 04 Aug 2008 22:45:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>New Django Paginator Example</title>
		<link>http://www.ninjacipher.com/2008/08/04/new-django-paginator-example/</link>
		<comments>http://www.ninjacipher.com/2008/08/04/new-django-paginator-example/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 17:06:28 +0000</pubDate>
		<dc:creator>mattd</dc:creator>
		
		<category><![CDATA[development]]></category>

		<category><![CDATA[django]]></category>

		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.ninjacipher.com/?p=52</guid>
		<description><![CDATA[So I pulled the latest Django codebase from svn today and I noticed that my old pagination setup no longer works. Not really surprising as a ton of stuff is being updated due to the coming release of 1.0. So I did a bit of digging into the new pagination code to see if I [...]]]></description>
			<content:encoded><![CDATA[<p>So I pulled the latest Django codebase from svn today and I noticed that my old pagination setup no longer works. Not really surprising as a ton of stuff is being updated due to the coming release of 1.0. So I did a bit of digging into the new pagination code to see if I could rework my <a href="http://www.ninjacipher.com/2007/12/27/django-pagination-wrapper/" target="_blank">wrapper class</a> to work with the new release. It turns out that with the updates there really is no good reason to wrap the classes any more. They have done a good job of working out all the kinks in the pagination setup and it does everything I need it to do out of the box.</p>
<p>So here is a quick nutshell example of how I am using the new django.core.paginator classes to replace the old ObjectPaginator wrapper from my <a href="http://www.ninjacipher.com/2007/12/27/django-pagination-wrapper/" target="_blank">previous example</a>.</p>
<p>in your view:</p>
<pre>from django.core.paginator import Paginator

#create a new paginator instance by passing it a collection of objects and the per page count
paginator = Paginator(Contact.objects.all().order_by('last_name'), 10)

#get the page number from a get param
#if param is blank then set page to 1
page = int(request.GET.get('page', '1'))

#grab the current page from the paginator...
contacts = paginator.page(page)

#render the template and pass the contacts page into the template
return render_to_response('contacts.html',{'contacts':contacts})</pre>
<p>in your template:</p>
<pre>{% for contact in contacts.object_list %}
{{ contact.name }}
{% endfor %}</pre>
<p>I&#8217;d say that&#8217;s pretty easy. <a href="http://www.ninjacipher.com/wp-content/uploads/2008/08/footerexample.txt">Here is a link</a> to a simple snippet that you can use to create a paging footer. </p>
<p>Notice to get the page of pages info all you have to do is output the page object like so&#8230; {{ contacts }} . Pretty cool.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ninjacipher.com/2008/08/04/new-django-paginator-example/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Linux vs Linux vs (well you get the picture)</title>
		<link>http://www.ninjacipher.com/2008/07/22/linux-vs-linux-vs-well-you-get-the-picture/</link>
		<comments>http://www.ninjacipher.com/2008/07/22/linux-vs-linux-vs-well-you-get-the-picture/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 23:42:57 +0000</pubDate>
		<dc:creator>mattd</dc:creator>
		
		<category><![CDATA[development]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[trendrr]]></category>

		<guid isPermaLink="false">http://www.ninjacipher.com/?p=50</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><script src="http://www.trendrr.com/embed/graph/393642/medium" type="text/javascript"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ninjacipher.com/2008/07/22/linux-vs-linux-vs-well-you-get-the-picture/feed/</wfw:commentRss>
		</item>
		<item>
		<title>group_required decorator</title>
		<link>http://www.ninjacipher.com/2008/06/20/group_required-decorator/</link>
		<comments>http://www.ninjacipher.com/2008/06/20/group_required-decorator/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 19:17:56 +0000</pubDate>
		<dc:creator>mattd</dc:creator>
		
		<category><![CDATA[development]]></category>

		<category><![CDATA[django]]></category>

		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.ninjacipher.com/?p=49</guid>
		<description><![CDATA[Here is a decorator that I came up with to augment the already available login_required and permission_required decorators. This one takes a group name and makes sure the logged in user is a part of it.
def group_required(group_name, login_url='/accounts/login/'):
    def wrap(view_func):
        def in_group(request, *args, **kwargs):
  [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a decorator that I came up with to augment the already available login_required and permission_required decorators. This one takes a group name and makes sure the logged in user is a part of it.</p>
<pre>def group_required(group_name, login_url='/accounts/login/'):
    def wrap(view_func):
        def in_group(request, *args, **kwargs):
            from django.contrib.auth.models import Group
            try:
                group = request.user.groups.get(name=group_name)
            except Group.DoesNotExist:
                from django.http import HttpResponseRedirect
                return HttpResponseRedirect(login_url)
            else:
                return view_func(request, *args, **kwargs)

        return in_group
    return wrap
</pre>
<p>to use</p>
<pre>@group_required('groupies')
def index(request):
   ...
</pre>
<p>I&#8217;m posting this with a disclaimer up front. Every time I post what I think is a clever snippet someone always tells me that I am reinventing the wheel and it already exists in django. So if this is another case of me being tragically uninformed then please let me know as I would most likely use the official way instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ninjacipher.com/2008/06/20/group_required-decorator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Batch converting avi files for xbox</title>
		<link>http://www.ninjacipher.com/2008/04/27/batch-converting-avi-files-for-xbox/</link>
		<comments>http://www.ninjacipher.com/2008/04/27/batch-converting-avi-files-for-xbox/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 16:33:15 +0000</pubDate>
		<dc:creator>mattd</dc:creator>
		
		<category><![CDATA[tutorials]]></category>

		<category><![CDATA[video]]></category>

		<category><![CDATA[xbox]]></category>

		<guid isPermaLink="false">http://www.ninjacipher.com/2008/04/27/batch-converting-avi-files-for-xbox/</guid>
		<description><![CDATA[So awhile back (when I switched to Vista which had built in windows media center) I started getting into streaming videos from my pc to my xbox over the network so I could watch them on my tv. I did some searching and found that you have to convert everything to wmv first. So since [...]]]></description>
			<content:encoded><![CDATA[<p>So awhile back (when I switched to Vista which had built in windows media center) I started getting into streaming videos from my pc to my xbox over the network so I could watch them on my tv. I did some searching and found that you have to convert everything to wmv first. So since all the files I have were avi files I found <a href="http://www.joystiq.com/2006/11/07/how-to-transcode-and-stream-videos-on-xbox-360/" target="_blank">this tutorial</a> to help me convert the files without having to pay for some shady converter software. Following that tutorial I got up and running fairly quickly and everything was peachy. Well sorta. My only issue was with this method you can only do one video at a time. So since I have a huge library of episodic anime this quickly became a prob. So I wrote a little add on to the instructions above that allows you to batch convert your avi files to wmv file using vlc player.</p>
<p>First the convert.bat file. Copy this code to a file and name it convert.bat. Put it in the directory where all your avi files are.</p>
<pre>
"C:\Program Files\VideoLAN\VLC\vlc" -vvv %1 --sout-ffmpeg-qscale 1 :sout=#transcode{vcodec=WMV2,scale=1,acodec=wma,ab=96,channels=2}:duplicate{dst=std{access=file,mux=asf,dst=%1.wmv}} vlc:quit</pre>
<p><em>note</em><br />
You may have to change this part C:\Program Files\VideoLAN\VLC\vlc to point at the path you installed your alc player if you didn&#8217;t go with the default install location.</p>
<p>Next the the bulk-convert script. Save the following code into a file and name it bulk-convert.bat. Put this script in the same directory as you convert.bat and all your avi files.</p>
<pre>
lfnfor off
for %%x in (*.avi) do call convert.bat %%x</pre>
<p>From there all you have to do is click on the bulk-convert.bat file and it will cycle through all the avi files in the directory and feed them into your convert.bat file.</p>
<p>Enjoy <img src='http://www.ninjacipher.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ninjacipher.com/2008/04/27/batch-converting-avi-files-for-xbox/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
