<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr - magicrebirth</title>
<link>http://snipplr.com/users/magicrebirth</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Thu, 20 Jun 2013 08:26:48 GMT</pubDate>
<item>
<title>(Django) Override the change_view in the admin</title>
<link>http://snipplr.com/view/62778/override-the-changeview-in-the-admin/</link>
<description><![CDATA[ <p>Adding another button with name "addnextid" would trigger our custom action, that redirects the user to the changeform screen for the next available item (by ID).

Then you can override admin/submit_line.html. Copy the version in contrib.admin.templates into your project. Mine is myproject/templates/admin/submit_line.html, but you could use /myproject/myapp/templates/admin/submit_line.html.

Next, edit the copy and add the code for showing the 'Save and edit next item (by ID)' link, which is caught via the "_addnextid" name. 

p.s.
The submit_line.html template is called in change_form.html via the {% submit_row %} tag.</p> ]]></description>
<pubDate>Thu, 26 Jan 2012 04:35:50 GMT</pubDate>
<guid>http://snipplr.com/view/62778/override-the-changeview-in-the-admin/</guid>
</item>
<item>
<title>(Django) Clean up expired django.contrib.session\'s in a huge MySQL InnoDB table</title>
<link>http://snipplr.com/view/62190/clean-up-expired-djangocontribsessions-in-a-huge-mysql-innodb-table/</link>
<description><![CDATA[ <p>While django provides the django_admin.py cleanup script, if sessions get out of control sometimes you have to go lower level to get everything cleaned up. If the problem gets out of hand and you hit the resource limits of the machine, it is very difficult to get anything done in the database.

Attached is SQL code which was used to cleanup 27GB of expired session data in 3h. Run it like this to make sure it runs to completion:

`nohup mysql --user=username --password=password --host=hostname database < delete_expired_sessions.sql`

nohup causes the script to run detached from a terminal, so if your session gets disconnected it will keep running.

p.s.
An alternative approach is to launch this command from the shell:

DELETE FROM django_session WHERE expire_date < NOW();

or 

DELETE FROM django_session WHERE expire_date < "2011-12-10 00:00:00";</p> ]]></description>
<pubDate>Fri, 30 Dec 2011 23:12:12 GMT</pubDate>
<guid>http://snipplr.com/view/62190/clean-up-expired-djangocontribsessions-in-a-huge-mysql-innodb-table/</guid>
</item>
<item>
<title>(Django) Adding request object info to a template</title>
<link>http://snipplr.com/view/60684/adding-request-object-info-to-a-template/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Thu, 10 Nov 2011 10:36:28 GMT</pubDate>
<guid>http://snipplr.com/view/60684/adding-request-object-info-to-a-template/</guid>
</item>
<item>
<title>(Bash) How to make git use TextMate as the default commit editor « Developmentality</title>
<link>http://snipplr.com/view/59658/how-to-make-git-use-textmate-as-the-default-commit-editor--developmentality/</link>
<description><![CDATA[ <p>Now when you do a git commit without specifying a commit message, TextMate will pop-up and allow you to enter a commit message in it. When you save the file and close the window, the commit will go through as normal. (If you have another text editor you prefer instead, just change the “mate -w” line to the preferred one)

For those curious what the -w argument is about, it tells the shell to wait for the mate process to terminate (the file to be saved and closed).</p> ]]></description>
<pubDate>Wed, 12 Oct 2011 06:28:41 GMT</pubDate>
<guid>http://snipplr.com/view/59658/how-to-make-git-use-textmate-as-the-default-commit-editor--developmentality/</guid>
</item>
<item>
<title>(Django) Django: check whether an object already exists before adding</title>
<link>http://snipplr.com/view/59359/django-check-whether-an-object-already-exists-before-adding/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Mon, 03 Oct 2011 21:49:28 GMT</pubDate>
<guid>http://snipplr.com/view/59359/django-check-whether-an-object-already-exists-before-adding/</guid>
</item>
<item>
<title>(Python) Indenting source code in python</title>
<link>http://snipplr.com/view/57154/indenting-source-code-in-python/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 26 Jul 2011 21:08:09 GMT</pubDate>
<guid>http://snipplr.com/view/57154/indenting-source-code-in-python/</guid>
</item>
<item>
<title>(Django) Getting Random objects from a Queryset in Django</title>
<link>http://snipplr.com/view/57053/getting-random-objects-from-a-queryset-in-django/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Sat, 23 Jul 2011 01:15:14 GMT</pubDate>
<guid>http://snipplr.com/view/57053/getting-random-objects-from-a-queryset-in-django/</guid>
</item>
<item>
<title>(Python) Statistical String Comparison</title>
<link>http://snipplr.com/view/57051/statistical-string-comparison/</link>
<description><![CDATA[ <p>http://docs.python.org/library/difflib.html</p> ]]></description>
<pubDate>Fri, 22 Jul 2011 23:06:05 GMT</pubDate>
<guid>http://snipplr.com/view/57051/statistical-string-comparison/</guid>
</item>
<item>
<title>(Django) Convert the time.struct_time object into a datetime.datetime object:</title>
<link>http://snipplr.com/view/56927/convert-the-timestructtime-object-into-a-datetimedatetime-object/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Wed, 20 Jul 2011 23:41:06 GMT</pubDate>
<guid>http://snipplr.com/view/56927/convert-the-timestructtime-object-into-a-datetimedatetime-object/</guid>
</item>
<item>
<title>(Python) Colorizing Python Source Using the Built-in Tokenizer</title>
<link>http://snipplr.com/view/56858/colorizing-python-source-using-the-builtin-tokenizer/</link>
<description><![CDATA[ <p>You need to convert Python source code into HTML markup, rendering comments, keywords, operators, and numeric and string literals in different colors.
tokenize.generate_tokens does most of the work. We just need to loop over all tokens it finds, to output them with appropriate colorization:</p> ]]></description>
<pubDate>Tue, 19 Jul 2011 18:01:26 GMT</pubDate>
<guid>http://snipplr.com/view/56858/colorizing-python-source-using-the-builtin-tokenizer/</guid>
</item>
<item>
<title>(Python) RGB Gradation Chart Generator</title>
<link>http://snipplr.com/view/56710/rgb-gradation-chart-generator/</link>
<description><![CDATA[ <p>[from the author's website]
I wrote this to better understand the relationship between RGB colors. Running it will generate a fairly large HTML file with all sorts of color transitions on it so you can see what is happening as colors are tweaked in different ways.</p> ]]></description>
<pubDate>Sun, 17 Jul 2011 20:22:21 GMT</pubDate>
<guid>http://snipplr.com/view/56710/rgb-gradation-chart-generator/</guid>
</item>
<item>
<title>(Python) RGB Color Gradation Function</title>
<link>http://snipplr.com/view/56709/rgb-color-gradation-function/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Sun, 17 Jul 2011 20:15:43 GMT</pubDate>
<guid>http://snipplr.com/view/56709/rgb-color-gradation-function/</guid>
</item>
<item>
<title>(Bash) Shell : How to rename/mv large number of files</title>
<link>http://snipplr.com/view/56327/shell--how-to-renamemv-large-number-of-files/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Fri, 08 Jul 2011 20:53:21 GMT</pubDate>
<guid>http://snipplr.com/view/56327/shell--how-to-renamemv-large-number-of-files/</guid>
</item>
<item>
<title>(Python) Counting elements in a list</title>
<link>http://snipplr.com/view/55137/counting-elements-in-a-list/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Sat, 11 Jun 2011 00:49:15 GMT</pubDate>
<guid>http://snipplr.com/view/55137/counting-elements-in-a-list/</guid>
</item>
<item>
<title>(Python) Extracting a URL in Python</title>
<link>http://snipplr.com/view/55134/extracting-a-url-in-python/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Fri, 10 Jun 2011 23:43:42 GMT</pubDate>
<guid>http://snipplr.com/view/55134/extracting-a-url-in-python/</guid>
</item>
<item>
<title>(Django) Adding custom django package to WSGI settings</title>
<link>http://snipplr.com/view/54284/adding-custom-django-package-to-wsgi-settings/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 24 May 2011 00:05:01 GMT</pubDate>
<guid>http://snipplr.com/view/54284/adding-custom-django-package-to-wsgi-settings/</guid>
</item>
<item>
<title>(Python) Ways to Move up and Down the dir structure in Python</title>
<link>http://snipplr.com/view/53250/ways-to-move-up-and-down-the-dir-structure-in-python/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Mon, 09 May 2011 23:10:03 GMT</pubDate>
<guid>http://snipplr.com/view/53250/ways-to-move-up-and-down-the-dir-structure-in-python/</guid>
</item>
<item>
<title>(Django) Remove duplicates from a list</title>
<link>http://snipplr.com/view/51688/remove-duplicates-from-a-list/</link>
<description><![CDATA[ <p>Not only is it really really fast; it's also order preserving and supports an optional transform function</p> ]]></description>
<pubDate>Thu, 07 Apr 2011 04:06:46 GMT</pubDate>
<guid>http://snipplr.com/view/51688/remove-duplicates-from-a-list/</guid>
</item>
<item>
<title>(Python) Python: rename a file</title>
<link>http://snipplr.com/view/51486/python-rename-a-file/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Mon, 04 Apr 2011 00:06:08 GMT</pubDate>
<guid>http://snipplr.com/view/51486/python-rename-a-file/</guid>
</item>
<item>
<title>(Python) Getting the difference between two lists - Python</title>
<link>http://snipplr.com/view/51138/getting-the-difference-between-two-lists--python/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Sat, 26 Mar 2011 03:19:27 GMT</pubDate>
<guid>http://snipplr.com/view/51138/getting-the-difference-between-two-lists--python/</guid>
</item>
</channel>
</rss>