Skip to content

Instantly share code, notes, and snippets.

View dsiddy's full-sized avatar

Dan Siddoway dsiddy

  • Spokane, WA
View GitHub Profile
@dsiddy
dsiddy / UTA Free Fare Zone.kml
Last active August 29, 2015 13:56
a KML file encapsulating the UTA's Free Fare Zone in Salt Lake City, UT
<!-- (Inspired by <http://legacy.rideuta.com/ridingUTA/payingFare/freeFareZone.aspx>.) -->
<?xml version="1.0" encoding="UTF-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>UTA Free Fare Zone</name>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-111.88509,40.75826 <!-- 200 E. & 500 S. -->
@dsiddy
dsiddy / setEC2Permissions.sh
Last active August 29, 2015 14:03
set Amazon EC2 Web server permissions
#!/bin/bash
# @see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html
#sudo groupadd www
#sudo usermod -a -G www ec2-user
sudo chown -R root:www /var/www
sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} +
find /var/www -type f -exec sudo chmod 0664 {} +
say "Fitter." using "Fred"
say "Happier." using "Fred"
say "More productive." using "Fred"
say "Comfortable." using "Fred"
say "Not drinking too much." using "Fred"
@dsiddy
dsiddy / CracklePop.py
Last active September 2, 2015 17:12
CracklePop
# @see https://www.recurse.com/apply
# My off-the-cuff solution. Sub-optimal, in all likelihood. I would prefer to test divisibility using base-10-digit-based tricks, but that'd make the code less readable.
def CracklePop(start, end):
for n in range(start, end + 1): # Mind the fencepost.
divisibleBy3 = divisibleBy(n, 3)
divisibleBy5 = divisibleBy(n, 5)
if divisibleBy3 and divisibleBy5:
@dsiddy
dsiddy / listServices.sh
Last active September 2, 2015 17:12
listServices.sh
#!/bin/bash
# @see https://github.com/drduh/OS-X-Yosemite-Security-and-Privacy-Guide#services
# @todo Design a better RE. Also, extract the file name from the full path.
regex="\"Program\" = \"([^\"]+)\""
for x in `launchctl list | awk '{ if (NR > 1) { print $3 } }' | sort`
do
[[ `launchctl list ${x}` =~ ${regex} ]]
echo ${BASH_REMATCH[1]} # @see `man bash`
@dsiddy
dsiddy / fuzzer.sh
Last active September 2, 2015 17:13
fuzzer.sh
#!/bin/bash
# @see http://dx.doi.org/10.1145/2560217.2560219
# @see http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-857-network-and-computer-security-spring-2014/lecture-notes-and-readings/
program=/usr/bin/acpi-listen
path=/dev/null # @todo Specify a valid 6676-byte filename.
for letter in {a..z} {A..Z}
do
# Note that `gtimeout` is the Homebrew-installed version of `timeout`, a GNU core utility.
@dsiddy
dsiddy / StripeKey.rb
Last active September 2, 2015 17:13
StripeKey.rb
# @see http://stackoverflow.com/a/18986500
require 'securerandom'
def StripeKey()
prefix = 'sk_live_'
# @see http://ruby-doc.org/stdlib-1.9.3/libdoc/securerandom/rdoc/SecureRandom.html#method-c-urlsafe_base64
key = SecureRandom.urlsafe_base64(24)
# Keep generating keys until a hyphen- and underscore-free one is found.
@dsiddy
dsiddy / secureDreamHost.sh
Created December 4, 2015 19:56
secure DreamHost directories
#!/bin/bash
# Secure the contents of the given directory recursively.
# @see http://wiki.dreamhost.com/Security#Setting_file_permissions
if [ -d $1 ]; then
find $1 -type f ! -perm +a=x -exec chmod 644 {} +
find $1 -type d -exec chmod 755 {} +
find $1 -type f -perm +a=x -exec chmod 755 {} +
else
echo $0: Argument must be a directory.
fi
@dsiddy
dsiddy / .htaccess
Created December 8, 2015 18:05
redirect HTTP to HTTPS
# @see https://wiki.apache.org/httpd/RewriteHTTPToHTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
@dsiddy
dsiddy / update.sh
Last active December 8, 2015 20:58
update package manager files
#!/bin/bash
for file in {package,bower}.json
do
if [ -f ${file} ]; then
# Warning: this command edits the files in-place.
sed -i '' -e 's|(http://\(.*\))|(https://\1)|' ${file}
fi
done