Skip to content

Instantly share code, notes, and snippets.

View googlefan256's full-sized avatar
๐Ÿ’ญ
Its Me! Googlefan.

googlefan256

๐Ÿ’ญ
Its Me! Googlefan.
View GitHub Profile
@googlefan256
googlefan256 / run.py
Created July 10, 2025 14:34
Mem-Agent
#!/usr/bin/env uv run --with openai,transformers,tqdm--script
from openai import AsyncOpenAI
from transformers import AutoTokenizer
from tqdm import tqdm
import argparse
parser = argparse.ArgumentParser(description="RL Memory Agent")
parser.add_argument(
"--api_base",
type=str,
@googlefan256
googlefan256 / main.py
Created July 2, 2025 02:45
DiffCoder 7Bใจไผš่ฉฑ
from transformers import AutoModel, AutoTokenizer
import torch
torch.backends.cudnn.benchmark = True
device = "cuda:0"
tokenizer = AutoTokenizer.from_pretrained(
"apple/DiffuCoder-7B-cpGRPO", trust_remote_code=True, device_map=device
)
model = AutoModel.from_pretrained(
@googlefan256
googlefan256 / main.rs
Created June 26, 2025 15:12
tinygrad in rust working example
use std::ffi::c_int;
fn inner() -> anyhow::Result<()> {
use tinygrad_in_rust::backend::cuda;
cuda::cuda_init("/usr/lib/x86_64-linux-gnu/libcuda.so")?;
cuda::nvrtc_init("/usr/local/cuda/lib64/libnvrtc.so")?;
cuda::nvjitlink_init("/usr/local/cuda/lib64/libnvJitLink.so")?;
let res = cuda::CuCompiler::new_default()?.compile(
r#"
extern "C" __global__ void add(int *a, int *b, int *c, int size) {
def ai(prompt: str):
from google import genai
client = genai.Client(api_key="")
response = client.models.generate_content(
model="gemini-2.5-flash-lite-preview-06-17",
contents=f"Write a python3 code only, no explanation. {prompt}"
)
code = response.text
if code.startswith("```python"):
code = code.removeprefix("```python").strip()
@googlefan256
googlefan256 / main.py
Created May 23, 2025 04:57
Qwen3 0.6B with tinygrad.
from tinygrad import Tensor, nn, dtypes, TinyJit, Variable, Context
from tinygrad.dtype import DType
from transformers import AutoTokenizer
from typing import Tuple, Optional, List, Dict, Generator
from huggingface_hub import hf_hub_download
import time
from tqdm import tqdm
Tensor.no_grad = True
package commandparser
import (
"encoding/json"
"errors"
"fmt"
"regexp"
"strings"
)
ใƒ—ใƒญใƒณใƒ—ใƒˆ:
ใ‚ใชใŸใฏๆ–™็†็•ช็ต„ใฎๅธไผš่€…ใงใ™ใ€‚ไปŠๆ—ฅใฎใƒ†ใƒผใƒžใฏใ€Œ่ชฐใ‚‚ใŒ้ฉšใ็ฐกๅ˜ใง่ฑช่ฏใชใƒ‡ใ‚ฃใƒŠใƒผใ€ใ€‚้™ใ‚‰ใ‚ŒใŸ้ฃŸๆใง็ฐกๅ˜ใซไฝœใ‚Œใ‚‹่ฑช่ฏใชๆ–™็†ใ‚’็ดนไป‹ใ—ใ€่ฆ–่ด่€…ใซใ€Œใ“ใ‚“ใช็ฐกๅ˜ใง็พŽๅ‘ณใ—ใ„ๆ–™็†ใŒใ‚ใ‚‹ใชใ‚“ใฆ๏ผใ€ใจๆ€ใ‚ใ›ใ‚‹่ชฌๆ˜Žใ‚’ใ—ใพใ—ใ‚‡ใ†ใ€‚ ๆ–™็†ใฎ้Ž็จ‹ใงใ€ๆ™‚ๆŠ˜่ฆ–่ด่€…ใซใ‚ฏใ‚คใ‚บใ‚’ๅ‡บใ—ใŸใ‚Šใ€็ฐกๅ˜ใชๆ–™็†ใฎใ‚ณใƒ„ใ‚’ๆ•™ใˆใŸใ‚Šใ™ใ‚‹ใชใฉใ—ใฆใ€่ฆ–่ด่€…ใฎๅ‚ๅŠ ๆ„่ญ˜ใ‚’้ซ˜ใ‚ใ€ไธ€็ท’ใซๆ–™็†ใ‚’ๆฅฝใ—ใ‚ใ‚‹ใ‚ˆใ†ใช้›ฐๅ›ฒๆฐ—ใ‚’็››ใ‚ŠไธŠใ’ใฆใใ ใ•ใ„ใ€‚ ๅ…ทไฝ“็š„ใซใฉใ‚“ใชๆ–™็†ใ‚’็ดนไป‹ใ™ใ‚‹ใ‹ใ€ใ‚ฏใ‚คใ‚บใฎๅ†…ๅฎนใ€ๆ–™็†ใฎใ‚ณใƒ„ใชใฉใ€่ฉณใ—ใๆ•™ใˆใฆใใ ใ•ใ„ใ€‚
ใƒ™ใƒผใ‚นใƒขใƒ‡ใƒซ:
ๆ–™็†๏ผšใŠใ‚ใ—้‡Ž่œใจ้ญš็ฒ‰ใฎใ‚ฟใƒ
* ็ฐกๅ˜ใซไฝœใ‚Œใ€ๆ „้คŠๆบ€็‚นใชๆ–™็†ใงใ™ใ€‚
* ๆ™‚้–“ๅˆถ้™ใฏ็Ÿญใใ€ๅฎถๆ—ใ‚„ๅ‹ไบบใจ็ฐกๅ˜ใซไธ€็ท’ใซไฝœใ‚‹ใ“ใจใŒใงใใพใ™ใ€‚
ใ‚ฏใ‚คใ‚บ๏ผš
@googlefan256
googlefan256 / Makefile
Created October 22, 2023 08:48
tiny-python
FROM gcr.io/distroless/python3 AS distroless
FROM scratch
COPY --from=distroless /lib/x86_64-linux-gnu/libpthread.so.0 /lib/x86_64-linux-gnu/libpthread.so.0
COPY --from=distroless /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libdl.so.2
COPY --from=distroless /lib/x86_64-linux-gnu/libutil.so.1 /lib/x86_64-linux-gnu/libutil.so.1
COPY --from=distroless /lib/x86_64-linux-gnu/libm.so.6 /lib/x86_64-linux-gnu/libm.so.6
COPY --from=distroless /lib/x86_64-linux-gnu/libexpat.so.1 /lib/x86_64-linux-gnu/libexpat.so.1
COPY --from=distroless /lib/x86_64-linux-gnu/libz.so.1 /lib/x86_64-linux-gnu/libz.so.1
COPY --from=distroless /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6
COPY --from=distroless /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2
@googlefan256
googlefan256 / gas.js
Created September 3, 2022 13:53
Gasใงgoogle translateใ‚’่‡ชๅ‹•่จ€่ชžๆคœ็Ÿฅใ‚ใ‚Šใงไฝฟใˆใ‚‹ใ‚„ใคใงใ™
function translate(text, from = "auto", to) {
try {
const result = UrlFetchApp.fetch(
"https://translate.google.com/_/TranslateWebserverUi/data/batchexecute",
{
payload:
"f.req=" +
encodeURIComponent(
JSON.stringify([
[