Skip to content

Instantly share code, notes, and snippets.

View korakot's full-sized avatar

Korakot Chaovavanich korakot

  • Bangkok, Thailand
View GitHub Profile
@korakot
korakot / hello.txt
Created March 17, 2025 09:22
test from pygithub
Hello World
@korakot
korakot / pytube.py
Created November 22, 2024 03:29
pytube patch - nov 2024
# From https://github.com/pytube/pytube/issues/2062
import ssl
from pytube import YouTube
from pytube import request
from pytube import extract
from pytube.innertube import _default_clients
from pytube.exceptions import RegexMatchError
_default_clients["ANDROID"]["context"]["client"]["clientVersion"] = "19.08.35"
_default_clients["IOS"]["context"]["client"]["clientVersion"] = "19.08.35"
@korakot
korakot / setenv.py
Created November 21, 2024 09:07
Set environment from secret in Colab
!pip install set-env-colab-kaggle-dotenv
from set_env import set_env
set_env("GOOGLE_API_KEY")
set_env("WANDB_API_KEY")
@korakot
korakot / cred.js
Created July 31, 2024 11:56
2 ways to pass in Google credentials from Service Account info
let cred = JSON.parse(Deno.env.get("GOOGLE_APPLICATION_CREDENTIALS"));
// Big Query Style
export let bq = new BigQuery({ projectId, credentials: cred });
// Vertex Style
let vertex_ai = new VertexAI({ project: "kora-id", location: "us-central1",
googleAuthOptions: { credentials: cred } });
@korakot
korakot / secret.py
Created May 9, 2024 07:25
Google colab secret key userdata
from google.colab import userdata
key = userdata.get('MY_APY_KEY')
@korakot
korakot / suppress.py
Created February 19, 2024 09:27
Suppress stdout
import os
import sys
from contextlib import contextmanager
@contextmanager
def suppress_stdout():
with open(os.devnull, 'w') as devnull:
original_stdout = sys.stdout
sys.stdout = devnull
try:
@korakot
korakot / playwright.py
Created February 10, 2024 10:56
Using playwright in Google Colab
!pip install playwright
!playwright install
# colab need this for async
import nest_asyncio
nest_asyncio.apply()
# start browser, not to use 'with' context
from playwright.async_api import async_playwright
playwright = await async_playwright().start()
browser = await playwright.chromium.launch()
@korakot
korakot / prompt.md
Created February 8, 2024 11:04
ChatGPT Main Prompt

You are ChatGPT, a large language model trained by OpenAI, based on the GPT-4 architecture. Knowledge cutoff: 2023-04 Current date: 2024-02-07

Image input capabilities: Enabled

Tools

python

@korakot
korakot / requests.py
Last active January 27, 2024 05:15
Impersonate browser with curl_cffi requests
# see https://github.com/yifeikong/curl_cffi
from curl_cffi import requests
@korakot
korakot / claude_history.py
Created October 27, 2023 06:41
Use Claude API to get history
!pip install claude2
from claude import Claude
from fastcore.foundation import patch
from curl_cffi import requests
cookie = "sessionKey=sk-ant-sid01-4etj_0tI6RJKMbAAA"
claude = Claude(cookie)
@patch