Skip to content

Instantly share code, notes, and snippets.

View tpai's full-sized avatar
💭
kumo

tonypai tpai

💭
kumo
View GitHub Profile
@tpai
tpai / delayed_http_response.yml
Created October 25, 2024 05:49
kubernetes summit 2024 code snippets
apiVersion: apps/v1
kind: Deployment
metadata:
name: delayed-http-response-deployment
spec:
replicas: 1
selector:
matchLabels:
app: delayed-http-response
template:
@tpai
tpai / stephen_chow_movie_quotes.txt
Created August 2, 2024 07:40
Steven Chow Movie Quotes
《望夫成龍》
娣:流星呀!人地話對住流星許願會好靈ga!
石金水:流星喎!話明「流」ga咋,你都信?
《一本漫畫闖天涯》
阿星表演唱歌﹕老豆有身己…己…己…己…恭喜恭喜。
阿星:話說小明個老豆有三個仔,大仔叫大毛,二仔叫二毛,咁三仔叫咩名?
朱標:三毛!
阿星:錯!
@tpai
tpai / boot_notify.sh
Last active July 6, 2024 10:41
Send notification to a Telegram bot from your device (e.g., Raspberry Pi). It will be helpful when the device has a DHCP IP.
#!/bin/bash
telegram_bot_token="xxx" # ask @BotFather for your Telegram bot token
telegram_chat_id="xxx" # type /start on the bot, and `curl https://api.telegram.org/bot${telegram_bot_token}/getUpdates` to retrieve chat_id
telegram_api_url="https://api.telegram.org/bot${telegram_bot_token}/sendMessage"
send_to_telegram() {
local message="$1"
echo $message
curl -s -X POST "${telegram_api_url}" -H "Content-Type: application/json" -d "{\"chat_id\": \"$telegram_chat_id\", \"text\": \"$message\"}"
@tpai
tpai / claude-3-sonnet.md
Last active June 26, 2024 02:46
system prompts of popular GenAI

You are Claude, created by Anthropic.

The current date is Thursday, May 30, 2024.

Claude's knowledge base was last updated in August 2023 and it answers user questions about events before August 2023 and after August 2023 the same way a highly informed individual from August 2023 would if they were talking to someone from Thursday, May 30, 2024.

It should give concise responses to very simple questions, but provide thorough responses to more complex and open-ended questions.

It cannot open URLs, links, or videos, so if it seems as though the interlocutor is expecting Claude to do so, it clarifies the situation and asks the human to paste the relevant text or image content directly into the conversation.

@tpai
tpai / extract-cert-chain.sh
Created June 18, 2024 09:07
Certificate chain extraction script
#!/bin/bash
# Accept stdin as input domain and dump the certificate chain
domain="$1"
openssl s_client -connect "$domain:443" -showcerts </dev/null 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > fullchain.pem
# Split the chain into individual certificates
awk '/BEGIN CERTIFICATE/{n++} {print >("cert-" n ".pem")}' fullchain.pem
# Rename the split files for clarity, handling 2 or 3 certificates
@tpai
tpai / main.py
Created June 17, 2024 16:01
AWS Bedrock API call (Claude 3 Sonnet)
import requests
import json
import boto3
from botocore.auth import SigV4Auth
from botocore.awsrequest import AWSRequest
# AWS credentials
access_key = '<access-key>'
secret_key = '<secret-key>'
region = 'us-west-2'
@tpai
tpai / README.md
Last active January 24, 2024 10:35
Upgrading Docker-Compose from V1 to V2 with Ansible

install docker compose v2

mkdir -p /usr/local/lib/docker/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.24.2/docker-compose-linux-x86_64 -o /usr/local/lib/docker/cli-plugins/docker-compose
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
docker compose version

Ref: https://docs.docker.com/compose/install/linux/#install-the-plugin-manually

@tpai
tpai / README.md
Last active January 9, 2024 10:20
A simple Python script for calling GA4 API
@tpai
tpai / walkthrough.md
Created December 31, 2023 05:15
my walkthrough of clmystery

find all clues with 'CLUE:' prefix in crimescene

Suspect:

  • 6' tall male
  • membership cards: Rotary_Club, Delta SkyMiles, the local library, the Museum of Bash History

Witness:

  • A woman named Annabel
  • blond spiky hair
  • New Zealand accent
@tpai
tpai / README.md
Last active April 16, 2023 15:23
This script allows you to extract English text from images using Python.
  1. Install the required packages by running pip install -r requirements.txt in your terminal.
  2. Run the command export TESSDATA_PREFIX=/usr/local/tessdata in your terminal to set the Tesseract data path.
  3. Download the English language data from here and place it to the tessdata folder above.
  4. Run main.py