Skip to content

Instantly share code, notes, and snippets.

View Jamlee's full-sized avatar
🎯
Focusing

JamLee Jamlee

🎯
Focusing
View GitHub Profile
@Jamlee
Jamlee / php-cs-fixer-pre-commit.php
Last active November 3, 2020 12:20 — forked from mardix/php-cs-fixer-pre-commit.php
Git: A pre-commit hook to make PHP code PSR-2 compliant, check for syntax error
#!/usr/bin/php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP error (lint), and make sure the code
* is PSR compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*
@Jamlee
Jamlee / generator-promise.js
Last active April 10, 2021 21:49
异步: promise, javascript 实现
var fs = require('fs');
var readFile = function (fileName){
return new Promise(function (resolve, reject){
fs.readFile(fileName, function(error, data){
if (error) reject(error);
resolve(data);
});
});
};
default: all
OUTDIR=out
CFLAGS=-g -Wall
INCLUDES=-I../src
# 测试依赖内容
OBJECTS=main.o adlist.o zmalloc.o
$(foreach i,$(OBJECTS),$(eval "$(OUTDIR)/$(subst .o,,$(i)).o:$(subst .o,,$(i)).c"))
@Jamlee
Jamlee / install.sh
Last active April 5, 2020 08:55
theia: cpp 配置, go 配置。目前还是测试版本
#!/bin/bash
prefix="/root/.theia-ide"
# go
snap install go --classic # 较新的版本
go get -u -v github.com/ramya-rao-a/go-outline
go get -u -v github.com/acroca/go-symbols
go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
@Jamlee
Jamlee / main.go
Created November 3, 2020 12:19
golang: exec 时继承父级进程数据
package main
import (
"fmt"
"golang.org/x/sys/unix"
"os"
"os/exec"
"syscall"
)
@Jamlee
Jamlee / yield-embed.php
Created July 9, 2021 08:16
PHP 中 yield:嵌套展平 yield 表达式
function stackedCoroutine(\Generator $gen)
{
$stack = new \SplStack;
$exception = null;
for (;;) {
try {
if ($exception) {
$gen->throw($exception);
$exception = null;
continue;
@Jamlee
Jamlee / exsi.sh
Last active May 22, 2022 16:32
hyper-v install ubtuntu cloud image
# usage
# ./exsi.sh 192.168.31.31 192.168.50.31
# apt install cloud-utils
hostname=$(echo $1 | sed s/\\./-/g)
{ echo instance-id: $hostname; echo local-hostname: $hostname; } > meta-data
cat > user-data <<EOF
#cloud-config
users:
- default
@Jamlee
Jamlee / fake_driver.c
Last active April 27, 2022 18:08
Linux 系统内核例子
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/of.h>
@Jamlee
Jamlee / reset.stp
Last active April 28, 2022 17:10
stap 脚本
#!/usr/bin/env stap
// Linux 172-19-0-11 5.4.0-109-generic #123-Ubuntu SMP Fri Apr 8 09:10:54 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
//tencent cloud centos 7.2 20220429
// tcp_send_active_reset 检测
probe kernel.statement("*@net/ipv4/tcp.c:2054") {
if (execname() == "node") {
printf("tcp_send_active_reset: %s\n", pp())
}
}
@Jamlee
Jamlee / README.md
Created April 23, 2023 11:33 — forked from oznu/README.md
QEMU + Ubuntu ARM aarch64

QEMU + Ubuntu ARM aarch64

These are the steps I used to get Ubuntu ARM aarch64 running with QEMU on OSX.

Get Ubuntu Image and QEMU EFI:

wget https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-arm64-uefi1.img
wget https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd