Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍
Automating and/or breaking things

Anthony Bouvier thebouv

🐍
Automating and/or breaking things
View GitHub Profile
@thebouv
thebouv / findfiles.sh
Created Dec 30, 2019
find files between datetimes
View findfiles.sh
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 Dec 30, 2019
python flask gzip example
View gzip-flask.py
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', '')
View keybase.md

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 Feb 20, 2017
One line to get average mem used by running apache processes, great for estimating MaxClients
View apachememavg.sh
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
View rackspace.apache.loadbalance.conf
LogFormat "%{X-Cluster-Client-IP}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
SetEnvIf X-Cluster-Client-IP "^.*\..*\..*\..*" forwarded
CustomLog "logs/access_log" combined env=!forwarded
CustomLog "logs/access_log" proxy env=forwarded
# http://fishnix.tumblr.com/post/18037951487/x-forwarded-for-in-rackspace-cloud-load-balancers
@thebouv
thebouv / .sh
Created Jun 24, 2016
gitshellstuff.sh
View .sh
export PS1="\[\e[00;36m\]thebouv\[\e[0m\]\[\e[00;37m\]@nurgle:\[\e[0m\]\[\e[00;33m\][\W]\[\e[0m\]\[\e[00;36m\]\$(parse_git_branch):\[\e[0m\]\[\e[00;37m\] \[\e[0m\]"
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
# git branch in prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
View gitgraph.sh
git --no-pager log --all -n 15 --graph --abbrev-commit --decorate --format=tformat:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an <%ce>%C(reset)'
View disablescrollling.js
// 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 / solradvice
Created May 28, 2015
Solr Statement
View solradvice
<@elyograg> remember this sentence: collections are made up of shards. shards are made up of replicas. each replica is a core.
@thebouv
thebouv / replace.pl
Created Feb 19, 2015
Perl one-liner to regex replace string stuff on file(s)
View replace.pl
perl -pi -e 's/you/me/g' file
# works with *html or any extension to do all in current directory
You can’t perform that action at this time.