Skip to content

Instantly share code, notes, and snippets.

View wenerme's full-sized avatar
🎯
Focusing

陈杨文 wenerme

🎯
Focusing
View GitHub Profile
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.DisplayMode;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.Polygon;
import java.awt.Rectangle;
@wenerme
wenerme / BenchGRPCOOME.java
Last active November 18, 2015 01:21
BenchGRPCOOME
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.Server;
import io.grpc.ServerBuilder;
import io.grpc.stub.StreamObserver;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.BenchmarkParams;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.infra.IterationParams;
@wenerme
wenerme / CommitLogReader.java
Last active January 21, 2016 02:12
RocketMQ commit log reader
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
@wenerme
wenerme / show-stars.js
Last active November 30, 2021 10:36
Show stars and push time in github repo links.
var AccessToken='YOUR-ACCESS-TOKEN-HERE' // <= Notice
var replaceText = (a) => {
let v = a.repoData;
let tpl = `[
<span style="color:red;opacity:${Math.max(v.stargazers_count / 500, 0.1)}">
★${v.stargazers_count}
</span>
🕐${new Date(v.updated_at)
.toISOString()
.replace(/\..*/, "")
@wenerme
wenerme / hardware-summary
Created January 3, 2017 06:22
Ubuntu 16.04.1 install failed
uname -a: Linux wener-ubuntu 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 GNU/Linux
lspci -knn: 00:00.0 Host bridge [0600]: Intel Corporation 440FX - 82441FX PMC [Natoma] [8086:1237] (rev 02)
lspci -knn: 00:01.0 ISA bridge [0601]: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II] [8086:7000]
lspci -knn: 00:01.1 IDE interface [0101]: Intel Corporation 82371AB/EB/MB PIIX4 IDE [8086:7111] (rev 01)
lspci -knn: Kernel driver in use: ata_piix
lspci -knn: 00:02.0 VGA compatible controller [0300]: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter [80ee:beef]
lspci -knn: 00:03.0 Ethernet controller [0200]: Intel Corporation 82540EM Gigabit Ethernet Controller [8086:100e] (rev 02)
lspci -knn: Subsystem: Intel Corporation Device [8086:001e]
lspci -knn: Kernel driver in use: e1000
lspci -knn: Kernel modules: e1000
@wenerme
wenerme / pre-commit-eslint
Last active January 24, 2019 02:22 — forked from linhmtran168/pre-commit-eslint
Pre-commit hook to check for Javascript using ESLint
#!/bin/sh
# List files
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
# Try find node
@wenerme
wenerme / icmp_ping.py
Created December 4, 2019 06:35 — forked from ageis/icmp_ping.py
Ansible ICMP ping module
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# (c) 2019, Ansible by Red Hat, inc
# (c) 2019 Kevin Gallagher (@ageis) <kevingallagher@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# from https://gist.github.com/ageis/face10be67b26e4519662e19290e06ff
# fix for busybox and macos
@wenerme
wenerme / k3s-new-cert.sh
Created July 12, 2020 06:12
K3S Create Client Cert
#!/bin/bash
set -e
fail(){
echo "error: $*"
echo "usage: ./k3s-new-cert <name> [subject=/O=admin]"
exit 1
}
@wenerme
wenerme / alpine-netboot-missing-ext4-verify.sh
Last active October 22, 2020 18:27
AlpineLinux netboot initrd missing ext4 module
# download firecracker
latest=$(basename $(curl -fsSLI -o /dev/null -w %{url_effective} https://github.com/firecracker-microvm/firecracker/releases/latest))
curl -LOJ https://github.com/firecracker-microvm/firecracker/releases/download/${latest}/firecracker-${latest}-$(uname -m)
mv firecracker-${latest}-$(uname -m) firecracker
chmod +x firecracker
# download netbook kernel and initrd
curl --remote-name-all -LC- https://mirrors.aliyun.com/alpine/v3.12/releases/x86_64/netboot/{modloop,vmlinuz,config,initramfs}-virt
# vmlinux
@wenerme
wenerme / boot-alpine-in-firecracker.sh
Last active June 14, 2023 14:51
AlpineLinux Firecracker
# download
latest=$(basename $(curl -fsSLI -o /dev/null -w %{url_effective} https://github.com/firecracker-microvm/firecracker/releases/latest))
curl -LOJ https://github.com/firecracker-microvm/firecracker/releases/download/${latest}/firecracker-${latest}-$(uname -m)
mv firecracker-${latest}-$(uname -m) firecracker
chmod +x firecracker
# rootfs
# =========
# qemu-img create -f raw alpine.rootfs.ext4 1G
fallocate -l 1G ubuntu.rootfs.ext4