Skip to content

Instantly share code, notes, and snippets.

# nginx port of https://gist.github.com/netscylla/23fda41e0de8cc211ef518b6954fed8c
#
# instructions:
# save the map $http_user_agent $bad_bot {..} section as /etc/nginx/conf/map-bad-bots.conf
# save the deny as /etc/nginx/conf/deny-av.conf
# note nginx out the box has no domain name resolver. you'll need to install https://github.com/flant/nginx-http-rdns
#
# inside /etc/nginx/nginx.conf add the following to the nginx {} section.
# include conf/map-bad-bots.conf;
# inside your server location {} add the following:
@jthatch
jthatch / CountryToIso639ValueObject.php
Last active September 24, 2020 15:13
[php] Convert ISO 3166 Country Code to ISO 639-1 (all countries and languages)
<?php
declare(strict_types=1);
/**
* Class CountryToIso639ValueObject
* @author jthatch
*/
class CountryToIso639ValueObject
{
@jthatch
jthatch / dnsresolve.js
Created December 23, 2016 11:26
Scan known google proxy IP subnets to determine if said ip's are google proxys. - This is written to help us detect traffic originating from google's "data saver" mobile chrome feature
#!/usr/bin/env node
/*
* dnsresolve.js
* Will resolve ip ranges to determine if they're google proxies.
*
* TIPS for increasing speed:
* Run on multi-core system
* ulimit -n 40000
*
* Examples:
@jthatch
jthatch / stripmirc.js
Created December 13, 2016 16:27
Strip mIRC color codes and tags from log files
#!/usr/bin/env node
/*
* stripmirc.js
* strip mirc color codes from logs
*
* Examples:
*
* ./stripmirc.js irc-log.txt > irc-log-new.txt
*
* (c) jthatch http://github.com/jthatch
@jthatch
jthatch / getPics.php
Created October 17, 2016 13:28
A Laravel function to read two directories of pics, landscape and portrait, merging the pics so they fit together
<?php
/**
*
* getPics - Takes two directories of portrait and landscape pictures and merges them to create an ordered 2 column thumbnail gallery.
*
* Instead of reading from an API, it reads pics from the filesystem, caching the results in redis for self::$cache minutes
* There currently two pic sizes, "portrait" and "landscape", possibly more added in the future..
*
* It will take into account the totals of each size, and spread the smaller sizes evenly across the resulting list in sets of 2.
*
@jthatch
jthatch / convert_mp4_to_mpeg.php
Created October 10, 2016 11:28
PHP Script to convert mp4's to mpeg using ffmpeg from the command line
<?php
/**
* Created by PhpStorm.
* User: jamest
* Date: 02/11/15
* Time: 10:14
*/
class Convert {
private $commandLine, $path;