Skip to content

Instantly share code, notes, and snippets.

View diyism's full-sized avatar

Malcolm Ke Win diyism

View GitHub Profile
@diyism
diyism / docker-run-gui-app.sh
Last active July 13, 2024 10:54
[Docker] Run GUI application inside Docker container
# Run Docker container with latest Ubuntu and pass DISPLAY
$ docker run --net=host --env="DISPLAY" --volume="$XAUTHORITY:/root/.Xauthority:rw" -it ubuntu
$ xhost +local:root #允许Docker容器访问X服务器
# Install simple GUI applications for test
$ apt update && apt install -y x11-apps
# Run GUI application 'calculator'
$ xcalc
@diyism
diyism / udp over http post with python and golang.txt
Last active May 6, 2024 09:16
udp over http post with python and golang
llama3-70b-8192的翻译是有问题的, 会导致1024字节缓冲区的后半段数据(下一个udp包的不完整前半部)作为一个udp包发送
claude-3-opus-20240229的翻译 性能好于 gpt-4-turbo-2024-04-09的翻译
=================================python gpt4 生成 65行============================================================
import aiohttp
from aiohttp import web
import socket
import base64
import asyncio
@diyism
diyism / directly call libcronet.so from cronet-go.txt
Created December 8, 2023 03:04
directly call libcronet.so from cronet-go
ref: https://github.com/sleeyax/cronet-binaries/issues/1
package main
import (
"net/http"
"os"
"github.com/sagernet/cronet-go"
)
### Keybase proof
I hereby claim:
* I am diyism on github.
* I am diyism (https://keybase.io/diyism) on keybase.
* I have a public key whose fingerprint is 11A9 8349 5D23 9308 4FF7 772A 098B 48D8 50FB 1759
To claim this, I am signing this object:
@diyism
diyism / fileserver.py
Created November 23, 2023 08:30
phus.lu fileserver.py
"""
curl phus.lu/fileserver.py | env PORT=8001 python
"""
import os
import re
import sys
import time
try:
from http.server import SimpleHTTPRequestHandler, HTTPServer
@diyism
diyism / rclone.conf for chunker over blomp swift.txt
Last active January 4, 2024 01:11
rclone.conf for chunker over blomp swift
rclone.conf:
[blomp]
type = swift
user = i@gmail.com
key = 123456
auth = https://authenticate.blomp.com
tenant = storage
auth_version = 2
no_chunk = true
# Install dependencies "pip install youtube_transcript_api langchain"
# Run with "OPENAI_API_KEY=xxxx python summarize.py <youtube_id>"
import sys
from youtube_transcript_api import YouTubeTranscriptApi
from langchain import OpenAI, PromptTemplate
from langchain.text_splitter import TokenTextSplitter
from langchain.prompts import PromptTemplate
@diyism
diyism / svg non-scaling-stroke.txt
Last active December 14, 2022 16:59
svg non-scaling-stroke
<html><head>
<style>
#svgContainer {
background-color: #dedede;
}
#svgZoom {
transform-origin: 0% 0%;
}
</style>
@diyism
diyism / playwright-go.txt
Last active May 29, 2023 08:03
playwright-go
# how to work in kali/debian/ubuntu22.04(jammy), ref: https://gist.github.com/diyism/4b892a4339f35561dd2ec48158a8c75d
# the playwright in playwright-go currently only supports ubuntu 20.04(focal)
$ sudo singularity build -s ubuntu_focal/ docker://ubuntu:focal
$ sudo singularity shell --writable ubuntu_focal/
$ pwd // /root
$ mkdir WorkSpace_sing_ubuntu_focal
$ cd WorkSpace_sing_ubuntu_focal
$ apt update
@diyism
diyism / x11docker (linux sanbox like android shelter app)
Last active July 13, 2024 10:57
x11docker (linux sanbox like android shelter app)
========update============
不需要x11docker, 更简单的方法, 直接允许容器访问host的X server:
https://gist.github.com/diyism/8f0d4b1cdfc4e9d0839927e78c90a327
=========================
"现在有很多国产linux程序了,比如 钉钉/飞书,
则linux上也有了隔离国产程序的需求,
试了1.virtualbox, 2.firejail, 3.docker theasp/novnc,
都不够方便实用, 最好用启动单个程序最快的是x11docker
@_:10个我离不开的android应用: