Skip to content

Instantly share code, notes, and snippets.

@tlehman
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save tlehman/cc9e2c32b754369ef736 to your computer and use it in GitHub Desktop.

Select an option

Save tlehman/cc9e2c32b754369ef736 to your computer and use it in GitHub Desktop.
Multnomah County Election Results Data
#!/bin/sh
curl -s https://multco.us/elections/november-2014-general-election-results | ruby -e 'STDIN.readlines.each {|line| puts line if /<pre>/ =~ line .. /<\/pre>/ =~ line }'
@tlehman

tlehman commented Nov 4, 2014

Copy link
Copy Markdown
Author

Here's how one could filter the results further and just look at some of the Measures, for example:

→ curl -s https://multco.us/elections/november-2014-general-election-results  | ruby -e 'pre=false; STDIN.readlines.each {|line| if /<pre>/ =~ line; pre=true; end; if /<\/pre>/ =~ line; pre=false; end; puts line if pre  }' | grep -A 3 -e 'Measure [89][678901]'
          State Measure 86
          Vote for  1
           Yes  .  .  .  .  .  .  .  .  .  .  .  .         0
           No.  .  .  .  .  .  .  .  .  .  .  .  .         0
--
          State Measure 87
          Vote for  1
           Yes  .  .  .  .  .  .  .  .  .  .  .  .         0
           No.  .  .  .  .  .  .  .  .  .  .  .  .         0
--
          State Measure 88
          Vote for  1
           Yes  .  .  .  .  .  .  .  .  .  .  .  .         0
           No.  .  .  .  .  .  .  .  .  .  .  .  .         0
--
          State Measure 89
          Vote for  1
           Yes  .  .  .  .  .  .  .  .  .  .  .  .         0
           No.  .  .  .  .  .  .  .  .  .  .  .  .         0
--
          State Measure 90
          Vote for  1
           Yes  .  .  .  .  .  .  .  .  .  .  .  .         0
           No.  .  .  .  .  .  .  .  .  .  .  .  .         0
--
          State Measure 91
          Vote for  1
           Yes  .  .  .  .  .  .  .  .  .  .  .  .         0
           No.  .  .  .  .  .  .  .  .  .  .  .  .         0

@tlehman

tlehman commented Nov 4, 2014

Copy link
Copy Markdown
Author

From @thorncp: https://gist.github.com/thorncp/6c9209d09ca3baa0bad6

TIL the range operator works with conditionals

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment