Skip to content

Instantly share code, notes, and snippets.

View MatthewDaniels's full-sized avatar

Matthew Daniels MatthewDaniels

  • Brisbane, Qld, Australia
View GitHub Profile
@kyleridolfo
kyleridolfo / ga-video.js
Created September 3, 2015 18:41
HTML5 Video Tracking for Google Tag Manager
<script>
// Let's wrap everything inside a function so variables are not defined as globals
(function(){
// This is gonna our percent buckets ( 10%-90% )
var divisor = 10;
// We're going to save our players status on this object.
var videos_status = {};
// This is the funcion that is gonna handle the event sent by the player listeners
function eventHandler(e){
switch(e.type) {
@renchap
renchap / README.md
Last active February 14, 2025 13:25
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@MatthewDaniels
MatthewDaniels / Upload file to S3 - Multipart
Last active January 9, 2022 23:24
Use this as a structure to send a file to S3. It uses the AWS Javascript SDK - unfortunately, without using requires js, all other builds failed aside from the CDN provided version here: https://sdk.amazonaws.com/js/aws-sdk-2.2.33.min.js
// NOTE: it is suggested that you use very limited credentials
// a good solution is to create an IAM user in AWS that has only PUT rights to S3
// use a temporary bucket that has an expiry (24hrs or something low)
// once the file is uploaded get your server to move the file to another bucket that has much less
// restricted rights.
// See: readme for more info
// setup the credentials
AWS.config.update({
accessKeyId: accessKeyId,
@MatthewDaniels
MatthewDaniels / GA Tracker helper
Last active November 13, 2017 03:47
This script iterates the Google Analytics trackers on the page (assuming the Google Analytics variable is 'ga'. It then outputs various bits of info, including the tracker name, the tracking ID, the client ID, the cookie domain and any custom dimensions that exist. Copy and paste it into the console on the page you want to find out more about.
if(window.ga) {
var arr = window.ga.getAll();
for (var i = 0, len = arr.length; i < len; i++) {
var t = arr[i];
if(console.group) {
console.group(t.get('name'));
}
console.log('Main tracker object:', t);
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active January 9, 2025 12:22
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
version: '2'
services:
master:
image: elasticsearch:5.0.0-alpha5
command: elasticsearch -Enode.master=true -Enode.data=false -Ecluster.name=cluster-01 -Enode.name="Master of Disaster"
environment:
- ES_JAVA_OPTS=-Xms2g -Xmx2g
ports:
- "9200:9200"
- "9300:9300"
@g0ld3lux
g0ld3lux / docker-compose.yml
Created November 27, 2016 07:37
Scaling Out Laravel with Docker
haproxy:
image: interaction/haproxy:master
links:
- letsencrypt
- web
ports:
- "80:80"
- "443:443"
volumes_from:
- letsencrypt
@kyleferguson
kyleferguson / Dockerfile
Last active December 19, 2023 06:10
Example Laravel deployment for Kubernetes
FROM php:7.1-apache
ADD . /var/www
ADD ./site.conf /etc/apache2/sites-enabled/000-default.conf
RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client && \
docker-php-ext-install mcrypt pdo_mysql opcache && \
pecl install redis-3.1.2 && docker-php-ext-enable redis && \
a2enmod rewrite