Skip to content

Instantly share code, notes, and snippets.

View cstrouse's full-sized avatar
💭
Bug Bounty

Casey Strouse cstrouse

💭
Bug Bounty
View GitHub Profile
@cstrouse
cstrouse / gist:2033271
Created March 14, 2012 01:38
Scrape beeradvocate with Python, Requests, and BS
import requests
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(requests.get("http://beeradvocate.com/search?q=ipa&qt=beer").content)
# Find the beer links
results = soup.findAll('div')
# How many beers did it find
beer_count = results[12].find('b').string.split(' ')[1]
@cstrouse
cstrouse / image-resizer.sh
Created October 22, 2012 19:14
Resizes images so that the shortest side is 250px
#!/bin/bash
# change this to the path where you have the images stored
src_path='/Users/tzayad/Pictures/test'; cd $src_path
# change this to the length you want for the smallest side
t_size=250;
# for each image of the type jpeg/jpg/gif/png loop through and resize
for img in `find . -iname \*.jpeg -o -iname \*.jpg -o -iname \*.png -o -iname \*.gif`; do
@cstrouse
cstrouse / image-resizer.scpt
Created October 25, 2012 16:11
Resizes images so that the shortest side is 250px. Wrote this before the bash version but Finder crashed with the volume of images that had to be processed.
with timeout of (30 * 60) seconds
tell application "Finder"
set input_images to every document file of folder "Users:tzayad:Pictures:test" of startup disk whose name extension is "jpg" or name extension is "png"
end tell
tell application "Image Events"
launch
repeat with a from 1 to length of input_images
try
@cstrouse
cstrouse / gist:4520209
Created January 12, 2013 19:55
Wordpress shortcode to grab all archived newsletters from a Constant Contact archive page and output as a table. To use add the require statement and the shortcode function to your theme's functions.php, upload the simple_html_dom.php file to the theme directory (you can get it from sf.net) and then replace the Constant Contact archive link with…
<?php require('simple_html_dom.php');
function generate_newsletter_archives($atts, $content = null) {
// setup the beginning of our data table for archives
$out = '<table cellpadding="0" cellspacing="0" id="newsletter-archives"><tr><th>Resource</th><th>Date</th></tr><tbody>';
// fetch the page which contains all of the newsletter issues that have been archived
$archive_page = str_get_html(wp_remote_retrieve_body(wp_remote_get('http://archive.constantcontact.com/fs127/1103640951068/archive/1111407854121.html')));
@cstrouse
cstrouse / kindle-highlight-extractor.py
Created April 7, 2013 07:11
Work in progress tool for extracting highlights from Kindle ebooks.
import binascii
import re
# highlights are stored in *.mbp files corresponding to the filename of the book
# in ~/Library/Application Support/Kindle/My Kindle Content/
# EA 44 41 54 41 - beginning of highlight
# 44 41 54 41 - end of highlight (except last highlight which *sometimes* ends with 42 4B 4D 4B)
fh = '0131177052.WrkngEffLegCode.mbp'
@cstrouse
cstrouse / vortex0.go
Last active December 30, 2015 23:39
OverTheWire Vortex Level 0 Go solution
package main
import (
"bytes"
"encoding/binary"
"fmt"
"net"
)
func main() {
@cstrouse
cstrouse / ks.cfg
Created August 31, 2014 18:07
A minimal kickstart file for CentOS 7 for use with Packer. Most other supposed CentOS 7 kickstart files wouldn't work for me.
install
repo --name=base --baseurl=http://mirror.cogentco.com/pub/linux/centos/7/os/x86_64/
url --url="http://mirror.cogentco.com/pub/linux/centos/7/os/x86_64/"
lang en_US.UTF-8
keyboard us
timezone America/Phoenix
cdrom
<?php
// fetches a file and returns an XML document
$xml = simplexml_load_file("http://search.cdsonline.com.au/offsite/xmlStock.asp?dlr=wesmotperf");
// loads the XML into the DOM
$dom1 = new DomDocument();
$dom1->loadXML($xml->asXML());
// Sets up an object so we can use xpath to query for nodes of the XML document
@cstrouse
cstrouse / fda_ia.py
Last active December 17, 2016 23:04
fda advisory item scraper
import requests
import re
import jinja2
import shutil
import os
from bs4 import BeautifulSoup
BASE_URL = "http://www.accessdata.fda.gov/cms_ia/"
OUTPUT_DIR = "build"
function change_graphic_lib($array) {
return array('WP_Image_Editor_GD', 'WP_Image_Editor_Imagick');
}
add_filter('wp_image_editors', 'change_graphic_lib');