Skip to content

Instantly share code, notes, and snippets.

Avatar

Brandon Walsh walshbr

View GitHub Profile
View scrape-jitp.py
# import necessary packages for webscraping.
from dataclasses import replace
from bs4 import BeautifulSoup
from urllib import request
from dateutil.parser import parse
import time
import random
import os
import re
@walshbr
walshbr / nemla-audio.py
Created Mar 14, 2017
implements audiogrep and pydub to cut up and reassemble audio
View nemla-audio.py
# Python 2
import os
from subprocess import call
from pydub import AudioSegment
def manifest(directory, extension=None):
# gives all the file names in the directory.
for (root, _, files) in os.walk(directory):
@walshbr
walshbr / notification.py
Last active Aug 24, 2016
Send yourself a notification when a long script finishes. Requires a gmail account for line 25-6. Adaptation of http://stackoverflow.com/questions/26981591/how-to-send-myself-an-email-notification-when-a-suds-job-is-done
View notification.py
# stick in the root of your directory, then you can import it as a package to be added to the end of a long process.
# Be sure to add notification.py to your .gitignore file to prevent accidentally sharing sensitive personal information.
# =====
# In file that takes forever to run
# At top of file
import notification
# As last line before file end
notification.email_notification_on_completion()
@walshbr
walshbr / image_convert.py
Last active Aug 18, 2016
Crawls over all .png images in a directory and compresses them by converting to jpg. Deletes pngs afterwards. Ignores non .png files. Run from root of the directory you want to crawl over.
View image_convert.py
import os
from PIL import Image
def all_files(dirname):
for (root, _, files) in os.walk(dirname):
for fn in files:
yield os.path.join(root, fn)
@walshbr
walshbr / gist:5968989
Last active Dec 19, 2015
Styling to make the search bar more subtle.
View gist:5968989
#searchform{
border-radius:0px;
border-top: 1px solid #E3E3E3;
border-left: 1px solid #E3E3E3;
border-right: 1px solid #E3E3E3;
border-bottom: 1px solid #E3E3E3;
}
View Arduino Rainbow Hack
// Piezo speaker connected to pins
int speakerPin = 6;
// RGB LED leads connected to PWM pins
const int RED_LED_PIN = 9;
const int GREEN_LED_PIN = 10;
const int BLUE_LED_PIN = 11;
// Used to store the current intensity level of the individual LEDs
int redIntensity = 0;
int greenIntensity = 0;