Skip to content

Instantly share code, notes, and snippets.

@rutger1140
rutger1140 / gist:a47d2aacab6cb5de68de
Created October 2, 2014 13:11
ModSecurity - block WordPress brute force hack attempts - Plesk 12
# /etc/httpd/modsecurity.d/wordpress.conf
# This has to be global, cannot exist within a directory or location clause
SecAction phase:1,log,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:1
<Location /wp-login.php>
# Setup brute force detection.
# React if block flag has been set.
SecRule user:bf_block "@gt 0" "deny,status:401,log,msg:'ip address blocked for 60 minutes, more than 15 login attempts in 3 minutes.',id:2"
<?php
//Fix homepage pagination
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} else if ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
@rutger1140
rutger1140 / gist:cfc20db7e14e2863fb99
Created July 2, 2014 09:04
jQuery validation tests
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery Validation plugin tests</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.min.css">
</head>
<body>
<form id="myform">
html {
position: relative;
min-height: 100%;
}
body {
margin: 0 0 100px; /* bottom = footer height */
}
footer {
position: absolute;
left: 0;
@rutger1140
rutger1140 / gist:691c865154736508332e
Created June 11, 2014 14:25
Debouncing scroll events
// Sample code from Paul Lewis
// Source: http://www.html5rocks.com/en/tutorials/speed/animations/
var latestKnownScrollY = 0,
ticking = false;
function onScroll() {
latestKnownScrollY = window.scrollY;
requestTick();
}
@rutger1140
rutger1140 / cm-get-totals.php
Created June 4, 2014 10:00
Campaign Monitor - get campaign recipient totals
<!doctype html>
<html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Campaign Monitor - get campaign recipient totals</title>
<meta name="viewport" content="width=device-width">
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<body>
#!/usr/bin/env bash
# Use with bash 4.0+
#==========================================================================================
# Original Script from Clemens Lang, neverpanic.de
# https://neverpanic.de/blog/2014/03/19/downloading-google-web-fonts-for-local-hosting/
# Modified by Chris Jung, campino2k.de
# * Rename Files to be compatible with Windows File System (remove spaces and colon)
# * Add "local()" to src like Google does to skip downloading if System has font installed
@rutger1140
rutger1140 / gist:9993776
Created April 5, 2014 16:05
Check for JS and SVG support and add/remove HTML classes accordingly. Snippet used in <head>
<script>
// Check for javascript support
(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement);
// Check for SVG support
(function(H){if(!!("createElementNS"in document&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect)){H.className+=" svg"}else{H.className+=" no-svg"}})(document.documentElement);
</script>
@rutger1140
rutger1140 / map.js
Last active July 21, 2017 17:54
Javascript module pattern to 'lazy load' Google Maps asynchronous, with jQuery
// global.js
// Global debug logger
var debug = true,
log = function(s){
if(debug) {
console.log(s);
}
};
@rutger1140
rutger1140 / grid.html
Last active August 29, 2015 13:57
Generate masonry grid blocks with LESS mixin
<!-- Sample HTML -->
<div class="grid">
<div class="grid__item grid-w1 grid-h1"></div>
<div class="grid__item grid-w1 grid-h2"></div>
<div class="grid__item grid-w2 grid-h2"></div>
<div class="grid__item grid-w4 grid-h3"></div>
</div>