This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def agent(): | |
log_level = ( | |
logging.DEBUG | |
if os.environ.get("DEBUG", "false").lower() == "true" | |
else logging.INFO | |
) | |
http_client.HTTPConnection.debuglevel = 1 if log_level == logging.DEBUG else 0 | |
logging.basicConfig() | |
logging.getLogger().setLevel(log_level) | |
requests_log = logging.getLogger("requests.packages.urllib3") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"normalizedInput": { | |
"line1": "753 Sunset Drive", | |
"city": "Lawrence", | |
"state": "KS", | |
"zip": "66044" | |
}, | |
"kind": "civicinfo#representativeInfoResponse", | |
"divisions": { | |
"ocd-division/country:us": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KSVotes.org uses the JavaScript library | |
https://github.com/szimek/signature_pad | |
to capture signature and save it as a base64-encoded string in the database. | |
The image string is then inserted into the registration or AB form as necessary. | |
You can see how ksvotes implements the library here: | |
https://github.com/BlueprintKansas/ksvotes.org/blob/master/app/templates/_signature.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ HEAD http://www.kssos.org/elections/18elec/2018_Primary_Election_United_States_House_of_Representatives_results_precinct.xlsx | |
200 OK | |
Date: Sat, 01 Dec 2018 19:31:09 GMT | |
Accept-Ranges: bytes | |
ETag: "fcfbe1a25f57d41:0" | |
Server: | |
Content-Length: 1473835 | |
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | |
Last-Modified: Fri, 28 Sep 2018 19:15:36 GMT | |
Client-Date: Sat, 01 Dec 2018 19:31:10 GMT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66002 | |
66006 | |
66007 | |
66008 | |
66010 | |
66012 | |
66013 | |
66014 | |
66015 | |
66016 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
form = initialize_form(request.params) | |
if form.is_valid(): | |
step = initialize_step(form, session_id) | |
step.perform() # do whatever is needed, write to the db | |
if step.is_complete(): | |
redirect_to step.next_step() | |
else: | |
render_form_for_this_step(request.params) # re-render with form pre-populated | |
else: | |
render_form_for_this_step(request.params) # re-render with form pre-populated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select s.id, count(rs.route_id) as nroutes | |
from stops as s left join routes_stops as rs on s.id=rs.stop_id | |
group by s.id | |
order by nroutes desc | |
limit 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Dezi::Client; | |
use Dezi::Doc; | |
my $BATCH_SIZE = 1000; # number of docs to buffer before committing. | |
if ( $#ARGV != 0 ) { | |
die "$0 inputfile.tsv"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MyAggregator; | |
use Moose; | |
extends 'Dezi::Aggregator'; | |
use Dezi::Doc; | |
sub crawl { | |
my ( $self, $inputfile ) = @_; | |
open( RF1, $inputfile ) or die "Can't open < $inputfile: $!"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
package Jieba; | |
use v5.10; | |
sub jieba_tokenize { | |
jieba_tokenize_python(shift); | |
} | |
# TODO: |