Skip to content

Instantly share code, notes, and snippets.

@waqqas
waqqas / start_script.sh
Created August 23, 2023 12:22
go debug
inotifywait -e MODIFY -r -m /workspace/src |
while read path action file; do
lockBuild
ext=${file: -3}
if [[ "$ext" == ".go" ]]; then
echo File changed: $file
rerunServer
fi
unlockBuild
done
@waqqas
waqqas / Dockerfile
Created August 23, 2023 12:08
golang debug
FROM builder AS debug
RUN apk add --no-cache git inotify-tools
ENV CGO_ENABLED 0
RUN go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@latest
RUN go install -v github.com/ramya-rao-a/go-outline@v0.0.0-20210608161538-9736a4bde949
RUN go install -v golang.org/x/tools/gopls@latest
RUN go install honnef.co/go/tools/cmd/staticcheck@2022.1
@waqqas
waqqas / .dockerignore
Created August 23, 2023 11:32
golang debugging
# Files
.dockerignore
.editorconfig
.gitignore
.env.*
Dockerfile
Makefile
LICENSE
**/*.md
**/*_test.go
@waqqas
waqqas / fsm_libs.md
Last active August 21, 2023 02:55
FSM
Language Library Name Description
Python transitions A lightweight, object-oriented FSM framework.
Python PyState A simple FSM library based on decorators. (Note: The exact GitHub URL might differ)
JavaScript javascript-state-machine A library for finite state machines that can be used in the browser or in Node.js.
JavaScript xstate A library for creating, interpreting, and executing finite state mach
from .iterators import TransactionIterator, BigQueryTransaction
#########################
query_job = client.query(sql)
return TransactionIterator(query_job.result())
from typing import TypedDict, Optional, List
from decimal import Decimal
from datetime import datetime
class BigQueryTransaction(TypedDict):
hash: str
nonce: int
transaction_index: int
from_address: str
from typing import Iterable, Iterator
from .models import BigQueryTransaction
class BaseIterator(Iterable):
def __init__(self, iterable: Iterator):
self.iterable = iterable
self._iterator = None
def __iter__(self) -> Iterator:
from google.cloud import bigquery
client = bigquery.Client.from_service_account_json(credentials_path)
query_job = client.query(sql)
return query_job.result()
import openai
def analyze_sentiment(comment):
prompt = f"Analyze the sentiment of the following comment: '{comment}'\n\nRating:"
response = openai.Completion.create(
engine="text-davinci-003",
prompt=prompt,
temperature=0.3,
max_tokens=10,
n=1,
# Airflow configuration
AIRFLOW_USE_MWAA=False
# Airflow configuration when AIRFLOW_USE_MWAA = True
MWAA_REGION_NAME=us-east-1
MWAA_ENVIRONMENT_NAME=MyAirflowEnv
# Airflow configuration when AIRFLOW_USE_MWAA = False
AIRFLOW_HOST=localhost
AIRFLOW_PORT=8080
AIRFLOW_USER=airflow_user
AIRFLOW_PASSWORD=airflow_password