Skip to content

Instantly share code, notes, and snippets.

View fliphess's full-sized avatar

Flip Hess fliphess

View GitHub Profile
@fliphess
fliphess / log_analyzer.php
Created February 22, 2016 03:06
GoAccess Log analyzer php wrapper
<?php
header('Pragma: no-cache');
header('Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate, proxy-revalidate');
$command = 'nice -n 10 zcat -f "%s" | nice -n 10 /usr/bin/goaccess --real-os --std-geoip --http-protocol --http-method --no-progress -a 2>&1';
$domain = $_SERVER["SERVER_NAME"];
$url = $_SERVER["SCRIPT_NAME"];
$log_files = array_filter(glob(sprintf('/var/log/apache2/%s-access.log*', $domain)), 'is_file');
@fliphess
fliphess / nginx-config.conf
Created March 11, 2016 09:29
magento with fishpig wordpress multisite nginx config
location /wp {
root /data/web/public;
index index.php ;
location ~ \.php$ {
echo_exec @phpfpm;
}
}
rewrite ^.*/files/(.*)$ /wp/wp-includes/ms-files.php?file=$1 last;
if (!-e $request_filename) {
@fliphess
fliphess / scp-wrapper.pl
Created April 7, 2016 07:23
Perl wrapper around scp to provide secure scp transfers to a specified location
#!/usr/bin/perl
use strict;
use warnings;
# This is a scp wrapper which allows to scp data into 1 specific and restricted file
# Example usage:
# command="/usr/sbin/scp-wrapper /etc/hosts $SSH_ORIGINAL_COMMAND" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAmkHG1WCjC...
#
@fliphess
fliphess / send2slack.py
Created May 20, 2016 13:14
Little python doodle to send messages to slack incoming webhooks
class SlackWebHook(object):
def __init__(self, url):
self.url = url
self.opener = build_opener(HTTPHandler())
def __post(self, payload):
payload_json = json.dumps(payload)
data = urlencode({"payload": payload_json})
req = Request(self.url)
@fliphess
fliphess / migrate-wordpress.sh
Last active October 31, 2022 20:42
Wordpress migrator script
#!/bin/bash
set -e
function die() { echo "$1"; exit 1; }
function action() {
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo "@@@ $(date)"
echo "@@@ $1"
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
@fliphess
fliphess / wordpress.md
Last active December 15, 2016 09:25
wordpress in a subdirectory on a hypernode.

Add to your wp-config.php:

$host = 'http://' . $_SERVER['HTTP_HOST'] . '/blog/';
define('WP_HOME',$host);
define('WP_SITEURL',$host);

Next create a server.blog in /data/web/nginx:

@fliphess
fliphess / sitemap-cache-warmer.sh
Last active July 19, 2016 13:28
sitemap-cache-warmer
#!/bin/bash
if [ "$#" -ne 1 ] || [ "x$1" == "x" ] ; then
echo "Usage: $0 <sitemap.xml>"
exit 0;
fi
if [ ! -f "$1" ]; then
echo "Sitemap file $1 not found! Exit!"
exit 1
@fliphess
fliphess / addblock.sh
Created June 14, 2016 13:21
bind addblock zones
curl -qs http://someonewhocares.org/hosts/ | grep -vE '^#' | grep ^127 | grep -v local | awk '{print $2}' | while read line; do echo "zone \"$line\" { type master; file "/etc/bind/db.empty"; };"; done >> named.conf.fake-zones
@fliphess
fliphess / serial-cache-warmer.sh
Created July 26, 2016 09:40
serial cache warmer
#!/bin/bash
if [ "$#" -ne 1 ] || [ "x$1" == "x" ] ; then
echo "Usage: $0 <sitemap.xml>"
exit 0;
fi
if [ ! -f "$1" ]; then
echo "Sitemap file $1 not found! Exit!"
exit 1
@fliphess
fliphess / change-wp-urlconfig.sh
Last active August 22, 2016 15:21
Change url config in wordpress after migrating to a new domain
#!/bin/bash
DOMAIN="$1"
OLD_DOMAIN="$2"
if [ "x$DOMAIN" == "x" ] || [ "x$OLD_DOMAIN" == "x" ] ; then
echo "Usage: $0 <new_domain> <old_domain> (no scheme://)"
exit 1
fi
mysql -Be "UPDATE wp_posts SET guid = REPLACE(guid, 'http://$OLD_DOMAIN/', 'http://$DOMAIN/')"