Skip to content

Instantly share code, notes, and snippets.

View craigvantonder's full-sized avatar

Craig van Tonder craigvantonder

  • South Africa
View GitHub Profile
@craigvantonder
craigvantonder / setup-awscli-codedeploy-agent.sh
Last active February 11, 2021 12:15
How to install AWS Code Deploy agent in Ubuntu 14.04 / 16.04 / 18.04 / 20.04
#!/bin/bash
# AWS CLI
apt-get install zip -y;
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip";
unzip awscli-bundle.zip;
./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws;
aws configure;
#AWS Access Key ID [None]: Obtained when creating user in AWS IAM
@craigvantonder
craigvantonder / install-configure-letsencrypt.md
Last active April 26, 2022 08:58
Install and configure LetsEncrypt on Ubuntu Server 14.04 & 16.04 (Apache)
#!/bin/bash
# https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-14-04
# Download the Let’s Encrypt Client
cd /usr/local/sbin
sudo wget https://dl.eff.org/certbot-auto
sudo chmod a+x /usr/local/sbin/certbot-auto
# Set Up the SSL Certificate
@craigvantonder
craigvantonder / electron-main.js
Last active November 27, 2016 09:48
Electron main process example for tray icon which minimizes / maximizes the app when clicked.
const electron = require('electron');
const app = electron.app;
const Tray = electron.Tray;
const BrowserWindow = electron.BrowserWindow;
// We create a null variables so that the tray and mainWindow
// don’t get removed by garbage collection
let tray = null;
let mainWindow = null;
@craigvantonder
craigvantonder / electron-sqlite3.md
Last active October 16, 2022 05:47
Electron SQLite3 Integration

Electron SQLite3 Integration

When trying to use the node-sqlite3 module in Electron I got the error:

Error: Cannot find module '/path/to/my/application/node_modules/sqlite3/lib/binding/electron-v1.4-linux-x64/node_sqlite3.node'

Using Ubuntu 16.04 with Node 7.1.0 and Electron 1.4.12.

I read the following:

@craigvantonder
craigvantonder / sails-grunt-babel.md
Last active March 14, 2017 07:55
Integrating Babel with Sails front end via Grunt

Sails Babel Integration

Install the grunt hook for babel along with the presets required:

npm install --save grunt-babel babel-preset-es2015

Create tasks/config/babel.js:

module.exports = function(grunt) {
@craigvantonder
craigvantonder / SendMail.php
Last active September 10, 2019 05:05
A wrapper for PHP mailer
<?php
function sendMail($mailFrom, $replyTo, $mailTo, $ccTo, $mailSubject, $mailContent, $mailTemplate)
{
// Create a new PHPMailer instance
$mail = new PHPMailer();
// Tell PHPMailer to use SMTP
$mail->isSMTP();
// Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
@craigvantonder
craigvantonder / runtime.php
Created December 18, 2016 12:07
Calculate the process runtime in PHP
<?php
$process_start_time;
$process_end_time;
$process_runtime;
// Capture process start time
list($usec, $sec) = explode(' ', microtime());
// Store the start time
$process_start_time = (float) $sec + (float) $usec;
@craigvantonder
craigvantonder / watch-mem.sh
Last active March 17, 2017 23:58
Watch memory usage in Ubuntu
#!/bin/bash
# http://www.upubuntu.com/2013/01/how-to-free-up-unused-memory-in.html
watch -n 5 free -m
@craigvantonder
craigvantonder / connectorj-mysql-integration.md
Last active October 5, 2022 23:29
MySQL Connector/J / JDBC Integration (In Ubuntu)
@craigvantonder
craigvantonder / logstash-mysql-elasticsearch-service.md
Last active September 1, 2020 12:28
Logstash (MySQL -> AWS Elasticsearch Service) Integration in Ubuntu 16.04