Skip to content

Instantly share code, notes, and snippets.

@thecloudranger
thecloudranger / rekognition_lambda.py
Created January 19, 2021 05:21
This lambda detects labels in an uploaded image to an S3 bucket by invoking Rekognition's DetectLabels (detect_labels in boto3) and DetectCustomLabels (detect_custom_labels in boto3) APIs.
from __future__ import print_function
import boto3
from decimal import Decimal
import json
import urllib
print('Loading function')
rekognition = boto3.client('rekognition')
@thecloudranger
thecloudranger / gist:406dfb7093d1431d679e5a5ad041f004
Created July 2, 2021 14:02 — forked from SzymonPobiega/gist:5220595
DDD/CQRS/ES/Architecture videos

If you have two days to learn the very basics of modelling, Domain-Driven Design, CQRS and Event Sourcing, here's what you should do:

In the evenings read the [Domain-Driven Design Quickly Minibook]{http://www.infoq.com/minibooks/domain-driven-design-quickly}. During the day watch following great videos (in this order):

  1. Eric Evans' [What I've learned about DDD since the book]{http://www.infoq.com/presentations/ddd-eric-evans}
  2. Eric Evans' [Strategic Design - Responsibility Traps]{http://www.infoq.com/presentations/design-strategic-eric-evans}
  3. Udi Dahan's [Avoid a Failed SOA: Business & Autonomous Components to the Rescue]{http://www.infoq.com/presentations/SOA-Business-Autonomous-Components}
  4. Udi Dahan's [Command-Query Responsibility Segregation]{http://www.infoq.com/presentations/Command-Query-Responsibility-Segregation}
  5. Greg Young's [Unshackle Your Domain]{http://www.infoq.com/presentations/greg-young-unshackle-qcon08}
  6. Eric Evans' [Acknowledging CAP at the Root -- in the Domain Model]{ht
@thecloudranger
thecloudranger / buildspec.yml
Created October 5, 2021 13:16
Codebuild for Flutter Android apps
version: 0.2
phases:
install:
runtime-versions:
android: 29
java: corretto8
commands:
- pwd
pre_build:
commands:
@thecloudranger
thecloudranger / ar-en-regex.md
Last active October 24, 2022 20:59
Match english and arabic characters and numerals

//regex

^[\u0621-\u064A\u0660-\u0669a-zA-Z0-9-_\s]{4,35}$

@thecloudranger
thecloudranger / ar-en-regex.html
Created October 24, 2022 21:01
Match EN AR characters and numbers between print and console.log statements
<html>
<body>
<input type="text" id="myinput"/>
<button id="testBtn" onclick=test()>test</button>
<button id="matchBtn" onclick=match()>match</button>
<br/>
<div>
<span id="outputMatch"></span>
</div>
@thecloudranger
thecloudranger / deploy.sh
Last active December 9, 2022 19:53
Security for Developers workshop setup
#!/bin/bash
cd ~/environment
wget https://workshops.devax.academy/security-for-developers/module2/files/pipeline.zip
unzip pipeline.zip -d pipeline
cd ~/environment/pipeline/
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp config.yaml.sample config.yaml
cdk bootstrap
@thecloudranger
thecloudranger / App.java
Last active January 4, 2023 10:02
AWS Lambda function in Java to show warming DynamoDB connection in the constructor
public class App implements RequestHandler < Object, Object > {
private final DynamoDbClient ddb = DynamoDbClient.builder()
.credentialsProvider(EnvironmentVariableCredentialsProvider.create())
.region(System.getenv("AWS_REGION"))
.httpClientBuilder(UrlConnectionHttpClient.builder())
.build();
private static final String tableName = System.getenv("DYNAMODB_TABLE_NAME");
public App() {
ddb = getDynamoDBClient();
DescribeTableRequest request = DescribeTableRequest.builder()
@thecloudranger
thecloudranger / App.java
Created January 4, 2023 10:06
AWS Lambda function in Java showing initialization of S3 client in constructor
public class App implements RequestHandler<Object, Object> {
private final S3Client s3Client;
public App() {
s3Client = DependencyFactory.s3Client();
}
@Override
public Object handleRequest(final Object input, final Context
context) {
ListBucketResponse response = s3Client.listBuckets();
// Process the response.
@thecloudranger
thecloudranger / Config.json
Created January 15, 2023 20:45
PopClip Extension - DEVONthink 3 Add New Markdown
# PopClip - DEVONthink 3 Add New Markdown
name: DT3 Add New
icon: symbol:asterisk
capture html: true
javascript: |
let clipping = popclip.input.markdown
if (popclip.context.browserUrl.length > 0) {
let title = encodeURIComponent(popclip.context.browserTitle)
let siteURL = popclip.context.browserUrl
clipping += `\n[${popclip.context.browserTitle}](${popclip.context.browserUrl})\n#clipped`
# PopClip - Obsidian extension, markdown variant
# Source https://forum.popclip.app/t/clip-selection-to-obsidian/359/4
name: OBSClipper
icon: O
options:
- identifier: vault
label: Vault Name
type: string
capture html: true # this is needed when we want markdown text
javascript: |