Skip to content

Instantly share code, notes, and snippets.

@andybeak
andybeak / cli-config.php
Created June 3, 2015 12:56
Client config for Doctrine
<?php
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
$paths = ['/home/andy/development/metagrated/poc/restengine/app/Lib/Domain/Mappings'];
require_once __DIR__.'/../../../../bootstrap/autoload.php';
$paths = [ __DIR__ ];
@andybeak
andybeak / LoggingMiddleware.php
Last active August 29, 2015 14:26
Laravel request logging middleware
<?php namespace App\Http\Middleware;
use Auth;
use Closure;
use Config;
use Log;
class LoggingMiddleware {
/**
@andybeak
andybeak / delete_all_local_and_remote_tags.sh
Last active September 9, 2015 13:11
Delete all tags on local and remote repository (be careful)
# See http://blog.siyelo.com/how-to-bulk-delete-remote-git-tags/
# delete local
git tag -l | awk '/^(.*)$/ {print $1}' | xargs git tag -d
# delete remote
git ls-remote --tags origin | awk '/^(.*)(\s+)(.*)$/ {print ":" $2}' | xargs git push origin
@andybeak
andybeak / nginx-tls1.conf
Last active November 4, 2015 12:29
Nginx SSL settings for TLS 1.0
# This config allows backwards compatibility for insecure TLS 1.0 protocols for Microsoft Browsers
# see https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
# General SSL settings
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
@andybeak
andybeak / iptables.sh
Created November 6, 2015 12:42
Block connections to MySQL
# allow the one IP address and localhost connections, disallow all else
iptables -A INPUT -i lo -p tcp --dport mysql -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport mysql -s 123.123.123.123 -j ACCEPT
iptables -A INPUT -p tcp --dport mysql -j DROP
# Use this on Debian to help persist over boot
# apt-get install iptables-persistent
@andybeak
andybeak / wordpress_update.sql
Created May 5, 2015 15:02
Update Wordpress posts when moving domains (e.g.: deploying)
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.olddomain.com', 'http://www.newdomain.com') WHERE instr(meta_value, 'http://www.olddomain.com') > 0;
UPDATE wp_posts SET guid = replace(guid, 'http://www.olddomain.com', 'http://www.newdomain.com') WHERE instr(guid, 'http://www.olddomain.com') > 0;
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.olddomain.com', 'http://www.newdomain.com') WHERE instr(post_content, 'http://www.olddomain.com') > 0;
@andybeak
andybeak / page.html
Last active November 18, 2015 14:50
Open url (same domain) in modal
<div>
Click <a href="/upload" class="modal-link" title="Upload your file">here</a> to upload an document.
</div>
<div id="dialog"></div>
@andybeak
andybeak / db_backup.sh
Created December 16, 2015 12:29
Backup all databases on a host
#!/bin/bash
# outputs all databases in the live database to gzipped sql dumps
# removes all the dumps that are older than 8 hours
# restore the dump with gunzip < outputfile.sql.gz | mysql < mysql options>
USER="myuser"
PASSWORD="password"
HOST="database.server"
OUTPUT="/home/ubuntu/database_backups/backups"
@andybeak
andybeak / PurlGurl.php
Last active January 25, 2016 12:59
Laravel 5.2 - Using route parameters in middleware
<?php namespace App\Lib\Purlgurl;
/**
* Class Purlgurl
*
* This class provides the purlgurl functionality - tracking visitors, and obtaining the responder from the request
*
*/
use App;
@andybeak
andybeak / nginx_laravel.conf
Last active March 17, 2016 12:33
Laravel Nginx config
# Read
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart#
# http://tautt.com/best-nginx-configuration-for-security/
#
# Generate your key with: openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
# Generate certificate: sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
server_tokens off;