Skip to content

Instantly share code, notes, and snippets.

View jamesseanwright's full-sized avatar
🤔

James Wright jamesseanwright

🤔
View GitHub Profile
@jamesseanwright
jamesseanwright / stable-diffusion-text2img-curl.sh
Last active May 10, 2024 16:29
Example HTTP request for Stable Diffusion's txt2img API
curl -X 'POST' https://<HOST>/sdapi/v1/txt2img \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"prompt": "Photo of a man eating an egg",
"negative_prompt": "",
"seed": -1,
"subseed": -1,
"subseed_strength": 0,
"seed_resize_from_h": -1,
@jamesseanwright
jamesseanwright / blender-containerised-cuda.sh
Created August 22, 2023 12:59
docker run command for rendering Blender projects within a container using the CUDA Cycles device
$ docker run --rm --runtime=nvidia --gpus all -e NVIDIA_VISIBLE_DEVICES=all \
-v ./blendervol:/blendervol \
nytimes/blender:3.3.1-gpu-ubuntu18.04 \
blender -b /blendervol/monster_under_the_bed_sss_demo_by_metin_seven.blend -o blendervol/monster_CONTAINER.jpg -F JPEG -f 1 -E CYCLES -- --cycles-device CUDA
@jamesseanwright
jamesseanwright / benchmark.js
Created April 12, 2022 21:57
Benchmarking serial vs parallel Promise executions
'use strict';
const http = require('http');
const getQuote = () =>
new Promise((resolve, reject) => {
http.get('http://ron-swanson-quotes.herokuapp.com/v2/quotes', res => {
res.setEncoding('utf8');
let data = '';
@jamesseanwright
jamesseanwright / html-table-to-csv.js
Created November 10, 2021 17:50
Serialising a HTML table to CSV format
'use strict';
const { parseHTML } = require('linkedom');
const createSerialiser = serialiser =>
element => {
let result = '';
const traverse = el => {
const serialisedEl = serialiser(el, result.length);
{
"message": "Invalid request body"
}
$ curl -XPOST "https://xxxxxxxxxx.execute-api.eu-west-1.amazonaws.com/production/events" \
-H "Content-Type: application/json" \
-H "x-api-key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
-d '{
"deviceID": "8f188304-e7b3-4a16-a243-b9470468478a",
"eventType": "temp_celcius",
"value":3
}'
$ curl -XPOST "https://xxxxxxxxxx.execute-api.eu-west-1.amazonaws.com/production/events" \
-H "Content-Type: application/json" \
-H "x-api-key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
-d '{
"date": "'$(date -u +%FT%TZ)'",
"deviceID": "8f188304-e7b3-4a16-a243-b9470468478a",
"eventType": "temp_celcius",
"value":3
}'
$ aws ecr get-login-password --region <AWS region> | docker login --username AWS --password-stdin <AWS account ID>.dkr.ecr.<AWS region>.amazonaws.com
variable "region" {
description = "The AWS region to which the lambdas and AWS-backed Atlas cluster are deployed"
type = string
}
variable "atlas_org_id" {
description = "The ID of your MongoDB Atlas organisation"
type = string
}
resource "aws_api_gateway_rest_api" "api" {
name = "iot-events"
}
resource "aws_api_gateway_model" "event" {
rest_api_id = aws_api_gateway_rest_api.api.id
name = "event"
description = "Event information sent from a device"
content_type = "application/json"