Skip to content

Instantly share code, notes, and snippets.

View thebouv's full-sized avatar
🐍
Automating and/or breaking things

Anthony Bouvier thebouv

🐍
Automating and/or breaking things
View GitHub Profile
@thebouv
thebouv / ducks.sh
Last active April 1, 2024 18:11
ducks: linux command for the 10 largest files in current directory
du -cks * | sort -rn | head -11
# Usually set this up in my bash profile as an alias:
# alias ducks='du -cks * | sort -rn | head -11'
# Because it is fun to type ducks on the command line. :)
@thebouv
thebouv / infowindowclick.js
Last active May 14, 2021 05:16
Add event listener to item in a Google Maps API InfoWindow
google.maps.event.addListener(infowindow, 'domready', function() {
$(".schedulelunch").click(function(e) {
setCommunitySelected(e.currentTarget.dataset.communitynumber);
});
});
@thebouv
thebouv / blank_pelican_theme.sh
Created April 12, 2021 20:14
creates the mandatory folders and files for a blank theme for pelican
# creates the mandatory folders and files for a blank theme for pelican
# to be run in your newly minted theme repo
mkdir -p static/css static/images templates
touch templates/{archives,period_archives,article,author,authors,categories,category,index,page,tag,tags}.html
@thebouv
thebouv / findfiles.sh
Created December 30, 2019 22:33
find files between datetimes
find -newermt "2019-12-30 15:15:00" ! -newermt "2019-12-30 16:26:00"
# and say you want to then send those files somewhere else like via cp?
find -newermt "2019-12-30 15:15:00" ! -newermt "2019-12-30 16:26:00" | xargs cp -t /path/to/destinationfolder
@thebouv
thebouv / gzip-flask.py
Created December 30, 2019 00:40
python flask gzip example
import gzip, functools
from io import BytesIO as IO
from flask import after_this_request, request
def gzipped(f):
@functools.wraps(f)
def view_func(*args, **kwargs):
@after_this_request
def zipper(response):
accept_encoding = request.headers.get('Accept-Encoding', '')
@thebouv
thebouv / disablescrollling.js
Created February 28, 2016 16:47
Disable scrolling
// as seen here: http://stackoverflow.com/questions/4770025/how-to-disable-scrolling-temporarily
// left: 37, up: 38, right: 39, down: 40,
// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
var keys = {37: 1, 38: 1, 39: 1, 40: 1};
function preventDefault(e) {
e = e || window.event;
if (e.preventDefault)
@thebouv
thebouv / highlight.js
Last active June 11, 2018 15:17
Highlight active menu item in bootstrap nav (that is just a link and not a pill or tab)
// highlight active menu item
var url = window.location;
$('ul.nav a').filter(function() {
return this.href == url;
}).parent().addClass('active');
// alternative for use with specific parameter checking
var url = window.location;
$('ul.nav a').filter(function() {
locationLink = getURLParameter('calID',url);
@thebouv
thebouv / fixwifishare.sh
Created October 8, 2014 18:11
fix wifi sharing on mac
sudo lsof -i udp:67 | grep bootpd |awk '{ print $2 }'| while read pid; do echo killing $pid; sudo kill -9 $pid&&echo "successfull..."; done

Keybase proof

I hereby claim:

  • I am thebouv on github.
  • I am thebouv (https://keybase.io/thebouv) on keybase.
  • I have a public key whose fingerprint is B7B1 E67D A27A 1F47 56EB 4732 2226 E190 8D28 A58E

To claim this, I am signing this object:

@thebouv
thebouv / apachememavg.sh
Created February 20, 2017 14:20
One line to get average mem used by running apache processes, great for estimating MaxClients
ps -ylC httpd --sort:rss | awk '{sum+=$8; ++n} END {print "Tot="sum"("n")";print "Avg="sum"/"n"="sum/n/1024"MB"}'
# above is a one liner, not really a script
# MaxClients = 80% of max memory on system / average mem from one-liner above