Skip to content

Instantly share code, notes, and snippets.

View brendannee's full-sized avatar

Brendan Nee brendannee

View GitHub Profile
@brendannee
brendannee / download.sh
Created August 28, 2021 06:15
Download a list of webpages as pdfs and use the last part of the path as the filename
while read p; do
DOWNLOADURL=$(echo $p | grep / | cut -d/ -f5 | awk '{print $1".pdf"}')
chrome --headless --print-to-pdf=$DOWNLOADURL $p; sleep 5
done <list.txt
<div class="row">
<div class="col-md-3">
<h2>Fares &amp; Passes</h2>
<div class="menu-fares-and-passes-container"><ul id="fares-menu" class="menu">
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-72"><a href="https://ccctadev.wpengine.com/fares/where-to-buy/">Where to Buy</a></li>
<li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-73"><a href="https://store.countyconnection.com">Purchase Online</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-71"><a href="https://ccctadev.wpengine.com/fares/rtc-discount-card-program/">RTC Discount Card Program</a></li>
</ul></div>
</div>
<div class="col-md-3">

Keybase proof

I hereby claim:

  • I am brendannee on github.
  • I am brendannee (https://keybase.io/brendannee) on keybase.
  • I have a public key whose fingerprint is C56D B712 8DA8 6351 9DD6 C633 F80D 2DED 1716 5FDB

To claim this, I am signing this object:

@brendannee
brendannee / gist:c4a28e02589d38db4ad9
Created December 14, 2014 22:42
Upgrade a specific Wordpress user's permissions
//to add capability to user
//Add to functions.php
//List of capabilities: http://codex.wordpress.org/Roles_and_Capabilities
$user = new WP_User( $user_id );
$user->add_cap( 'edit_pages');
$user->add_cap( 'edit_published_pages' );
@brendannee
brendannee / gist:8292378
Created January 7, 2014 00:05
Dump a mongo collection, or part of a collection from a remote server and import locally
mongodump -u <USERNAME> -p<PASSWORD> --host <HOSTNAME>:<PORT> --collection <COLLECTION_NAME> -db <REMOTE_DATABASE_NAME> -o ~/Downloads
mongorestore --collection <COLLECTION_NAME> --drop -db <LOCAL_DATABASE_NAME> ~/Downloads/<PATH TO BSON FILE>
# http://stackoverflow.com/questions/7828817/is-it-possible-to-mongodump-the-last-x-records-from-a-collection/18679197#18679197
@brendannee
brendannee / gist:7196251
Created October 28, 2013 12:48
Whitelist a Wordpress custom post type for use with the Jetpack JSON API using the `rest_api_allowed_post_types` filter. See http://developer.wordpress.com/docs/api/1/get/sites/%24site/posts/
function allow_my_post_types($allowed_post_types) {
$allowed_post_types[] = 'my_post_type';
return $allowed_post_types;
}
add_filter( 'rest_api_allowed_post_types', 'allow_my_post_types');
#!/bin/sh
# script for optimizing images in a directory (recursive)
# pngcrush & jpegtran settings from:
# http://developer.yahoo.com/performance/rules.html#opt_images
# pngcrush
find . -iname "*.png" | while read png
do
echo "crushing $png ..."
@brendannee
brendannee / gist:6668143
Created September 23, 2013 09:03
Optimize jpg files in a directory (overwrite)
find . -name "*.jpg" -exec jpegtran -optimize -copy none -outfile {} {} \;
@brendannee
brendannee / gist:5408771
Created April 17, 2013 23:58
.htaccess remove www. from domain
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.mysite.com [NC]
RewriteRule ^(.*)$ http://mysite.com/$1 [L,R=301]
@brendannee
brendannee / gist:5400591
Last active April 21, 2022 08:56
Restart chromium via SSH
# stop chromium
sudo killall chromium
# manually set the display to one that is currently being used
# start chromium in kiosk mode with the URL we want to load
# use nohup so it stays up after we disconnect
DISPLAY=:0 nohup chromium --kiosk --incognito bart.blinktag.com/?station=16TH &