Skip to content

Instantly share code, notes, and snippets.

@dvogel
dvogel / gist:8ebf7020d4ee8e709e6034f6aef5f024
Created April 29, 2021 19:30
vim-commentary-empty-comment-confusion.tf
# vim: noexpandtab tabstop=2 shiftwidth=2 softtabstop=2 commentstring=#\ %s
# This is a repro case for the commentary plugin dealing with commenting visual
# blocks in which there is an existing "empty" comment. I am expecting to be
# able to comment all lines of the `resource` block.
# If I place my cursor on `resource` and pressing `VGgc` then
# there is no space between `resource` and the new comment hash at the
# beginning of the line.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>provisioningProfiles</key>
<!-- THIS SHOULD HAVE BEEN A DICT: -->
<string>90064_appcl0XL8guBT_DIST.mobileprovision</string>
</dict>
</plist>
@dvogel
dvogel / congress_bill_transitions.rb
Created January 31, 2014 22:35
A script to generate a Graphviz file for what happens to bills in congress
require 'set'
require 'pp'
require 'json'
require 'date'
require 'bigdecimal'
module BillStateGraphs
class BillAction
attr_accessor :acted_at
@dvogel
dvogel / search.cc
Created May 15, 2012 18:17
Superfastmatch Search::execute and PostingSlot::searchIndex
void Search::execute(){
size_t num_results=registry_->getNumResults();
size_t count=0;
registry_->getPostings()->searchIndex(*this);
for(inverted_search_t::iterator it2=pruned_results.begin(),ite2=pruned_results.end();(it2!=ite2) && (count<num_results);++it2){
DocumentPtr other=registry_->getDocumentManager()->getDocument(it2->second.doc_type,it2->second.doc_id,DocumentManager::META);
AssociationPtr association(new Association(registry_,doc,other));
performance->add(association->getInstrument());
if (association->getResultCount()>0){
associations.push_back(association);
@dvogel
dvogel / update_index.py
Created January 4, 2012 17:02
Haystack update_index do_update
def do_update(backend, index, qs, start, end, total, verbosity=1):
# Get a clone of the QuerySet so that the cache doesn't bloat up
# in memory. Useful when reindexing large amounts of data.
small_cache_qs = qs.all()
current_qs = small_cache_qs[start:end]
if verbosity >= 2:
if os.getpid() == os.getppid():
print " indexed %s - %d of %d." % (start+1, end, total)
else:
@dvogel
dvogel / gist:663215
Created November 4, 2010 21:21
Tornado web.py diff
175c175
< def clear(self):
---
> def clear(self, extra_headers=None):
180a181,182
> if extra_headers:
> self._headers.update(extra_headers)
578c580
< def send_error(self, status_code=500, **kwargs):
---
@dvogel
dvogel / gist:663167
Created November 4, 2010 20:51
Tornado RequestHandler.send_error
def send_error(self, status_code=500, **kwargs):
"""Sends the given HTTP error code to the browser.
We also send the error HTML for the given error code as returned by
get_error_html. Override that method if you want custom error pages
for your application.
"""
if self._headers_written:
logging.error("Cannot send error response after headers written")
if not self._finished: