Skip to content

Instantly share code, notes, and snippets.

View artolaluis's full-sized avatar

Luis Artola artolaluis

View GitHub Profile
@artolaluis
artolaluis / gist:8309532
Created January 8, 2014 00:32
Quick shell command to find a space-separated list of files that contain a string in a given directory
grep -H -r string_to_find directory_to_search | cut -d: -f1 | sort | uniq | tr "\n" " "
@artolaluis
artolaluis / gist:8427359
Created January 14, 2014 22:40
Django 1.4 to 1.6 url templatetags syntax update. e.g. From {% url foobar one two %} To {% url "foobar" one two %}
sed -e 's/{% url \([^ %]*\)\(.*\)%}/{% url "\1"\2%}/g' file.in > file.out
@artolaluis
artolaluis / gist:c914a5e700195f912a2f
Created May 28, 2014 20:49
List of HTML templates using url template tags.
grep -nri '% url' site/templates | cut -d : -f 1 | sort | uniq | tr "\n" " "
<?xml version=”1.0"?>
<membership>
<users>
<user name=”john”/>
<user name=”charles”/>
<user name=”peter”/>
</users>
from xml.etree import ElementTree
from xml.etree.ElementTree import Element
from xml.etree.ElementTree import SubElement
# <membership/>
membership = Element( 'membership' )
# <membership><users/>
users = SubElement( membership, 'users' )
output_file = open( 'membership.xml', 'w' )
output_file.write( '<?xml version="1.0"?>' )
output_file.write( ElementTree.tostring( membership ) )
output_file.close()