Skip to content

Instantly share code, notes, and snippets.

View abserari's full-sized avatar
🐱
Let's build a better world

DingRui Yang abserari

🐱
Let's build a better world
View GitHub Profile
import qrcode
from qrcode.util import *
def hack_put(self, num, length):
if num == 0:
num = 233 # make a fake length
for i in range(length):
self.put_bit(((num >> (length - i - 1)) & 1) == 1)
qrcode.util.BitBuffer.put = hack_put
@ljyloi
ljyloi / test.cu
Last active July 28, 2022 08:41
用来测试 gpu 的简单 cuda 代码
// a program doing matrix multiplication with gpu, which could be use to test if gpu monitor really works
// use nvcc to complile
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <random>
#include <stdexcept>
@fengyfei
fengyfei / main.go
Created June 23, 2022 10:11
[Go] Sudo execution
package main
import (
"bytes"
"io"
"log"
"os/exec"
"strings"
"sync"
"time"
@abserari
abserari / MySQL.go
Last active January 11, 2021 13:47
Pub/Sub Pattern realized by SQL database;
package main
import (
"bytes"
stdSQL "database/sql"
"encoding/gob"
"fmt"
"strings"
"time"
@android10
android10 / oh-my-zsh-powerlevel9k-theme.md
Last active June 26, 2024 00:21
oh-my-zsh with PowerLevel9k on Arch Linux

Attention: This is DEPRECATED in favor of PowerLevel10K, I wrote an article about it:

Install oh-my-zsh with powerlevel9k theme on Arch Linux

This gist aims to facilitate the switching from bash to zsh as our defaut shell. We will be using oh-my-zsh with the powerful theme: Powerlevel9k. You will find all the links below. This process applies mainly for Arch Linux, but can be setup for any other distro (in theory :)). I'm also using Gnome Terminal and pacaur as package manager.

@adaroobi
adaroobi / vb-guest-additions.sh
Last active June 27, 2022 16:57
Install Oracle VirtualBox Guest additions via terminal CentOS7
# Find the appropriate version here http://download.virtualbox.org/virtualbox/
sudo VBOX_VERSION=6.0.4
sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/d/dkms-2.6.1-1.el7.noarch.rpm
sudo yum -y install wget perl gcc dkms kernel-devel kernel-headers make bzip2
wget http://download.virtualbox.org/virtualbox/${VBOX_VERSION}/VBoxGuestAdditions_${VBOX_VERSION}.iso
sudo mkdir /media/VBoxGuestAdditions
@Akagi201
Akagi201 / go-mod.md
Created December 17, 2018 02:27
[go-mod]

go mod 项目管理

go 1.11 有了对模块的实验性支持,大部分的子命令都知道如何处理一个模块,比如 run build install get list mod 子命令,第三方工具可能会支持的晚一些。

到 go 1.12 会删除对 GOPATH 的支持,go get 命令也会变成只能获取模块,不能像现在这样直接获取一个裸包。

可以用环境变量 GO111MODULE 开启或关闭模块支持,它有三个可选值:off、on、auto,默认值是 auto。

开启go mod机制

请选择go1.11以上版本

@hellokaton
hellokaton / README.md
Last active March 29, 2024 02:33
Go 的信号处理和优雅退出

每个平台的信号定义或许有些不同。下面列出了POSIX中定义的信号。 Linux 使用34-64信号用作实时系统中。 命令man 7 signal提供了官方的信号介绍。

在POSIX.1-1990标准中定义的信号列表

@superseb
superseb / kubectl.yml
Created May 18, 2018 20:07
Rancher 2.0 nfs-provisioner
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: nfs-provisioner
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: nfs-provisioner-runner
@michaelboke
michaelboke / Dockerfile
Last active June 26, 2024 14:46
Docker scratch x509 fix
FROM golang:alpine as builder
WORKDIR /app
RUN apk update && apk upgrade && apk add --no-cache ca-certificates
RUN update-ca-certificates
ADD main.go /app/main.go
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags="-s -w" -installsuffix cgo -o app .
FROM scratch
COPY --from=builder /app/app .
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/