Skip to content

Instantly share code, notes, and snippets.

View ckaznable's full-sized avatar
🐦
Free Bird ya~

ckaznable ckaznable

🐦
Free Bird ya~
View GitHub Profile
@ckaznable
ckaznable / gist:b8f175f4237815629bdf21e8cd018b6a
Last active October 3, 2024 07:15
specific ip pass by l2tp vpn
nmcli con add \
type vpn \
vpn-type l2tp \
con-name "My L2TP VPN" \
ifname "" \
vpn.data "gateway=VPN_SERVER_IP,
user=YOUR_USERNAME,
password-flags=1,
ipsec-enabled=yes,
ipsec-psk=YOUR_PRESHARED_KEY"
@ckaznable
ckaznable / .gitignore
Created April 17, 2024 07:19 — forked from iffy/.gitignore
Example using electron-updater with `generic` provider.
node_modules
dist/
yarn.lock
wwwroot
@ckaznable
ckaznable / Makefile
Created January 4, 2024 03:12 — forked from jlgerber/Makefile
simple makefile for rust projects
prog :=xnixperms
debug ?=
$(info debug is $(debug))
ifdef debug
release :=
target :=debug
extension :=debug
@ckaznable
ckaznable / publish.yml
Created August 3, 2023 07:08 — forked from umanghome/publish.yml
GitHub Action: Generate a build and push to another branch
# .github/workflows/publish.yml
name: Generate a build and push to another branch
on:
push:
branches:
- master # Remove this line if your primary branch is "main"
- main # Remove this line if your primary branch is "master"
jobs:
@ckaznable
ckaznable / tokio-internals.md
Created April 17, 2023 12:07 — forked from weihanglo/tokio-internals.md
【譯】Tokio 內部機制:從頭理解 Rust 非同步 I/O 框架

本文譯自 [Tokio internals: Understanding Rust's asynchronous I/O framework from the bottom up][tokio-internals]。
Thanks [David Simmons][david-simmons] for this awesome article!

[Tokio][tokio] 是 Rust 的開發框架,用於開發非同步 I/O 程式(asynchronous I/O,一種事件驅動的作法,可實現比傳統同步 I/O 更好的延伸性、效能與資源利用)。可惜的是,Tokio 過於精密的抽象設計,招致難以學習的惡名。即使我讀完教程後,依然不認為自己充分內化這些抽象層,以便推斷實際發生的事情。

從前的非同步 I/O 相關開發經驗甚至阻礙我學習 Tokio。我習慣使用作業系統提供的 selection 工具(例如 Linux epoll)當作起點,再轉移至 dispatch、state machine 等等。倘若直接從 Tokio 抽象層出發,卻沒有清楚了解 epoll_wait() 在何處及如何發生,我會覺得難以連結每個概念。Tokio 與 future-driven 的方法就好像一個黑盒子。

@ckaznable
ckaznable / hugo-auto-deoply.yml
Created February 10, 2023 08:59 — forked from lisez/hugo-auto-deoply.yml
如何使用 Github Actions 自動部署 Hugo
# link: https://sujingjhong.com/posts/how-to-deploy-hugo-automatically-with-github-actions/
# author: lisez <[email protected]>
name: Auto publish to public site
# 只有推送到 master 才自動化
on:
push:
branches:
- master
@ckaznable
ckaznable / simple_chat.rs
Created February 10, 2023 05:41 — forked from andelf/simple_chat.rs
Simple Socket Chat Server in Rust. (TcpListener, TcpStream, SharedChan, RWArc)
extern mod sync;
// str op trait
use std::str::StrSlice;
// for tcp listen
use std::io::{TcpListener, TcpStream};
use std::io::net::ip::SocketAddr;
// for trait
use std::io::{Listener, Writer, Acceptor, Buffer};
// for spawn
@ckaznable
ckaznable / middleware.ts
Created February 2, 2023 02:23
rewrite old php endpoint to nextjs
import { NextRequest, NextResponse } from "next/server"
export function middleware(req: NextRequest) {
const url = req.nextUrl
// redirect php path
if (url.pathname.endsWith(".php")) {
url.pathname = url.pathname.replace("index.php", "").replace(".php", "")
return NextResponse.rewrite(url)
}
@ckaznable
ckaznable / index.html
Created January 6, 2023 09:57 — forked from mcxiaoke/index.html
detect app installed in browser
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>App Redirection</title>
</head>
<body>
<!-- iframe used for attempting to load a custom protocol -->
<iframe style="display:none" height="0" width="0" id="loader"></iframe>
@ckaznable
ckaznable / CI.yml
Last active February 28, 2023 05:26 — forked from Tehnix/CI.yml
Ready to use Github workflow for cross-compiling a rust binary to many Linux architectures.
name: CI
on:
pull_request:
paths:
- 'src/**'
- 'Cargo.*'
- '.github/workflows/**'
push:
branches: