Skip to content

Instantly share code, notes, and snippets.

@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 / 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-badbots.conf
Created January 28, 2016 09:03
Fail2Ban badbots filter - edited from Debian apache badbots
# Fail2Ban configuration file
#
# Regexp to catch known spambots and software alike. Please verify
# that it is your intent to block IPs which were driven by
# above mentioned bots.
[Definition]
badbotscustom = EmailCollector|WebEMailExtrac|TrackBack/1\.02|sogou music spider|Baiduspider
@andybeak
andybeak / fizzbuzz.exs
Created April 11, 2016 09:05
Fizzbuzz with no conditional logic
fizz = fn
  {0, 0, _} -> "FizzBuzz"
  {0, _, _} -> "Fizz"
  {_, 0, _} -> "Buzz"
  {_, _, a} -> "#{a}"
end
foo = fn (n) -> "#{IO.puts(fizz.({rem(n,3), rem(n,5), n}))}" end
for i <- 1..100 do
@andybeak
andybeak / Kernel.php
Created May 11, 2016 08:35
Laravel 5.2 Fingers Crossed logging setup
// laravel 5.1 kernel (http and console) to bootstrap using the custom ConfigureLogging class
public function __construct(Application $app, Router $router)
{
parent::__construct($app, $router);
array_walk($this->bootstrappers, function(&$bootstrapper)
{
if($bootstrapper === 'Illuminate\Foundation\Bootstrap\ConfigureLogging')
{
@andybeak
andybeak / nginx.conf
Last active September 24, 2018 16:59
Nginx configuration with redirects #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
## redirects http traffic to https ##
server {