Skip to content

Instantly share code, notes, and snippets.

@imweijh
imweijh / llama_grok3.mak
Created April 18, 2025 01:38
让grok3,参考此skeeto的llama.cpp Makefile,添加llama-cli.exe的构建
# llama.cpp server, CLI, and DLL build (CPU inference only)
#
# llama.cpp is an amazing project, but its build system is poor and
# growing worse. It's never properly built llama.dll under any compiler,
# and DLL builds have been unsupported by w64dk for some time. This
# makefile is a replacement build system that produces llama.dll,
# llama-server.exe, and llama-cli.exe using w64dk. No source file changes
# are needed.
#
# The DLL exports the public API and no more, and is readily usable as a
@imweijh
imweijh / gist:13025f6c020878e455be1e7ebc1583fb
Created March 26, 2025 13:14
Your new compiler will be at ~/gcc10/bin/gcc
sudo apt install -y curl build-essential libgmp-dev libmpfr-dev libmpc-dev
mkdir /tmp/$$ && cd /tmp/$$
curl -s https://ftp.gnu.org/gnu/gcc/gcc-10.3.0/gcc-10.3.0.tar.xz | tar xJ
mkdir build && cd build
../gcc-10.3.0/configure --prefix=$HOME/gcc10 \
--disable-dependency-tracking \
--disable-nls \
--disable-multilib \
--enable-default-pie \
--enable-languages=c,c++
@imweijh
imweijh / .gitconfig
Created March 12, 2025 00:30 — forked from Kovrinic/.gitconfig
git global url insteadOf setup
# one or the other, NOT both
[url "https://github"]
insteadOf = git://github
# or
[url "[email protected]:"]
insteadOf = git://github
@imweijh
imweijh / README.md
Created December 25, 2024 14:21 — forked from liviaerxin/README.md
FastAPI and Uvicorn Logging #python #fastapi #uvicorn #logging

FastAPI and Uvicorn Logging

When running FastAPI app, all the logs in console are from Uvicorn and they do not have timestamp and other useful information. As Uvicorn applies python logging module, we can override Uvicorn logging formatter by applying a new logging configuration.

Meanwhile, it's able to unify the your endpoints logging with the Uvicorn logging by configuring all of them in the config file log_conf.yaml.

Before overriding:

uvicorn main:app --reload
@imweijh
imweijh / install_pyenv.md
Created August 7, 2024 02:06 — forked from trongnghia203/install_pyenv.md
Install pyenv
@imweijh
imweijh / add_index_to_all_dirs.sh
Created July 29, 2024 06:12 — forked from corysolovewicz/add_index_to_all_dirs.sh
Recursively create an empty index.html file in all directories which currently do not have one.
# run this command in the root web directory
find . -type d -exec touch {}/index.html \;
@imweijh
imweijh / demo.rb
Created May 24, 2024 14:01 — forked from lukeholder/demo.rb
How to connect to Microsoft SQL Server with jruby on Windows using JDBC and Sequel Gem
require "java"
require "rubygems"
require "sequel"
require "sqljdbc4.jar" #this files path may need to be relevate to file location
DB = Sequel.connect(
:adapter => "jdbc",
:url => "jdbc:sqlserver://doric-server5;database=ADCData_Doric;integratedSecurity=true"
# This is using integrated security, might want to pass username and password
# More Info at http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html
@imweijh
imweijh / logstash.conf
Last active November 6, 2023 07:44
logstash配置,在某个时间段,加tags,比如只在此时间段内才记录全量日志
input {
generator {
lines => [
"line 1",
"line a"
]
count => 1
}
}
@imweijh
imweijh / nginx.conf
Created September 28, 2023 08:13 — forked from morhekil/nginx.conf
Full request/response body logging in nginx
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '
@imweijh
imweijh / logstash-to-logstash-over-http.md
Created August 14, 2023 10:38 — forked from yaauie/logstash-to-logstash-over-http.md
2022 high-level docs for logstash-to-logstash using the HTTP input/output pair

We have had some success using LS-to-LS over HTTP(S), which supports an HTTP(s) Load Balancer or Proxy in the middle, and can be secured with TLS/SSL. It can be made to be quite performant, but doing so requires some specific tuning.

Upstream (HTTP Output)

The upstream pipelie would contain a single HTTP output plugin aimed either directly at a downstream Logstash or at a Load Balancer, importantly configured with:

  • format => json_batch (for performance; without this one event will be sent at a time) and
  • retry_non_idempotent => true (for resilience; without this, some failures cannot be safely retried).

Depending on whether we ar sending directly to another Logstash or through an SSL-terminating Load Balancer or proxy, the output may need to be configured

  • with HTTP Basic credentials (user/password),