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 / 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 / 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
@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
@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 / 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 / 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 / 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 / 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 / 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)