<?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"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>Cognitive Sandbox &#187; Software development</title> <atom:link href="http://cognitivesandbox.com/posts/tag/software-development/feed/" rel="self" type="application/rss+xml" /><link>http://cognitivesandbox.com</link> <description>Vegan cooking, unix tidbits and other minor discoveries</description> <lastBuildDate>Sat, 03 Dec 2011 01:20:30 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>Media suffix context processor</title><link>http://cognitivesandbox.com/posts/media-suffix-context-processor/</link> <comments>http://cognitivesandbox.com/posts/media-suffix-context-processor/#comments</comments> <pubDate>Sun, 17 Apr 2011 04:09:05 +0000</pubDate> <dc:creator>Brad Beattie</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[Software development]]></category> <guid
isPermaLink="false">http://cognitivesandbox.com/?p=3161</guid> <description><![CDATA[I&#8217;m using this Django context processor for automatically appending a query string for file cache versioning. It generates the query string off of the git revision and saves me many headaches. from django.conf import settings from git import Repo import &#8230; <a
href="http://cognitivesandbox.com/posts/media-suffix-context-processor/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I&#8217;m using this Django context processor for automatically appending a query string for file cache versioning. It generates the query string off of the git revision and saves me many headaches.</p><pre><code>from django.conf import settings
from git import Repo
import hashlib, os
git_head = Repo(settings.PROJECT_DIR).heads[0].commit.hexsha
salted_git_head = hashlib.sha512("".join([
    git_head,
    os.getlogin(),
    "".join(os.uname()),
])).hexdigest()[0:6]
def git_head(request):
    return {
        "GIT_HEAD": git_head,
        "SALTED_GIT_HEAD": salted_git_head,
        "SALTED_GIT_QS": "v=%s" % salted_git_head,
    }
</code></pre>]]></content:encoded> <wfw:commentRss>http://cognitivesandbox.com/posts/media-suffix-context-processor/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>PHP&#8217;s array_walk_recursive</title><link>http://cognitivesandbox.com/posts/phps-array_walk_recursive/</link> <comments>http://cognitivesandbox.com/posts/phps-array_walk_recursive/#comments</comments> <pubDate>Sat, 28 Aug 2010 21:23:21 +0000</pubDate> <dc:creator>Brad Beattie</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[Software development]]></category> <guid
isPermaLink="false">http://cognitivesandbox.com/?p=2729</guid> <description><![CDATA[The description says &#8220;If funcname needs to be working with the actual values of the array, specify the first parameter of funcname as a reference.&#8221; This isn&#8217;t necessarily helpful as the function you&#8217;re calling might be built in (e.g. trim &#8230; <a
href="http://cognitivesandbox.com/posts/phps-array_walk_recursive/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>The description says &#8220;If funcname needs to be working with the actual values of the array, specify the first parameter of funcname as a reference.&#8221; This isn&#8217;t necessarily helpful as the function you&#8217;re calling might be built in (e.g. trim or strip_tags). One option would be to create a version of these like so.</p><pre><code>
function trim_by_reference(&#038;$string) {
    $string = trim($string);
}
</code></pre><p>The downside to this approach is that you need to create a wrapper function for each function you might want to call. Instead, we can use PHP 5.3&#8242;s inline function syntax to create a new version of array_walk_recursive.</p><pre><code>
/**
 * This function acts exactly like array_walk_recursive, except
 * that it pretends that the function its calling replaces the
 * value with its result.
 *
 * @param $array The first value of the array will be passed
 *               into $function as the primary argument
 * @param $function The function to be called on each element
 *               in the array, recursively
 * @param $parameters An optional array of the additional
 *                parameters to be appeneded to the function
 *
 * Example to alter $array to get a short slice of each value
 *    array_walk_recursive_by_reference(
 *        $array, "substr", array("1","3")
 *    );
 */
function array_walk_recursive_by_reference(
        &#038;$array, $function, $parameters = array()) {
    $reference_function = function(&#038;$value, $key, $data) {
        $parameters = array_merge(array($value), $data[1]);
        $value = call_user_func_array($data[0], $parameters);
    };
    array_walk_recursive(
        $array,
        $reference_function,
        array($function, $parameters)
    );
}
</code></pre><p>The advantage here is that we only explicitly define one wrapper function instead of potentially dozens.</p> ]]></content:encoded> <wfw:commentRss>http://cognitivesandbox.com/posts/phps-array_walk_recursive/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Finding columns in a database</title><link>http://cognitivesandbox.com/posts/finding-columns-in-a-database/</link> <comments>http://cognitivesandbox.com/posts/finding-columns-in-a-database/#comments</comments> <pubDate>Sat, 26 Jun 2010 22:13:15 +0000</pubDate> <dc:creator>Brad Beattie</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[Software development]]></category> <guid
isPermaLink="false">http://cognitivesandbox.com/?p=2697</guid> <description><![CDATA[If you need to determine which columns in a database contain a certain type of string, the pseudocode is fairly simple: list all tables in a database, list their columns that are text-oriented, filter those that match some given format. &#8230; <a
href="http://cognitivesandbox.com/posts/finding-columns-in-a-database/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>If you need to determine which columns in a database contain a certain type of string, the pseudocode is fairly simple: list all tables in a database, list their columns that are text-oriented, filter those that match some given format. For large tables, this script won&#8217;t bother looking at too much.</p><pre><code>
############################################
# Imports
import MySQLdb
import sys
############################################
# Initialize the database connection
database = MySQLdb.connect(
  host = "localhost",
  user = "username",
  passwd = "password",
  db = "database")
cursor = database.cursor();
############################################
# Find all matching columns
cursor.execute("SHOW TABLES")
tables = [table[0] for table in cursor.fetchall()]
for table in tables:
  cursor.execute("DESCRIBE %s" % table)
  columns = [column for column in cursor.fetchall()]
  for column in columns:
    if column[1].count("text") or column[1].count("char"):
      cursor.execute("SELECT `%s` FROM \
        (SELECT `%s` FROM `%s` LIMIT 20000) AS subtable \
        WHERE `%s` LIKE %s LIMIT 1" \
        % (column[0], column[0], table, column[0], '"%foo%"'))
      results = cursor.fetchall()
      if results != ():
        print "%s.%s -- %s" % (table, column[0], results)
############################################
# Close the database connection
database.close()
</code></pre>]]></content:encoded> <wfw:commentRss>http://cognitivesandbox.com/posts/finding-columns-in-a-database/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Invasive browser sniffing</title><link>http://cognitivesandbox.com/posts/history-scanner/</link> <comments>http://cognitivesandbox.com/posts/history-scanner/#comments</comments> <pubDate>Fri, 19 Feb 2010 19:47:55 +0000</pubDate> <dc:creator>Brad Beattie</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[Software development]]></category> <guid
isPermaLink="false">http://cognitivesandbox.com/?p=2597</guid> <description><![CDATA[Take the a:visited pseudo-class and use it to determine if the client&#8217;s browser has visited a site. Do this en masse with a subset of Alexa&#8217;s top 1m websites and you can build up a fairly detailed profile of a &#8230; <a
href="http://cognitivesandbox.com/posts/history-scanner/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Take the a:visited pseudo-class and use it to determine if the client&#8217;s browser has visited a site. Do this en masse with a subset of <a
href="http://s3.amazonaws.com/alexa-static/top-1m.csv.zip">Alexa&#8217;s top 1m websites</a> and you can build up a fairly detailed profile of a visiting brower&#8217;s history.</p><pre><code>var sites = [
  'http://google.com',
  'http://facebook.com'
];
$(function(){
  for (var i in sites) {
    $(&quot;#test&quot;).html(&quot;
      &lt;li&gt;&lt;a href='&quot;+sites[i]+&quot;'&gt;&quot;+sites[i]+&quot;&lt;/a&gt; &lt;/li&gt;
    &quot;);
    if ($(&quot;#test a&quot;).css('color') == &quot;rgb(0, 204, 0)&quot;)
      $(&quot;#test li&quot;).appendTo(&quot;#visited&quot;);
    else
      $(&quot;#test li&quot;).appendTo(&quot;#not-visited&quot;);
    }
});</code></pre><ul><li><a
href="http://cognitivesandbox.com/wp-content/uploads/2010/02/history-scanner.html">Try the code</a></li></ul><p>The ethics of this technique are questionable, especially if you retain this data and associate it with an email address or a registered user account. The only way I can see to protect against it is to disable JavaScript on all but the few sites you trust.</p><p>You could augment it to only send a sampling of 50 sites, respond with an ajax post, then determine which 50 to check next (e.g. if a user has visited a site specific to tech news, poll your next 50 on the most popular tech news sites). This concept is used at <a
href="http://whattheinternetknowsaboutyou.com/">What The Internet Knows About You</a>.</p> ]]></content:encoded> <wfw:commentRss>http://cognitivesandbox.com/posts/history-scanner/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Implementing Schulze STV</title><link>http://cognitivesandbox.com/posts/implementing-schulze-stv/</link> <comments>http://cognitivesandbox.com/posts/implementing-schulze-stv/#comments</comments> <pubDate>Tue, 26 Jan 2010 08:06:10 +0000</pubDate> <dc:creator>Brad Beattie</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[Politics]]></category> <category><![CDATA[Software development]]></category> <guid
isPermaLink="false">http://www.cognitivesandbox.com/?p=2461</guid> <description><![CDATA[Thus far, my implementation of Schulze STV has worked fairly well. The downside I&#8217;ve recently run into is in simulating real world multiple winner elections. Take Vancouver&#8217;s 2008 municipal election as an example, in which 32 candidates ran for 10 &#8230; <a
href="http://cognitivesandbox.com/posts/implementing-schulze-stv/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Thus far, <a
href="http://github.com/bradbeattie/Election-Web-Service/blob/master/schulze_stv.py">my implementation of Schulze STV</a> has worked fairly well. The downside I&#8217;ve recently run into is in simulating real world multiple winner elections. Take Vancouver&#8217;s 2008 municipal election as an example, in which 32 candidates ran for 10 seats. The problem-space we&#8217;re looking at consists of <code>32 choose 10</code> nodes and <code>(32 choose 10) x 11</code> edges. For those unfamiliar with <a
href="http://en.wikipedia.org/wiki/Binomial_coefficient">binomial coefficients</a>, that&#8217;s roughly 64 million nodes and  709 million edges. <a
href="http://en.wikipedia.org/wiki/Computational_complexity_theory#Intractability">Exponential runtime is a bitch</a>.</p><p>For the purposes of heuristic development, let&#8217;s look at Tideman&#8217;s A03. It&#8217;s a set of 989 ballots to elect 7 winners from 15 candidates. Schulze STV computes the winning set as B/D/E/F/H/K/N by looking at 6435 nodes and 51480 edges. How do we best prune the number of candidates down so as to look at a smaller subset, yet still produce the same winning set in most cases? Well, what&#8217;s quickly available? We can easily calculate the sum of all votes, standard deviation, and whatnot.</p><p><img
src="http://cognitivesandbox.com/wp-content/uploads/2010/01/sort-by-sum.png" alt="" title="sort-by-sum" width="340" height="366" class="aligncenter size-full wp-image-2484" /></p><p>If we wanted to prune off the least preferred by sum (indicated by larger sums), we&#8217;d be cutting off one of a winner Schulze STV would want to elect. Alternatively, let&#8217;s look at the number of voters that mark each candidate in first place. If a voter marks two candidates in first place, split their vote between the two.</p><p><img
src="http://cognitivesandbox.com/wp-content/uploads/2010/01/sort-by-top-votes.png" alt="" title="sort-by-top-votes" width="405" height="366" class="aligncenter size-full wp-image-2501" /></p><p>That heuristic seems great at first as it didn&#8217;t accidentally eliminate winning candidates and it reduced the number of nodes to 120, a 98% reduction in problem space size. However, the winning set would now be computed by SchulzeSTV as A/B/D/E/G/L/N, which is significantly different. Furthermore, the heuristic is going to incentivize tactical voting. Sometimes there aren&#8217;t any easy shortcuts and the best thing to do is just optimize the implementation.</p> ]]></content:encoded> <wfw:commentRss>http://cognitivesandbox.com/posts/implementing-schulze-stv/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Vancouver Open Data</title><link>http://cognitivesandbox.com/posts/vancouver-open-data/</link> <comments>http://cognitivesandbox.com/posts/vancouver-open-data/#comments</comments> <pubDate>Fri, 22 Jan 2010 01:04:33 +0000</pubDate> <dc:creator>Brad Beattie</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[Software development]]></category> <category><![CDATA[Vancouver]]></category> <guid
isPermaLink="false">http://www.cognitivesandbox.com/?p=2453</guid> <description><![CDATA[Some months ago, there was talk in Vancouver about opening up the city&#8217;s data. As of yesterday, that data is now widely accessible in open formats at data.vancouver.ca. One such data layer is the bike routes in the city. There&#8217;s &#8230; <a
href="http://cognitivesandbox.com/posts/vancouver-open-data/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Some months ago, there was talk in Vancouver about opening up the city&#8217;s data. As of yesterday, that data is now widely accessible in open formats at <a
href="http://data.vancouver.ca/datacatalogue/">data.vancouver.ca</a>. One such data layer is the bike routes in the city. There&#8217;s a lot more and it&#8217;ll be fun to see where it leads.</p><p><iframe
width="425" height="350" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?q=http:%2F%2Fdata.vancouver.ca%2Fdownload%2Fkml%2Fbike_routes.kmz&amp;ie=UTF8&amp;ll=49.257286,-123.123612&amp;spn=0.113533,0.200537&amp;output=embed"></iframe></p> ]]></content:encoded> <wfw:commentRss>http://cognitivesandbox.com/posts/vancouver-open-data/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Short codes</title><link>http://cognitivesandbox.com/posts/short-codes/</link> <comments>http://cognitivesandbox.com/posts/short-codes/#comments</comments> <pubDate>Thu, 21 Jan 2010 02:08:58 +0000</pubDate> <dc:creator>Brad Beattie</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[Software development]]></category> <guid
isPermaLink="false">http://www.cognitivesandbox.com/?p=2437</guid> <description><![CDATA[With the advent of Twitter, shortened URLs have become all the rage: http://bit.ly/5dk33b, http://imgur.com/9G2rL, http://www.reddit.com/9dfo1. This kind of thing really isn&#8217;t all that hard to do. $short_code = substr(preg_replace( array('/\//', '/\+/'), array('-', '_'), base64_encode(sha1(serialize($data, $salt), true)) ), 0, 7); Your &#8230; <a
href="http://cognitivesandbox.com/posts/short-codes/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>With the advent of Twitter, shortened URLs have become all the rage: <a
href="http://bit.ly/5dk33b">http://bit.ly/5dk33b</a>, <a
href="http://imgur.com/9G2rL">http://imgur.com/9G2rL</a>, <a
href="http://www.reddit.com/9dfo1">http://www.reddit.com/9dfo1</a>. This kind of thing really isn&#8217;t all that hard to do.</p><pre><code>$short_code = substr(preg_replace(
  array('/\//', '/\+/'),
  array('-', '_'),
  base64_encode(sha1(serialize($data, $salt), true))
), 0, 7);</code></pre><p>Your <code>$salt</code> might be something as simple as a manually generated random string. If your data is time sensitive, it could be <code>microtime()</code>. Fancier two-way conversions are doable, in which you convert your primary key into a base-62 number, but I&#8217;ve yet to find a need for that.</p> ]]></content:encoded> <wfw:commentRss>http://cognitivesandbox.com/posts/short-codes/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Motivated hobbies</title><link>http://cognitivesandbox.com/posts/motivated-hobbies/</link> <comments>http://cognitivesandbox.com/posts/motivated-hobbies/#comments</comments> <pubDate>Fri, 15 Jan 2010 03:21:27 +0000</pubDate> <dc:creator>Brad Beattie</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[Musings]]></category> <category><![CDATA[Politics]]></category> <category><![CDATA[Software development]]></category> <guid
isPermaLink="false">http://www.cognitivesandbox.com/?p=2411</guid> <description><![CDATA[Start a project around a subject you feel passionate about. It&#8217;s surprising how quickly you can get things done when there&#8217;s internal motivation. My most recent project went from prototype to useful application in about 10 days. I have to &#8230; <a
href="http://cognitivesandbox.com/posts/motivated-hobbies/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Start a project around a subject you feel passionate about. It&#8217;s surprising how quickly you can get things done when there&#8217;s internal motivation. My most recent project went from prototype to useful application in about 10 days. I have to say, there&#8217;s a bit of pride that goes along with reaching a presentable milestone.</p><p><object
width="425" height="344"><param
name="movie" value="http://www.youtube.com/v/dIGL2C47bYo&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param
name="allowFullScreen" value="true"></param><param
name="allowscriptaccess" value="always"></param><embed
src="http://www.youtube.com/v/dIGL2C47bYo&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p> ]]></content:encoded> <wfw:commentRss>http://cognitivesandbox.com/posts/motivated-hobbies/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Modern Ballots</title><link>http://cognitivesandbox.com/posts/modern-ballots/</link> <comments>http://cognitivesandbox.com/posts/modern-ballots/#comments</comments> <pubDate>Mon, 04 Jan 2010 07:33:21 +0000</pubDate> <dc:creator>Brad Beattie</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[Politics]]></category> <category><![CDATA[Software development]]></category> <guid
isPermaLink="false">http://www.cognitivesandbox.com/?p=2394</guid> <description><![CDATA[One of the difficulties I&#8217;ve run into with my recent project is explaining what it is a back-end web service does. In response, I&#8217;ve put a small web app up at modernballots.com. This front-end lets you create elections, but has &#8230; <a
href="http://cognitivesandbox.com/posts/modern-ballots/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>One of the difficulties I&#8217;ve run into with my recent project is explaining what it is a back-end web service does. In response, I&#8217;ve put a small web app up at <a
href="http://www.modernballots.com">modernballots.com</a>. This front-end lets you create elections, but has no direct knowledge of voting systems. The winner is calculated remotely through the <a
href="http://vote.cognitivesandbox.com">election web service</a>, which is publicly available for other programmers to use.</p><p>At the moment, the front-end only requests the winner as calculated by Schulze STV, but that&#8217;s just to make the interface simpler.</p> <a
href='http://cognitivesandbox.com/posts/modern-ballots/attachment/1/' title='1'><img
width="190" height="190" src="http://cognitivesandbox.com/wp-content/uploads/2010/01/1-190x190.png" class="attachment-thumbnail" alt="1" title="1" /></a> <a
href='http://cognitivesandbox.com/posts/modern-ballots/attachment/2/' title='2'><img
width="190" height="190" src="http://cognitivesandbox.com/wp-content/uploads/2010/01/2-190x190.png" class="attachment-thumbnail" alt="2" title="2" /></a> <a
href='http://cognitivesandbox.com/posts/modern-ballots/attachment/3/' title='3'><img
width="190" height="190" src="http://cognitivesandbox.com/wp-content/uploads/2010/01/3-190x190.png" class="attachment-thumbnail" alt="3" title="3" /></a> <a
href='http://cognitivesandbox.com/posts/modern-ballots/attachment/4/' title='4'><img
width="190" height="190" src="http://cognitivesandbox.com/wp-content/uploads/2010/01/4-190x190.png" class="attachment-thumbnail" alt="4" title="4" /></a> <a
href='http://cognitivesandbox.com/posts/modern-ballots/attachment/5/' title='5'><img
width="190" height="190" src="http://cognitivesandbox.com/wp-content/uploads/2010/01/5-190x190.png" class="attachment-thumbnail" alt="5" title="5" /></a> ]]></content:encoded> <wfw:commentRss>http://cognitivesandbox.com/posts/modern-ballots/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Election Web Service</title><link>http://cognitivesandbox.com/posts/election-web-service/</link> <comments>http://cognitivesandbox.com/posts/election-web-service/#comments</comments> <pubDate>Mon, 14 Dec 2009 07:35:59 +0000</pubDate> <dc:creator>Brad Beattie</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[Politics]]></category> <category><![CDATA[Software development]]></category> <guid
isPermaLink="false">http://www.cognitivesandbox.com/?p=2365</guid> <description><![CDATA[First draft of the Election Web Service is up and running. I&#8217;ve implemented Plurality, IRV, Ranked Pairs, the Schulze Method, Plurality at Large, and STV. The source code is up on GitHub for anyone interested in implementing additional voting systems &#8230; <a
href="http://cognitivesandbox.com/posts/election-web-service/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>First draft of the Election Web Service is up and running. I&#8217;ve implemented Plurality, IRV, Ranked Pairs, the Schulze Method, Plurality at Large, and STV.</p><p><a
href="http://github.com/bradbeattie/Election-Web-Service">The source code is up on GitHub</a> for anyone interested in implementing additional voting systems or using them as Python libraries. For those that just want to send requests to a server, I have one responding to posts at <a
href="http://vote.cognitivesandbox.com">vote.cognitivesandbox.com</a> (note that the server only response to HTTP POSTs and works solely on JSON encoded requests).</p><p>Hopefully this takes some of the burden out of implementing polls and whatnot. You take care of storing the ballots, I&#8217;ll show you who won (and why).</p><h3>Example Request</h3><pre><code class="js">{
  "votingSystem": "stv",
  "ballots": [
    {"count": 4, "ballot": ["orange"]},
    {"count": 2, "ballot": ["pear", "orange"]},
    {"count": 8, "ballot": ["chocolate", "strawberry"]},
    {"count": 4, "ballot": ["chocolate", "sweets"]},
    {"count": 1, "ballot": ["strawberry"]},
    {"count": 1, "ballot": ["sweets"]}
  ],
  "winners": 3
}</code></pre><h3>Example Response</h3><pre><code class="js">{
  "rounds": [
    {
      "tallies": {
        "orange": 4.0,
        "strawberry": 1.0,
        "chocolate": 12.0,
        "pear": 2.0,
        "sweets": 1.0
      },
      "quota": 6,
      "winners": ["chocolate"],
    },
    {
      "tallies": {
        "orange": 4.0,
        "strawberry": 5.0,
        "pear": 2.0,
        "sweets": 3.0
      },
      "quota": 5,
      "winners": ["strawberry"],
    },
    {
      "tallies": {
        "orange": 4.0,
        "sweets": 3.0,
        "pear": 2.0
      },
      "quota": 5,
      "loser": "pear"
    },
    {
      "tallies": {
        "orange": 6.0,
        "sweets": 3.0
      },
      "quota": 5,
      "winners": ["orange"],
    }
  ],
  "winners": ["orange", "strawberry", "chocolate"]
}</code></pre>]]></content:encoded> <wfw:commentRss>http://cognitivesandbox.com/posts/election-web-service/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
