├── README.md ├── _config.yml ├── _includes └── navigation.html ├── _layouts └── default.html ├── assets └── css │ └── style.scss ├── information.md ├── misc.md ├── process.md └── scraping.md /README.md: -------------------------------------------------------------------------------- 1 | # Favorite code snippets: A responsibly sourced, artisanal list from the Lonely Coder's Club 2 | 3 | The Lonely Coder's Club, a Slack community of newsroom programmers without big teams, would like to present our favorite, most-used code snippets. We've translated these snippets to most common coding languages and commented the heck out them so you can plug and play with ease! 4 | 5 | Contributions, edits and additions are encouraged. 6 | 7 | NICAR 2019 project presentation: [http://dhmontgomery.com/files/lccsnippets.html](http://dhmontgomery.com/files/lccsnippets.html) 8 | 9 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-hacker 2 | title: LCC Code Snippets 3 | baseurl: /code-snippets -------------------------------------------------------------------------------- /_includes/navigation.html: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /_layouts/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {% seo %} 10 | 11 | 12 | 13 | 14 |
15 |
16 |

{{ site.title | default: site.github.repository_name }}

17 |

{{ site.description | default: site.github.project_tagline }}

18 | 19 |
20 | {% if site.show_downloads %} 21 | Download as .zip 22 | Download as .tar.gz 23 | {% endif %} 24 | View on GitHub 25 | {% include navigation.html %} 26 |
27 |
28 |
29 | 30 |
31 |
32 | {{ content }} 33 |
34 |
35 | 36 | {% if site.google_analytics %} 37 | 45 | {% endif %} 46 | 47 | 48 | -------------------------------------------------------------------------------- /assets/css/style.scss: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | @import "{{ site.theme }}"; 5 | 6 | -------------------------------------------------------------------------------- /information.md: -------------------------------------------------------------------------------- 1 | # Information generating code snippets 2 | 3 | ## Get geo file metadata 4 | {% gist 4c4b410c928000e2660c82aa832377f6 %} 5 | -------------------------------------------------------------------------------- /misc.md: -------------------------------------------------------------------------------- 1 | # Miscellaneous code snippets 2 | 3 | ## Reload environment variable 4 | 5 | **Terminal** 6 | {% gist 0c2829d0080914b7916ecc72356ac4bf %} 7 | 8 | ## Python styleguide 9 | **Terminal** 10 | {% gist 9aa657485ed13c66897aa5a8381f5b50 %} 11 | 12 | ## Start local server 13 | **Terminal** 14 | {% gist 5c8a6c16c04960303d53159f7af2719c %} 15 | 16 | ## Video to Gif 17 | **Terminal** 18 | {% gist d7e16a6d85476a101762969c17220486 %} 19 | 20 | ## Start a virtual environment with python3 21 | **Terminal** 22 | {% gist 21a400d8556760c9a3652403a35f8696 %} 23 | -------------------------------------------------------------------------------- /process.md: -------------------------------------------------------------------------------- 1 | # File processing code snippets 2 | 3 | 4 | ## Combine .csv files 5 | 6 | **Python/Vanilla** 7 | {% gist f5e1a540a07de0d462d046e8796008b1 %} 8 | 9 | **Python/Pandas** 10 | {% gist 153898dcc74c7bbd593caa41243a37e5 %} 11 | 12 | **R** 13 | 14 | 15 | ## Lowercase all files in a directory 16 | 17 | **Terminal** 18 | {% gist ff10767bc42ad1bb5edef99a7462c5d8 %} 19 | 20 | **Python** 21 | {% gist 4710f8e517f760ac193901b14e21547f %} 22 | 23 | **R** 24 | {% gist 94ef12eb1c3dd1fba4e11f77409b8429 %} 25 | 26 | ## Batch rename columns from key (e.g. Census) 27 | 28 | **Python** 29 | {% gist 5d8c43f8d8b90a1ebf12781adf9d4cb9 %} 30 | 31 | **R** 32 | {% gist 526498c60fa54dcef085a8041e8d5fb5 %} 33 | 34 | ## Convert geo files 35 | 36 | **Terminal** 37 | {% gist b4071dd2106d1bde37be3274c8e6ba5b %} 38 | -------------------------------------------------------------------------------- /scraping.md: -------------------------------------------------------------------------------- 1 | # Web scraping code snippets 2 | 3 | ## Scrape webpages that operate on a delayed load 4 | 5 | **Python** 6 | {% gist f166bb58dfce5786c20b28d3b4d669d3 %} 7 | 8 | ## Download a youtube video 9 | 10 | **Terminal** 11 | {% gist 0db6f341c4b1684bfc00b0c88fa4b9d4 %} 12 | --------------------------------------------------------------------------------