Skip to content

Instantly share code, notes, and snippets.

View nanmu42's full-sized avatar

Zhennan LI nanmu42

View GitHub Profile
@usr-ein
usr-ein / Dockerfile
Last active May 2, 2024 10:55
Optimal multistaged Dockerfile for poetry
# syntax=docker/dockerfile:1
# Keep this syntax directive! It's used to enable Docker BuildKit
# Based on https://github.com/python-poetry/poetry/discussions/1879?sort=top#discussioncomment-216865
# but I try to keep it updated (see history)
################################
# PYTHON-BASE
# Sets up all our shared environment variables
################################
@moyix
moyix / CodeGen_GPTJ_Conversion.md
Last active January 5, 2024 12:50
How to convert the SalesForce CodeGen models to GPT-J

Using Linear Algebra to Convert a Large Code Model

Background

The SalesForce CodeGen models are a family of large language models trained on a large amount of natural language data and then fine-tuned on specialized datasets of code. Models of size 350M, 2B, 6B, and 16B parameters are provided in three flavors:

  • nl, the base model trained on The Pile, a large natural language dataset compiled by EleutherAI
  • multi, which is fine-tuned from the nl model on a dataset of code in multiple languages, scraped from GitHub, and
  • mono, which is fine-tuned from the multi model on Python code only.
@nanmu42
nanmu42 / Flink: throttle messages to walkaround deadlock under heavy iteration feedback load.md
Last active October 11, 2021 11:15
Flink: throttle messages to walkaround deadlock under heavy iteration feedback load
@xykong
xykong / k8sdump.sh
Last active January 14, 2024 15:19
Export Kubernetes cluster resource to yaml.
#!/usr/bin/env bash
readonly SCRIPT=$(basename "$0")
readonly VERSION='1.0.0'
readonly AUTHOR='xy.kong@gmail.com'
readonly SOURCE='https://gist.github.com/xykong/6efdb1ed57535d18cb63aa8e20da3f4b'
# For script running robust
set -o nounset # to exit when your script tries to use undeclared variables
set -o errexit # to make your script exit when a command fails
@phlinhng
phlinhng / a-clash-tproxy-gateway.md
Last active March 27, 2024 22:07
Clash as transparent proxy gateway via TPROXY

Notes

  1. If your local network use public IP ranges instead of private ones, make sure to add respecive RETURN rules to iptables to prevent looping issue
  2. Set clash as DHCP's only DNS server to allow domain-based filter (shunting) rules work
  3. Use lsof -i udp:53 to check if clash's DNS module work fine, otherwise you may have to kill systemd-resolved and any other processes occupying the UDP 53 port
  4. The given scripts will NOT hangle the traffic of gateway itself since it is not recommend to do so. If you want to redirect the egress traffic of the gateway, the following material may be useful

Reference

@nanmu42
nanmu42 / fileserver.go
Created March 6, 2021 03:48
Golang Quick Static File Server
package main
import (
"flag"
"fmt"
"net"
"net/http"
)
var (
@sleeyax
sleeyax / go2c.md
Last active February 21, 2024 18:31
CGO <-> C conversions list
Type C Call method Go type Bytes (byte) Numerical range
char C.char byte 1 -128~127
signed char C.schar int8 1 -128~127
unsigned char C.uchar uint8 1 0~255
short int C.short int16 2 -32768~32767
short unsigned int C.ushort uint16 2 0~65535
int C.int int 4 -2147483648~2147483647
unsigned int C.uint uint32 4 0~4294967295
long int C.long int32 or int64 4 -2147483648~2147483647
@madkoding
madkoding / install-docker-deepin.sh
Last active May 9, 2024 17:08
Install Docker-CE script for Deepin Linux
#!/bin/bash
echo "Starting Docker installation on Deepin Linux..."
# Define a mapping from Deepin version to Debian version
map_deepin_to_debian() {
if [ "$1" -lt 20 ]; then
echo "stretch"
elif [ "$1" -ge 20 ]; then
echo "buster"
@nanmu42
nanmu42 / openinbrowser.go
Created May 20, 2019 09:43
Golang: Open URL in Browser
func openBrowser(url string) {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
@nanmu42
nanmu42 / Dockerfile
Last active July 27, 2023 10:18
Minimal-sized Golang Docker Image
FROM golang:1-alpine as golang
RUN apk --no-cache add git zip tzdata ca-certificates
# avoid go path, use go mod
WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 go build -ldflags "-s -w -extldflags "-static"" ./cmd/appnamehere
WORKDIR /usr/share/zoneinfo
# -0 means no compression. Needed because go's
# tz loader doesn't handle compressed data.
RUN zip -r -0 /zoneinfo.zip .