<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7702416879586229335</id><updated>2012-02-16T11:24:33.341-08:00</updated><category term='CruiseControl PHP PHPUnderControl Ubuntu Deployment'/><title type='text'>local.cache</title><subtitle type='html'>Programming is friendship.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://localcache.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7702416879586229335/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://localcache.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>David Fritzman</name><uri>http://www.blogger.com/profile/07382999229792587280</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7702416879586229335.post-3452850445468918714</id><published>2009-08-11T19:36:00.000-07:00</published><updated>2009-08-11T21:37:36.581-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CruiseControl PHP PHPUnderControl Ubuntu Deployment'/><title type='text'>Cruise Control and PHPUnderControl on Ubuntu 9.04</title><content type='html'>Most of this was stolen from &lt;a href="http://no-names.biz/2008/06/09/cruisecontrol-and-phpundercontrol-in-debian-etch/"&gt;http://no-names.biz/2008/06/09/cruisecontrol-and-phpundercontrol-in-debian-etch/&lt;/a&gt; and &lt;a href="http://confluence.public.thoughtworks.org/display/CC/Getting+Started+With+CruiseControl"&gt;http://confluence.public.thoughtworks.org/display/CC/Getting+Started+With+CruiseControl&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;1.) Install the sun's java 6 runtime via `sudo apt-get install sun-java6-bin`. I had to enable the multiverse repositories by editing my /etc/apt/sources.list and adding multiverse to the end of every line.&lt;br /&gt;2.) Add 'JAVA_HOME="/usr/lib/jvm/java-6-openjdk/jre/"' into /etc/environment and run `source /etc/environment`.&lt;br /&gt;3.) Download the Cruise Control binary into opt by running `wget http://switch.dl.sourceforge.net/sourceforge/cruisecontrol/cruisecontrol-bin-2.7.2.zip`&lt;br /&gt;4.) Unzip and make a link to /opt/cruisecontrol.&lt;br /&gt;5.) Install php-pear via `sudo apt-get install php-pear`.&lt;br /&gt;6.) Install php under control and phpunit via pear by running:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;pear config-set preferred_state beta&lt;br /&gt;pear channel-discover components.ez.no&lt;br /&gt;pear install -a ezc/Graph&lt;br /&gt;pear channel-discover pear.phpunit.de&lt;br /&gt;pear install --alldeps phpunit/phpUnderControl&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Note: When running the last command php's cli let me know it ran out of memory. I edited /etc/php5/cli/php.ini and changed memory_limit from 32M to 512M. I changed this back after the installation was complete.&lt;br /&gt;7.) Run `phpuc install /opt/cruisecontrol` to get phpUnderControl setup in cruise control.&lt;br /&gt;8.) Go into /opt/cruisecontrol/projects and copy the connectfour directory to the name of your project.&lt;br /&gt;9.) go into the directory you just created and delete everything under the src directory. Checkout your subversion repository here.&lt;br /&gt;10.) Edit your build.xml file to look like:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;project name="projectname" basedir="."&gt;&lt;br /&gt;  &lt;target name="checkout"&gt;&lt;br /&gt;    &lt;exec executable="svn" dir="${basedir}/src"&gt;&lt;br /&gt;      &lt;arg line="up" /&gt;&lt;br /&gt;    &lt;/exec&gt;&lt;br /&gt;  &lt;/target&gt;&lt;br /&gt;&lt;/project&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;11.) Now run `../../apache-ant-1.7.0/bin/ant checkout` and you should see:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-sun-1.6.0.14/lib/tools.jar&lt;br /&gt;Buildfile: build.xml&lt;br /&gt;&lt;br /&gt;checkout:&lt;br /&gt;     [exec] At revision 4347.&lt;br /&gt;&lt;br /&gt;BUILD SUCCESSFUL&lt;br /&gt;Total time: 1 second&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7702416879586229335-3452850445468918714?l=localcache.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://localcache.blogspot.com/feeds/3452850445468918714/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://localcache.blogspot.com/2009/08/cruise-control-and-phpundercontrol-on.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7702416879586229335/posts/default/3452850445468918714'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7702416879586229335/posts/default/3452850445468918714'/><link rel='alternate' type='text/html' href='http://localcache.blogspot.com/2009/08/cruise-control-and-phpundercontrol-on.html' title='Cruise Control and PHPUnderControl on Ubuntu 9.04'/><author><name>David Fritzman</name><uri>http://www.blogger.com/profile/07382999229792587280</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7702416879586229335.post-4466233007929551937</id><published>2009-08-07T15:11:00.001-07:00</published><updated>2009-08-10T11:16:04.846-07:00</updated><title type='text'>Examining MySQL Slow Query Logs With AWK and PERL</title><content type='html'>To pull out the information for the slow queries use:&lt;br /&gt;&lt;pre&gt;awk '$2 ~ /Query_time/' slow-log&lt;/pre&gt;&lt;br /&gt;To print out just the times of each query:&lt;br /&gt;&lt;pre&gt;awk '{if ($2 ~ /Query_time/) { print $3; }}' slow-log&lt;/pre&gt;&lt;br /&gt;To print out each query as "time - query":&lt;br /&gt;&lt;pre&gt;#!/usr/bin/perl&lt;br /&gt;# takes in a mysql slow query log and spits out a ranked list of query time&lt;br /&gt;# and queries.&lt;br /&gt;open FILE, "&lt;slow-log" or die $!;&lt;br /&gt;&lt;br /&gt;my @times;&lt;br /&gt;my %times_to_sql;&lt;br /&gt;&lt;br /&gt;while ($line = &lt;FILE&gt;) {&lt;br /&gt;  if ($line =~ m/Query_time: (\d+\.\d+)/) { # looking for query time&lt;br /&gt;    my $time = $1;&lt;br /&gt;    # building offending query&lt;br /&gt;    $sql = "";&lt;br /&gt;    while ($line_sql = &lt;FILE&gt; and ($line_sql !~ m/^#/) and 1) {&lt;br /&gt;      chomp($line_sql);&lt;br /&gt;      $sql .= $line_sql . " ";&lt;br /&gt;    }&lt;br /&gt;    $times_to_sql{$time} = $sql;&lt;br /&gt;    push @times, $time;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;close $FILE;&lt;br /&gt;&lt;br /&gt;open FILE, "&gt;slow-log-ranked" or die $!;&lt;br /&gt;&lt;br /&gt;@sorted_times = sort { $b &lt;=&gt; $a } @times;&lt;br /&gt;foreach my $time (@sorted_times) {&lt;br /&gt;  print FILE "$time  - ".$times_to_sql{$time}."\n";&lt;br /&gt;}&lt;br /&gt;close FILE;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7702416879586229335-4466233007929551937?l=localcache.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://localcache.blogspot.com/feeds/4466233007929551937/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://localcache.blogspot.com/2009/08/examining-mysql-slow-query-logs-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7702416879586229335/posts/default/4466233007929551937'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7702416879586229335/posts/default/4466233007929551937'/><link rel='alternate' type='text/html' href='http://localcache.blogspot.com/2009/08/examining-mysql-slow-query-logs-with.html' title='Examining MySQL Slow Query Logs With AWK and PERL'/><author><name>David Fritzman</name><uri>http://www.blogger.com/profile/07382999229792587280</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7702416879586229335.post-9048038886835863895</id><published>2009-08-03T10:04:00.000-07:00</published><updated>2009-08-03T10:12:53.850-07:00</updated><title type='text'>Loading Django models.ImageField via a URL</title><content type='html'>The Django models.ImageField class is an easy way to store images in Django. However, for me it was unclear what to do if the user just has a URL. In my experience this is a common case. If you are building a website that aggregates content from other places and you are allowed to host the image content you are aggregating then it is cumbersome for a user to save a file to their local system and then upload it. It would be much easier if it was possible to use a URL to import this information.&lt;br /&gt;&lt;br /&gt;Here is how to do that via the Django shell:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;url = "http://media.buffalonews.com/smedia/2009/07/20/07/646-0720homelife.standalone.prod_affiliate.50.JPG";&lt;br /&gt;&lt;br /&gt;import os&lt;br /&gt;original_filename = os.path.basename(url)&lt;br /&gt;fp = urllib.urlopen(url)&lt;br /&gt;imgstr = cStringIO.StringIO(fp.read())&lt;br /&gt;storage = S3Storage()&lt;br /&gt;img = My_Image()&lt;br /&gt;path = S3Storage.save(storage, original_filename, ContentFile(imgstr.getvalue()))&lt;br /&gt;import Image&lt;br /&gt;pilimg = Image.open(imgstr)&lt;br /&gt;img.image = path&lt;br /&gt;img.width = pilimg.size[0]&lt;br /&gt;img.height = pilimg.size[1]&lt;br /&gt;img.save()&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I am using the &lt;a href="http://code.welldev.org/django-storages/wiki/S3Storage"&gt;S3Storage library&lt;/a&gt; to store my images.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7702416879586229335-9048038886835863895?l=localcache.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://localcache.blogspot.com/feeds/9048038886835863895/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://localcache.blogspot.com/2009/08/loading-django-modelsimagefield-via-url.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7702416879586229335/posts/default/9048038886835863895'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7702416879586229335/posts/default/9048038886835863895'/><link rel='alternate' type='text/html' href='http://localcache.blogspot.com/2009/08/loading-django-modelsimagefield-via-url.html' title='Loading Django models.ImageField via a URL'/><author><name>David Fritzman</name><uri>http://www.blogger.com/profile/07382999229792587280</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
