Skip to content

Instantly share code, notes, and snippets.

View joduplessis's full-sized avatar
Brewing coffee.

Jo du Plessis joduplessis

Brewing coffee.
View GitHub Profile
@joduplessis
joduplessis / mongodb.go
Created May 22, 2019 11:28
Gets a document in a date range (30 days ago) using the new MongoDB drivers. Based off of Yack.app.
package main
import (
"fmt"
"time"
"log"
"context"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/bson"
@joduplessis
joduplessis / index.html
Created March 1, 2019 05:39
Helped a friend do a fade out/in testmassessment in vanilla JS.
<html>
<body>
<style>
* {
font-family: helvetica;
}
.fadein {
transition: opacity 1s;
@joduplessis
joduplessis / index.js
Created January 4, 2019 18:54
Converting my personal site project list to markdown files. Keeping the gist as a reference (for future).
const fs = require('fs');
const { project } = require('./work.json');
project.forEach((proj) => {
const { author, images, links, notes, partner, project, roles, slug, tags, year } = proj;
const path = `./projects/${slug}.md`;
const content = `
#${project}
@joduplessis
joduplessis / .travis.yml
Created January 4, 2019 01:47
TravisCI doesn't seem to play too nice with Node - snippet of a Node build & FTP push (hangs). For reference though.
language: node_js
sudo: false
addons:
apt:
packages:
- lftp
os: linux
node_js:
- "9.11.2"
branches:
@joduplessis
joduplessis / bitbucket-pipelines.yml
Created January 3, 2019 09:30
Simple BitBucket Pipelines file for pushing recent Git updates to FTP
image: php:7.1.1
pipelines:
branches:
master:
- step:
name: Deploy to FTP
script:
- apt-get update
- apt-get -qq install git-ftp
@joduplessis
joduplessis / AuthJwt.js
Created January 3, 2019 09:28
Custom HAPI.js plugin for handling JWT authentication on routes.
const jwt = require('./jwt');
const SECRET = "yoursupersecret";
export const AuthJwt = {
name: 'AuthJwt',
version: '1.0.0',
register: async function (server, options) {
server.auth.scheme('jwt', (server, options) => {
return {
@joduplessis
joduplessis / webrtc-mqtt.html
Created September 22, 2018 06:41
Straightforward implementation of (promisified) WebRTC using MQTT as a messaging protocol (over WebSockets). Needs some QA love, but illustrates the process of WebRTC offers, answers & "jingles".
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<video autoplay controls></video>
<button onClick="javascript:start()">Connect</button>
@joduplessis
joduplessis / backup.sh
Created March 21, 2018 14:57
Backup pipeline running every day for a Linux VPS. Zips folder & files and FTPs to a location.
#!/bin/bash
# Change the directory
cd /home/username/backup
# First do our MySQL dump
mysqldump -u root -p "PASSWORD" --all-databases > alldb.sql
# Copy all sorted of stuff here to the backup folder
cp -r /home/username/files /home/username/backup/files
@joduplessis
joduplessis / mongodb_commands.sh
Created March 12, 2018 10:48
Bunch of MongoDB CLI commands. Kept on here as a reference for me.
# Exports to JSON
mongoimport --db DB_NAME --collection COLLECTION --file COLLECTION.json
mongoexport --db DB_NAME --collection COLLECTION -o COLLECTION.json
# Exports to CSV, using specific fields
mongoexport --db DB_NAME --collection COLLECTION --type=csv --fields OBJECT, FIELDS --out COLLECTION.csv
mongoexport --db DB_NAME --collection COLLECTION --type=csv --fields OBJECT, FIELDS --out COLLECTION.csv
# Gzippy goodness
mongodump -d "DB_NAME" --gzip -o "DB_NAME.dump"
@joduplessis
joduplessis / AppName.plist
Created March 9, 2018 11:02
Sample plist file for over-the-air deployment. Rererenced from another Gist, kept here for my reference.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>