Skip to content

Instantly share code, notes, and snippets.

View zstumgoren's full-sized avatar

Serdar Tumgoren zstumgoren

View GitHub Profile
@zstumgoren
zstumgoren / senate-compromisers.py
Last active February 11, 2023 21:02 — forked from zhongleqi/leqi_assignment5_draft1.py
updated with feedback
"""
*** SERDAR's NOTES ****
This is a good start. There are a few minor issues that I've noted in the code towards the top of the file,
specifically in the "main" and "group_members_by_party" functions. Please read the notes I added to the top half of the
file and try to fix the code before moving on to the sorting and printing steps.
Let me know if you have any questions.
@zstumgoren
zstumgoren / ca_failed_banks.sh
Last active January 31, 2022 00:50 — forked from irenecasado/ca_failed_banks.sh
ca_failed_banks.sh
# No need for creating new directories with this script. Note, if you were to use "mkdir-p" it requires a path to a directory
# as its argument. For example, "mkdir -p ~/code/example"
# mkdir -p
# cd code
curl -s --output banklist.csv https://www.fdic.gov/resources/resolutions/bank-failures/failed-bank-list/banklist.csv
# No need to touch the file
# touch ca_failed_banks.csv
# Instead, create it using head
head -1 banklist.csv > ca_failed_banks.csv
# You should delete extraneous commands not needed by the script such as below "cat" statement
@zstumgoren
zstumgoren / county_fips_annotated.json
Last active October 22, 2020 02:29
Counties that have one or more sites available on Agenda Watch
{
"01001": 0,
"01003": 1,
"01005": 0,
"01007": 0,
"01009": 0,
"01011": 0,
"01013": 0,
"01015": 0,
"01017": 0,
{
"Items": [
{
"site_type": {
"S": "municipality"
},
"country": {
"S": "United States"
},
"endpoint": {
@zstumgoren
zstumgoren / failed_banks_count.py
Created January 23, 2019 22:24
Partial script.
import csv
import os
import urllib.request
url = 'https://www.fdic.gov/bank/individual/failed/banklist.csv'
source_file = os.path.expanduser('~/Desktop/failed_banks.csv')
urllib.request.urlretrieve(url, source_file)
with open(source_file, 'r', encoding="latin-1") as failed_banks:
@zstumgoren
zstumgoren / gist:3a63d0183ae05e27a5ef15dd82ba6bf5
Last active July 28, 2017 21:17
bundler error when installing Fech from source
### Gemfile ###
cd ~/test
less Gemfile
source 'https://rubygems.org'
gem 'fech', git: 'https://github.com/NYTimes/Fech.git', :tag => 'v1.8', :submodules => true
#### CLI output ####
# Below run by a user with no ssh keys
~/test$ bundle
@zstumgoren
zstumgoren / election_results_py3.py
Created March 1, 2017 01:25
Python3 port of election_results.py for NICAR17 PyHumans bootcamp
"""
A monstrosity of an election results script. Calculates total votes for
races and candidates, and determines if there is a winner in each race.
This module bundles together way too much functionality and is near impossible
to test, beyond eye-balling results.
USAGE:
python election_results.py
@zstumgoren
zstumgoren / Python_intermediate_notes.md
Last active August 14, 2017 13:27
Python Intermediate (Code Design)
@zstumgoren
zstumgoren / election_results.py
Last active March 1, 2016 21:34
Elec results script for shredding at NICAR
import csv, urllib
from operator import itemgetter
from collections import defaultdict
from os.path import dirname, join
url = "https://docs.google.com/spreadsheet/pub?key=0AhhC0IWaObRqdGFkUW1kUmp2ZlZjUjdTYV9lNFJ5RHc&output=csv"
filename = join(dirname(dirname(__file__)), 'fake_va_elec_results.csv')
urllib.urlretrieve(url, filename)
reader = csv.DictReader(open(filename, 'rb'))
@zstumgoren
zstumgoren / gist:e1a27c55f77d51c7ff10
Created November 3, 2015 16:43
r10k git errors
~/code/ruby/ap/devops/vmfarm/puppet/private> cd projects/
~/code/ruby/ap/devops/vmfarm/puppet/private/projects> pwd
/Users/stumgoren/code/ruby/ap/devops/vmfarm/puppet/private/projects
~/code/ruby/ap/devops/vmfarm/puppet/private/projects> git branch -a
error: object directory /root/.r10k/git/https---git.ap.org-puppet-puppet-projects.git/objects does not exist; check .git/objects/info/alternates.
master
remotes/cache/master
remotes/origin/HEAD -> origin/master
remotes/origin/master
~/code/ruby/ap/devops/vmfarm/puppet/private/projects> git remote show