Skip to content

Instantly share code, notes, and snippets.

@whuhacker
whuhacker / index.js
Created Apr 18, 2019
botDetection in Lambda@Edge
View index.js
const isBot = require('isbot');
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
const headers = request.headers;
const userAgentString = headers['User-Agent'] && headers['User-Agent'][0] ? headers['User-Agent'][0] : null;
const isCrawler = isBot(userAgentString);
if ( isCrawler ) {
headers['CloudFront-Is-Crawler-Viewer'] = ['true'];
View firewall.sh
#! /bin/bash
# Set the default policies to allow everything while we set up new rules.
# Prevents cutting yourself off when running from remote SSH.
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# Flush any existing rules, leaving just the defaults
iptables -F
@whuhacker
whuhacker / chosen.css
Created Nov 22, 2012
chosen style for twitter bootstrap
View chosen.css
.chosen {
width: 220px;
}
.chosen-mini {
width: 70px;
}
.chosen-small {
width: 100px;
}
.chosen-medium {