Navigation Menu

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
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 June 24, 2016 16:03
gitshellstuff.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)/'
}
@thebouv
thebouv / gitgraph.sh
Created May 11, 2016 20:14
git graph
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)'
@thebouv
thebouv / conncount.sh
Last active January 4, 2016 20:09
conncount: linux command listing current IPs connected and how many connections
# Very handy one-liner from DDoS Deflate project. Useful just by itself.
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
# As an alias:
# alias conncount='netstat -ntu | awk '\''{print $5}'\'' | cut -d: -f1 | sort | uniq -c | sort -nr'
@thebouv
thebouv / solradvice
Created May 28, 2015 19:50
Solr Statement
<@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 February 19, 2015 15:49
Perl one-liner to regex replace string stuff on file(s)
perl -pi -e 's/you/me/g' file
# works with *html or any extension to do all in current directory
@thebouv
thebouv / changeperm.sh
Created February 19, 2015 15:40
Recursive find and change permissions
find . -type d -perm 777 -exec chmod 755 {} \; # (for changing the directory permission)
find . -type f -perm 777 -exec chmod 644 {} \; # (for changing the file permission)
# If they did not have 777 permissions, we easily remove the -perm 777 part.
# sourced from: http://serverfault.com/a/363428
@thebouv
thebouv / bounds.js
Last active August 29, 2015 14:14
Force google map to zoom so all markers show
// gMarkers is your array of markers
var bounds = new google.maps.LatLngBounds();
for(i=0;i<gMarkers.length;i++) {
bounds.extend(gMarkers[i].getPosition());
}
map.fitBounds(bounds);
@thebouv
thebouv / fail2ban-cmds.sh
Created January 25, 2015 18:39
fail2ban-client
fail2ban-client status
fail2ban-client set ssh-iptables unbanip x.x.x.x
@thebouv
thebouv / parse.js
Last active August 29, 2015 14:13
Parsing XML with namespace (such as slash:comments)
el[0].getElementsByTagNameNS('http://purl.org/rss/1.0/modules/slash/', 'comments')[0].innerHTML;
// or a fuller example
$.get('/blogfeed.php', function (data) {
var count = 1;
$(data).find("item").each(function () {
var el = $(this);
// ...
// how many comments