Skip to content

Instantly share code, notes, and snippets.

View spdin's full-sized avatar
🏠
Working from home

Saripudin spdin

🏠
Working from home
View GitHub Profile
import base64
import requests
# Set up Datasaur API
API_URL = "https://deployment.datasaur.ai/api/deployment/8/1937/chat/completions"
headers = {
'Authorization': 'Bearer <api-key>',
'Content-Type': 'application/json'
}
import asyncio
import os
import sys
import re
from pathlib import Path
from urllib.parse import urlparse, parse_qs
import aiohttp
import aiofiles
from typing import Any, Sequence
import logging
@spdin
spdin / mcp_hello_world.py
Created June 13, 2025 03:53
MCP Remote Server Example
import asyncio
import json
import logging
from typing import Any, Dict, Optional
import modal
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse, StreamingResponse, Response
from pydantic import BaseModel
# Modal app configuration
@spdin
spdin / gist:f30a121ba79e3dfb1f60f44d40469324
Created July 27, 2023 04:36
nginx setup for streamlit
location / {
proxy_pass http://0.0.0.0:8501/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
@spdin
spdin / plot.py
Created February 17, 2023 07:16
plot graph
import matplotlib.pyplot as plt
training_points = [0, 10, 25, 50, 100, 250, 500]
bert_acc = [0.5310526315789473, 0.5727631578947369, 0.6130263157894736, 0.8502631578947368, 0.8619736842105263, 0.8727631578947368, 0.8660526315789474]
roberta_acc = [0.49236842105263157, 0.6001315789473685, 0.7292105263157894, 0.7705263157894737, 0.8469736842105263, 0.8442105263157895, 0.8730263157894737]
plt.plot(training_points, bert_acc, label="bert-base-uncased")
plt.plot(training_points, roberta_acc, label="roberta-base")
@spdin
spdin / requirements.txt
Last active November 11, 2021 03:43
requirements.txt
flask==1.0.2
opencv-python==4.0.1.23
opencv-python-headless==4.5.1.48
pyyaml==5.3.1
shapely==1.7.0
pandas==0.24.2
requests==2.23.0
albumentations==0.4.5
glog==0.3.1
gunicorn==20.0.4
@spdin
spdin / compare.py
Created September 10, 2021 10:47
bantu SE
save_keeping_v2 = {
"1_000": None,
"1_001": {
"jenis_dokumen": {
"text": "INVOICE",
},
"nomor_dokumen": {
"text": "cloudmob015",
},
}
gunicorn -w 5 -b 127.0.0.1:8811 api:app -t 120 --reload --max-requests 100 --access-logfile log.txt --access-logformat '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" %({X-REMOTE-ADDR}i)s %({X-REAL-IP}i)s'
@spdin
spdin / default
Created July 8, 2021 07:51
NGINX setup
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
server_name _;
index index.html index.htm index.nginx-debian.html;
location / {
proxy_read_timeout 600s;
proxy_connect_timeout 600s;
@spdin
spdin / save-load-pickle.py
Created June 24, 2021 00:21
save and load pickle
import pickle
# Saving the objects:
with open('test1.pkl', 'wb') as f: # Python 3: open(..., 'wb')
pickle.dump([table_bbox, row_bbox, column_bbox], f)
# Getting back the objects:
with open('test1.pkl', 'rb') as f: # Python 3: open(..., 'rb')