Skip to content

Instantly share code, notes, and snippets.

View johnoscott's full-sized avatar

Johno Scott johnoscott

View GitHub Profile
## Connect PG8000 to database
conn = pg8000.connect(database=args['db_name'],user=args['db_user'],password=args['db_password'],host=args['db_host'],port=5432)
cur = conn.cursor()
# ...
# Example upsert query
cur.execute("INSERT INTO {} SELECT * FROM {} ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name".format('campaigns', 'tmp_staging_campaings'))
# ...
conn.commit()
cur.close()
conn.close()
@johnoscott
johnoscott / sample-excw.excalidraw
Last active July 13, 2020 16:15
Draw.io Diagrams
{
"type": "excalidraw",
"version": 2,
"source": "https://excalidraw.com",
"elements": [
{
"type": "rectangle",
"version": 192,
"versionNonce": 1899200910,
"isDeleted": false,
@johnoscott
johnoscott / sparkline.md
Last active November 15, 2018 08:08
Hide Sparkline end value
@johnoscott
johnoscott / out.log
Created November 12, 2018 23:57
Create a Self-signed Certificate for Development
Credit to : https://github.com/kingkool68/generate-ssl-certs-for-local-development
Here is the sample output after running the script:
sudo ./generate-ssl.sh local.dev
Password:
Generating RSA private key, 2048 bit long modulus
..........+++
..............................................+++
<iframe src="data:text/html;charset=utf-8,%3Cbody%3E%3Cscript%20src%3D%22https%3A%2F%2Fgist.github.com%2Fef4%2Ffe2e8e5b6e75266e3c2d.js%22%3E%3C%2Fscript%3E%3C%2Fbody%3E">
@johnoscott
johnoscott / react-data-grids.md
Last active April 18, 2018 03:19
[React Data Grid Examples] Some research on the better data grids for React #datagrid #react

React Data Grid Examples

Edit new

<iframe src="https://codesandbox.io/embed/new" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe> Edit new
@johnoscott
johnoscott / rotate_pi.sh
Created April 16, 2018 02:18
[Rotate Raspberry Pi Display from Terminal] #raspberry-pi
INSTALLATION
We've created a one-liner that automates the installation procedure. To get started with this display, simply execute curl -L http://coreelec.io/2q | bash
If you want to see what this script does before running, save it to a file with curl -L http://coreelec.io/2q >> lcd35-installer
You can roll back to using the regular HDMI output at any time by executing the included LCD_hdmi script.
https://core-electronics.com.au/3-5inch-display-module-touch-lcd-with-stylus-for-raspberry-pi-3.html
To rotate your display, simply enter display_rotate or lcd_rotate at the bottom of your config file:
@johnoscott
johnoscott / generateUUID.js
Created April 6, 2018 02:14
[Generat UUID] Create a UUID with JavaScript
function generateUUID() { // Public Domain/MIT
var d = new Date().getTime();
if (typeof performance !== 'undefined' && typeof performance.now === 'function'){
d += performance.now(); //use high-precision timer if available
}
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});
@johnoscott
johnoscott / docker_cloud_stack_on_digital_ocean_for_$5_per_mo.md
Last active April 1, 2018 03:21
[Docker Cloud Stack on Digital Ocean $5 per mo]

Dockerize a React App in 2018 with CreateReactApp

TLDR

Markdown Less Pretty
Still renders nicely
1 2 3

References

Dockerize a React App in 2018 with CreateReactApp

TLDR

Markdown Less Pretty
Still renders nicely
1 2 3

References