Skip to content

Instantly share code, notes, and snippets.

View brettscott's full-sized avatar

Brett Scott brettscott

View GitHub Profile
@brettscott
brettscott / dev-machine-check.sh
Created March 30, 2022 16:12
Script to check if dev machine properly configure to run Python
#!/bin/bash
function bin_check() {
which $1 > /dev/null; exists=$?
[ $exists -ne 0 ] && echo -e "\nERROR: $1 not found" && exit 1
printf "%-20s" $1
[ $exists -eq 0 ] && echo "OK" || echo "MISSING"
}
@brettscott
brettscott / vscode_plantuml_docker.md
Last active October 6, 2023 07:43
Integrating PlantUML with VSCode using Windows 10, WSL2, Dockerised PlantUML Server and "jebbs.plantuml" VSCode Extension

There is no need to install Java or Graphviz on your Windows 10 Desktop. These are contained neatly within a Docker Container.

Prerequisites

  • Windows 10
  • WSL2 (Ubuntu) - optional
  • VSCode
  • Docker Desktop

Setup

@brettscott
brettscott / Link.tsx
Created November 14, 2019 13:44
React Link component in Nextjs (v9) with Next Link, Next Router, Material-UI's MuiLink and TypeScript
{
"workbench.startupEditor": "newUntitledFile",
// Controls auto save of dirty files. Accepted values: 'off', 'afterDelay', 'onFocusChange' (editor loses focus), 'onWindowChange' (window loses focus). If set to 'afterDelay', you can configure the delay in 'files.autoSaveDelay'.
"files.autoSave": "onWindowChange",
// Controls the window title based on the active editor. Variables are substituted based on the context:
// ${activeEditorShort}: the file name (e.g. myFile.txt)
// ${activeEditorMedium}: the path of the file relative to the workspace folder (e.g. myFolder/myFile.txt)
// ${activeEditorLong}: the full path of the file (e.g. /Users/Development/myProject/myFolder/myFile.txt)
@brettscott
brettscott / aes-256-cbc-test.js
Last active January 26, 2024 08:01
AES 256 CBC encryption between Golang and Node JS
// Node v6.9.0
//
// TEST FILE (cut down for simplicity)
// To ensure Golang encrypted string can be decrypted in NodeJS.
//
let crypto;
try {
crypto = require('crypto');
@brettscott
brettscott / test_ghostdriver_useragent.txt
Created February 20, 2014 15:09
Output of test_ghostdriver_useragent.sh
[root@pal bin]# ./test_ghostdriver_useragent.sh
=== TEST #1 ===
phantomjs.page.settings.userAgent: iphone
=== START SESSION ===
/session :
Response:
@brettscott
brettscott / test_ghostdriver_useragent.sh
Created February 20, 2014 15:02
Ghostdriver User-Agent Test
#!/bin/bash
# pkill -KILL phantomjs
# phantomjs --disk-cache=no --webdriver=4444 &
# ------------------------------------------------------------------
# Config
host="http://localhost"
@brettscott
brettscott / test_ghostdriver.txt
Created February 7, 2014 10:02
Output of test_ghostdriver.sh
[root@pal bin]# ./test_ghostdriver.sh
/session :
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 536 100 536 0 0 8638 0 --:--:-- --:--:-- --:--:-- 0
Response:
HTTP/1.1 200 OK
Cache: no-cache
Content-Length: 536
Content-Type: application/json;charset=UTF-8
@brettscott
brettscott / test_ghostdriver.sh
Last active August 29, 2015 13:56
Ghostdriver debugging REST interface
#!/bin/bash
# ------------------------------------------------------------------
# Start Session
echo "/session :"
request="curl --include --data "{\"desiredCapabilities\":[{\"phantomjs.page.settings.userAgent\":\"iphone\"},{\"browserName\":\"phantomjs\"}]}" http://localhost:4444/wd/hub/session"
# Example response: {"sessionId":"67b0bfd0-8f4c-11e3-94f9-11808a4b2852","status":0,"value":{"browserName":"phantomjs","version":"1.9.2","driverName":"ghostdriver","driverVersion":"1.0.4","platform":"linux-unknown-64bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"},"phantomjs.page.settings.userAgent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0 BBC-GNL-BDD"}}
response=$($request)
echo "Response:"