Skip to content

Instantly share code, notes, and snippets.

View xdays's full-sized avatar
🏠
Working from home

Xiangjun Zhang xdays

🏠
Working from home
View GitHub Profile
@adrienbrault
adrienbrault / llama2-mac-gpu.sh
Last active April 22, 2024 08:47
Run Llama-2-13B-chat locally on your M1/M2 Mac with GPU inference. Uses 10GB RAM. UPDATE: see https://twitter.com/simonw/status/1691495807319674880?s=20
# Clone llama.cpp
git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
# Build it
make clean
LLAMA_METAL=1 make
# Download model
export MODEL=llama-2-13b-chat.ggmlv3.q4_0.bin
@CHIZI-0618
CHIZI-0618 / PuerNya_sing-box_fakeip_client_config.jsonc
Last active April 28, 2024 06:14
sing-box 带有 Proxy Providers 的客户端配置示例
{
"log": {
"level": "info",
"output": "sing-box.log",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "cloudflare",
@geerlingguy
geerlingguy / increase-pci-bar-space.sh
Last active January 15, 2024 22:17
Increase the BAR memory address space for PCIe devices on the Raspberry Pi Compute Module 4
#!/bin/bash
# The default BAR address space available on the CM4 may be too small to allow
# some devices to initialize correctly. To avoid 'failed to assign memory'
# errors on boot, you can increase the range of the PCIe bus in the Raspberry
# Pi's Device Tree (a .dtb file specific to each Pi model).
#
# You should probably read up on Device Trees if you don't know what they are:
# https://www.raspberrypi.org/documentation/configuration/device-tree.md
#

Erlang honors cgroup CPU quota from Erlang 23. But when less than 1 CPU is used, schedulers_online will be cores number(see below k8s 0-5).

docker

$ docker run --rm -it --cpu-period 100000 --cpu-quota 100000 erlang:23 bash
root@3f793576001a:/# erl
Erlang/OTP 23 [erts-11.0.2] [source] [64-bit] [smp:4:1] [ds:4:1:10] [async-threads:1] [hipe]
@krisleech
krisleech / renew-gpgkey.md
Last active April 22, 2024 20:13
Renew Expired GPG key

Renew GPG key

Given that your key has expired.

$ gpg --list-keys
$ gpg --edit-key KEYID

Use the expire command to set a new expire date:

@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@joer14
joer14 / rds_download_log.py
Last active March 8, 2024 08:34
workaround for downloading rds logs via the AWS REST interface. This uses the IAM credentials for the session so should 'just work' on a lambda without needing to hardcode credentials/pass them in via environmental variables etc.
"""
Craft a web request to the AWS rest API and hit an endpoint that actually works but isn't supported in the CLI or in Boto3.
Based on this: https://github.com/aws/aws-cli/issues/2268#issuecomment-373803942
"""
import boto3
import os
import sys, os, base64, datetime, hashlib, hmac, urllib
import requests
{
"stats": {},
"api": {
"services": [
"StatsService"
],
"tag": "api"
},
"policy": {
"levels": {
@aunyks
aunyks / snakecoin-server-full-code.py
Last active March 8, 2024 19:22
The code in this gist isn't as succinct as I'd like it to be. Please bare with me and ask plenty of questions that you may have about it.
from flask import Flask
from flask import request
import json
import requests
import hashlib as hasher
import datetime as date
node = Flask(__name__)
# Define what a Snakecoin block is
class Block:
import hashlib as hasher
import datetime as date
# Define what a Snakecoin block is
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
self.data = data
self.previous_hash = previous_hash