tag:quandyfactory.com,2016-11-2:/2016112 2016-11-2T12:00:00Z Quandy Factory Newsfeed - Projects Quandy Factory is the personal website of Ryan McGreal in Hamilton, Ontario, Canada.. http://quandyfactory.com/projects/150/tracking_movement 2015-06-14T12:00:00Z Tracking Movement <p>I've been tracking my daily/weekly running and stepcounts. You can see the results here:</p> <ul> <li><p><a href="/running">Running</a></p></li> <li><p><a href="/biking">Biking</a></p></li> <li><p><a href="/stepcounts">Stepcounts</a></p></li> </ul> Ryan McGreal 2 http://quandyfactory.com/projects/151/recipes 2015-04-17T12:00:00Z Recipes <p>I've got a new section on the site for recipes I often use. You can find it here:</p> <ul> <li><a href="/recipes">Recipes</a></li> </ul> Ryan McGreal 2 http://quandyfactory.com/projects/74/solitaire 2013-05-08T12:00:00Z Solitaire <p>This is a version of solitaire I hacked up using HTML, CSS, javascript with <a href="http://jquery.com">jQuery</a>, <a href="http://jqueryui.com/">jQUery-UI</a> draggable, the <a href="https://github.com/DanielRapp/Noisy">Noisy</a> jQuery plugin, and only one small image. It's pretty nasty, but I wanted to get a feel for the draggable jquery-UI functionality. </p> <p><strong>Demo</strong>: <a href="http://quandyfactory.com/static/solitaire/solitaire.html">http://quandyfactory.com/static/solitaire/solitaire.html</a></p> <p><strong>Source</strong>: <a href="https://github.com/quandyfactory/Solitaire">https://github.com/quandyfactory/Solitaire</a></p> <p><strong>Update</strong>: You can play this game live, courtesy of PythonAnywhere:</p> <ul> <li><a href="https://www.pythonanywhere.com/gists/459573/rps.py/ipython2/">https://www.pythonanywhere.com/gists/459573/rps.py/ipython2/</a></li> </ul> Ryan McGreal 2 http://quandyfactory.com/projects/87/site-specific_google_search_for_hamiltonca 2011-09-16T12:00:00Z Site-Specific Google Search for Hamilton.ca <p>The <a href="http://hamilton.ca">hamilton.ca</a> search engine is awful. Instead, you can do a site-specific google search to find what you're looking for. The following form does this for you:</p> <script type="text/javascript"> function googleIt() { var keywords = document.getElementById('google_keywords').value; var url = 'http://google.ca/search?q='+encodeURIComponent(keywords)+'+site:hamilton.ca'; window.location = url; } </script> <form method="get" action="https://www.google.com/search" onsubmit="googleIt();return false"> <input style="width: 300px" id="google_keywords" title="Search Terms" type="text"> <input id="submit" type="submit" value="Search Hamilton.ca"> </form> <p>&nbsp;</p> <p>To do this yourself when searching directly in google, just add the following to your search terms: <code>site:hamilton.ca</code>.</p> Ryan McGreal 2 http://quandyfactory.com/projects/73/url_shortener 2011-01-10T12:00:00Z URL Shortener <p>I whipped up a quick utility to shorten URLs using the Google URL Shortener API:</p> <ul> <li><a href="/shorturl">http://quandyfactory.com/shorturl</a></li> </ul> <p>You can read the source code on Github:</p> <script src="https://gist.github.com/773917.js?file=gistfile1.txt"></script> Ryan McGreal 2 http://quandyfactory.com/projects/71/keywordtweets 2010-08-30T12:00:00Z KeywordTweets <p>KeywordTweets is a simple script that returns recent tweets with a given keyword. Includes Python server code and Javascript Ajax script (using jQuery) for the client.</p> <p>The repository is <a href="http://github.com/quandyfactory/KeywordTweets">available on Github</a>.</p> Ryan McGreal 2 http://quandyfactory.com/projects/56/makechart 2010-04-27T12:00:00Z MakeChart <p>Check out the <a href="http://github.com/quandyfactory/MakeChart">Github repository</a> for source and documentation.</p> <p>Here's an example use, assuming you save makechart.py somewhere in your PATH:</p> <pre><code>try: import json except: import simplejson as json import urllib import makechart # chart with world petroleum production data by month from EIA url = 'http://quandyfactory.com/json/makechart' output = urllib.urlopen(url) contents = output.read() dataset = json.loads(contents) caption = 'World Oil Production by Month, 2001-2010&lt;br&gt;(Source: EIA)' unit = 'mbpd' chart = makechart.make_chart(dataset, caption, unit) html = makechart.make_html(chart) file = open('makechart_example.html', 'w') file.write(html) file.close </code></pre> <p>Note: for the sake of convenience, this example uses a sample dataset in JSON format that is <a href="/json/makechart">hosted on this website</a>.</p> Ryan McGreal 2 http://quandyfactory.com/projects/40/pytoc 2010-04-15T12:00:00Z PyToc <h3>Introduction</h3> <p>PyToc generates a table of contents for an HTML document based on headings, with anchor links from the TOC to specific headings.</p> <h3>Download</h3> <p>You can download the latest version of PyToc from its github repository:</p> <ul> <li><a href="http://github.com/quandyfactory/PyToc">http://github.com/quandyfactory/PyToc</a></li> </ul> <h3>Requirements</h3> <ul> <li>Python 2.5 or 2.6</li> <li><a href="http://www.crummy.com/software/BeautifulSoup/">BeautifulSoup</a> 3.0.8</li> </ul> <h3>Using PyToc</h3> <p>You can see the code in action on this very page!</p> <p>It's pretty simple to use. <a href="http://github.com/quandyfactory/PyToc">Download</a> <code>pytoc.py</code> and save it somewhere in your PATH. </p> <p>Here's a demonstration:</p> <pre><code>&gt;&gt;&gt; import urllib &gt;&gt;&gt; import pytoc &gt;&gt;&gt; url = 'http://quandyfactory.com/projects/40/pytoc' &gt;&gt;&gt; page = urllib.urlopen(url) &gt;&gt;&gt; html = page.read() &gt;&gt;&gt; toc = pytoc.Toc(html_in=html) &gt;&gt;&gt; toc.make_toc() True &gt;&gt;&gt; toc.html_toc # returns an HTML table of contents &gt;&gt;&gt; toc.html_out # returns the html with anchors and numbering in headings &gt;&gt;&gt; toc.toc_list # returns a list of tuples in the form (section number, title) </code></pre> <h4>Input Properties</h4> <p>The following are input properties you enter to generate the table of contents.</p> <ul> <li><p><code>html_in</code> - The HTML document for which you want to generate a table of contents.</p> <p>This is the only necessary property to assign. The rest have default values that may meet your needs.</p></li> <li><p><code>levels</code> - A list of numbers corresponding to the heading levels you want to include in your TOC.</p> <p>E.g. [3, 4] would include <code>&lt;h3&gt;</code> and <code>&lt;h4&gt;</code> headings. Default is [3, 4].</p></li> <li><p><code>id</code> - The base id of the HTML table of contents to be generated. Default is "toc".</p></li> <li><p><code>title</code> - The title of the generated table of contents. Default is "Contents".</p></li> </ul> <h4>Methods</h4> <ul> <li><code>make_toc()</code> - this generates the table of contents and populates the output properties. Returns True when complete.</li> </ul> <h4>Output Properties</h4> <p>After calling the <code>make_toc()</code> method, the following output properties are populated with values.</p> <ul> <li><p><code>html_out</code> - The same as <code>html_in</code> except with the TOC anchors and numbering included in the headings.</p></li> <li><p><code>html_toc</code> - The generated HTML table of contents.</p></li> <li><p><code>toc_list</code> - A list of tuples containing the anchors and headings, in case you would rather roll your own HTML table of contents.</p></li> </ul> <p>That's it, really.</p> <h3>History</h3> <p>This library started out as one-off code to generate a table of contents for a long document that I'm converting from MS Word format over to HTML. </p> <p>The existing Word document has had many contributors and editors over the years and the format is a shambles. The table of contents is a mess and the headings are all over the place. (Thanks, WYSIWYG.) </p> <p>I converted the whole thing into <a href="http://daringfireball.net/projects/markdown/" title="John Gruber's Markdown">Markdown</a>, a simple plain-text formatting syntax that converts to clean, structural HTML. </p> <p>I still wanted the final document to have a table of contents, but I didn't want to have to go through the bother of maintaining the thing - especially if I ever wanted to add a new section in the middle, which would require a re-numbering of all the subsequent sections and subsections.</p> <p>I whipped up a simple parser that walked the document and dynamically generated a table of contents, plus anchors in the document so the section headings listed in the contents could straight down to the sections themselves.</p> <h3>Need for Flexibility</h3> <p>It worked, but the code was brittle. It required the HTML formatting to be very strict, e.g. the following would work:</p> <pre><code>&lt;h3&gt;Some subheading title&lt;/h3&gt; </code></pre> <p>but the following would not work:</p> <pre><code>&lt;h3&gt; Some subheading title &lt;/h3&gt; </code></pre> <p>Documents generated using <a href="http://code.google.com/p/python-markdown2/">python-markdown2</a> would work pretty consistently, but documents generated using, say, <a href="http://www.freewisdom.org/projects/python-markdown/">python-markdown</a> would not, since the latter produces messier HTML output. </p> <p>Of course, with documents produced using other means, all bets were off.</p> <p>Anyway, I decided that if this was going to be at all useful as a general-purpose tool, it needed to be more flexible and forgiving. Of course, if you're programming in python, parsing HTML and want to be flexible and forgiving, there's no better tool than the mighty <a href="http://www.crummy.com/software/BeautifulSoup/">BeautifulSoup</a> parsing library.</p> <p>So I re-wrote it using BeautifulSoup.</p> Ryan McGreal 2 http://quandyfactory.com/projects/51/pycouchcontacts 2010-04-12T12:00:00Z PyCouchContacts <p>Coming soon.</p> Ryan McGreal 2 http://quandyfactory.com/projects/49/gitiot 2010-04-07T12:00:00Z Gitiot <p>Gitiot is a really simple cross-platform GUI wrapper for the most minimal useful subset of git's awesome power; i.e. one-button commit and push-to-master for people who want revision control but don't want to learn the command line.</p> <p>Download the repository on <a href="http://github.com/quandyfactory/Gitiot">github</a>.</p> Ryan McGreal 2