Skip to content

Instantly share code, notes, and snippets.

View ndunn219's full-sized avatar

Nat Dunn ndunn219

View GitHub Profile
@ndunn219
ndunn219 / .gitignore
Last active April 25, 2021 13:03
Webucator VS Code Courseware Settings
.DS_Store
@ndunn219
ndunn219 / cloudSettings
Last active December 24, 2020 09:25
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-12-24T09:25:39.702Z","extensionVersion":"v3.4.3"}
@ndunn219
ndunn219 / combo_lock.py
Created October 5, 2019 23:08
How to pick a combo lock.
# based on https://youtu.be/w4wkCcsWs4c
def guess_numbers(num1, num2):
nums = [num1, num1+10, num1+20, num1+30,
num2, num2+10, num2+20, num2+30]
return nums
def main():
print('''The first step is to find the "Sticky number"
by applying pressure to the shackle and turning clockwise
@ndunn219
ndunn219 / srt_to_txt.py
Last active October 2, 2024 09:48
Simple Python Script for Extracting Text from an SRT File
"""
Creates readable text file from SRT file.
"""
import re, sys
def is_time_stamp(l):
if l[:2].isnumeric() and l[2] == ':':
return True
return False
import os, re
dir = 'path-to-your-directory'
i=0
results = [] #Store changed files so you can look into it later
for dirname, dirnames, filenames in os.walk(dir):
for filename in filenames:
ext = filename.split('.')[-1] #Get Extension
if ext in ('cfc','cfm'): #Limit search to specific file types
from bs4 import BeautifulSoup
import requests
import pandas as pd
url = "https://www.akc.org/reg/dogreg_stats.cfm"
r = requests.get(url)
data = r.text
soup = BeautifulSoup(data, "lxml")
@ndunn219
ndunn219 / sitemap_checker.py
Last active November 19, 2022 17:18
This code shows how to check a sitemap to make sure there are no links pointing to missing pages and to see if 301s are working correctly. It is explained at https://www.webucator.com/blog/2016/05/checking-your-sitemap-for-broken-links-with-python/
import requests
from bs4 import BeautifulSoup
sitemap = 'http://www.nasa.gov/sitemap/sitemap_nasa.html'
r = requests.get(sitemap)
html = r.content
soup = BeautifulSoup(html, 'html.parser')
links = soup.find_all('a')
@ndunn219
ndunn219 / StackExchange PY2 v. PY3.ipynb
Created March 10, 2016 16:10
IPython Notebook creating plots showing trend in StackExchange posts tagged Python 2 and Python 3
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ndunn219
ndunn219 / adventure.py
Created February 3, 2016 17:46
This script was created as part of a series of training videos based on Python projects created by Shelly Tan of Northwestern University's Knight Lab. The video explaining the code is at https://youtu.be/8uJFN7OZ2Yo
import random
def msg(room):
if room['msg'] == '': #There is no custom message
return "You have entered the " + room['name'] + '.'
else:
return room['msg']
def get_choice(room,dir):
if dir=='N':
@ndunn219
ndunn219 / FixMarkDownHeaders.ipynb
Last active November 6, 2015 15:08
Adds a space after series of hash marks at the beginning of lines. The purpose is to fix markdown headers that didn't include a space after heading hash marks. USE AT YOUR OWN RISK.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.