Skip to content

Instantly share code, notes, and snippets.

View MatthewDaniels's full-sized avatar

Matthew Daniels MatthewDaniels

  • Brisbane, Qld, Australia
View GitHub Profile
@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:

@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);
@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,
@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
@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 {
@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) {
@bengarrett
bengarrett / rsync.md
Last active June 8, 2024 06:33
Rsync - Helpers and common usage.

Rsync

Common arguments

-v verbose

-h humanise the output by implementing binary multipliers instead of byte values etc.

-P display progress and allow resumption of interrupted transfers

-n do a dry run for testing

@joyrexus
joyrexus / README.md
Last active June 8, 2023 07:45
form-data vs -urlencoded

Nice answer on stackoverflow to the question of when to use one or the other content-types for POSTing data, viz. application/x-www-form-urlencoded and multipart/form-data.

“The moral of the story is, if you have binary (non-alphanumeric) data (or a significantly sized payload) to transmit, use multipart/form-data. Otherwise, use application/x-www-form-urlencoded.”


Matt Bridges' answer in full:

The MIME types you mention are the two Content-Type headers for HTTP POST requests that user-agents (browsers) must support. The purpose of both of those types of requests is to send a list of name/value pairs to the server. Depending on the type and amount of data being transmitted, one of the methods will be more efficient than the other. To understand why, you have to look at what each is doing

@xrstf
xrstf / setup.md
Last active October 3, 2022 13:30
Nutch 2.3 + ElasticSearch 1.4 + HBase 0.94 Setup

Info

This guide sets up a non-clustered Nutch crawler, which stores its data via HBase. We will not learn how to setup Hadoop et al., but just the bare minimum to crawl and index websites on a single machine.

Terms

  • Nutch - the crawler (fetches and parses websites)
  • HBase - filesystem storage for Nutch (Hadoop component, basically)
  • 🎨 when improving the format/structure of the code
  • 🚀 when improving performance
  • ✏️ when writing docs
  • 💡 new idea
  • 🚧 work in progress
  • ➕ when adding feature
  • ➖ when removing feature
  • 🔈 when adding logging
  • 🔇 when reducing logging
  • 🐛 when fixing a bug