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 / rn-async-webapi.js
Created September 13, 2017 13:05
Example of making an async React Native call to a .NET Web API 2 project.
/*
* Example of making an async React Native call to a .NET Web API 2 project.
* Helped with this issue a few times now.. Note the content type.
*/
(async () => {
// Make the API call
fetch(constants.API_ROUTE+'Token', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
@joduplessis
joduplessis / index.html
Created May 2, 2022 08:18
Basic (very old) WebRTC test
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<video autoplay controls></video>
<button onClick="javascript:start()">Connect</button>
@joduplessis
joduplessis / index.js
Created November 10, 2020 08:31
Replacing the classNames library with 9 lines.
const classNames = (object) => {
const classArray = [];
for (let property in object) {
if (object[property]) classArray.push(property)
}
return classArray.join(' ')
}
@joduplessis
joduplessis / index.html
Created March 1, 2022 11:43
The Adtriba coding challenge. Form solution + draggable input curve.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<style>
* {
font-family: sans-serif;
outline: none;
text-decoration: none;
@joduplessis
joduplessis / session.js
Last active February 19, 2022 14:03
Simple session tracking using cookies only
window.addEventListener('load', function() {
function registerPageView(currentSessionCookieTimestamp) {
const currentTimestamp = new Date().getTime()
const fiveMinutes = 5 * 60 * 1000
if (!currentSessionCookieTimestamp) {
// ...PV logic...
} else {
if (currentTimestamp - currentSessionCookieTimestamp > fiveMinutes) {
// ...PV logic...
@joduplessis
joduplessis / index.js
Created February 19, 2022 14:02
ReactQuill example (for reference, so I don't forget)
// https://github.com/afry/quill-mention
// https://github.com/zenoamaro/react-quill
// <link rel="stylesheet" href="https://unpkg.com/react-quill@1.3.3/dist/quill.snow.css">
// .ql-mention-list-container{width:270px;border:1px solid #f0f0f0;border-radius:4px;background-color:#fff;box-shadow:0 2px 12px 0 rgba(30,30,30,.08);z-index:9001;overflow:auto}.ql-mention-loading{line-height:44px;padding:0 20px;vertical-align:middle;font-size:16px}.ql-mention-list{list-style:none;margin:0;padding:0;overflow:hidden}.ql-mention-list-item{cursor:pointer;line-height:44px;font-size:16px;padding:0 20px;vertical-align:middle}.ql-mention-list-item.disabled{cursor:auto}.ql-mention-list-item.selected{background-color:#d3e1eb;text-decoration:none}.mention{height:24px;width:65px;border-radius:6px;background-color:#d3e1eb;padding:3px 0;margin-right:2px;user-select:all}.mention>span{margin:0 3px}
import React, { useEffect, useState, Component } from 'react'
import './accounts.page.css'
import ReactQuill from 'react-quill'
import Qu
@joduplessis
joduplessis / config.yml
Created June 10, 2020 04:30
CircleCI file for building Windows electron apps - actual Docker image doesn't always work so well.
version: 2
jobs:
build_windows:
docker:
- image: electronuserland/builder:wine
steps:
- checkout
- run: npm i
- run: npm run build:electron
- run: npm run pack:win
@joduplessis
joduplessis / bitbucket-ftp-push.yml
Created March 6, 2018 06:41
Simple FTP push using BitBucket pipelines.
image: node:7.10.1
pipelines:
default:
- step:
script:
- node -v
- npm install
- apt-get update
- apt-get install -y lftp
- lftp -u USERNAME,PASSWORD FTPDOMAIN -e "mirror -e -R -p ./dist/ public_html ; quit"
@joduplessis
joduplessis / convert.sh
Created May 31, 2020 19:14
Favourite bash command for converting almost any video to H.264/AAC (web video).
#!/bin/bash
ffmpeg -i input.mp4 -vcodec libx264 -acodec aac output.mp4
@joduplessis
joduplessis / letsencrypt-acme-challenge.conf
Created April 28, 2020 06:34
Generating LE certs manually with acme challenges.
#############################################################################
# Configuration file for Let's Encrypt ACME Challenge location
# This file is already included in listen_xxx.conf files.
# Do NOT include it separately!
#############################################################################
#
# This config enables to access /.well-known/acme-challenge/xxxxxxxxxxx
# on all our sites (HTTP), including all subdomains.
# This is required by ACME Challenge (webroot authentication).
# You can check that this location is working by placing ping.txt here: