Skip to content

Instantly share code, notes, and snippets.

@adrienbrault
adrienbrault / llama2-mac-gpu.sh
Last active April 8, 2025 13:49
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
import inspect
from functools import wraps
import openai
def generate_code(signature, docstring):
init_prompt = "You are a Python expert who can implement the given function."
definition = f"def {signature}"
prompt = f"Read this incomplete Python code:\n```python\n{definition}\n```"
@Linusp
Linusp / finance.py
Last active January 10, 2021 07:32
计算达到资产目标需要多少年
import click
@click.command()
@click.option("--age", type=int, default=24, help="你当前的年龄")
@click.option("--asset", type=float, default=0, help="上一年年末总资产")
@click.option("--salary", type=float, default=200000, help="预计今年年工作收入")
@click.option("--salary-rate", type=float, default=0.1, help="预计工作收入年增长率")
@click.option("--invest", type=float, default=10000, help="预计今年投资收入")
@click.option("--invest-rate", type=float, default=0.1, help="预计投资收入年增长率")
@click.option("--expense", type=float, default=90000, help="预计今年支出")
@Linusp
Linusp / sunburst.py
Last active March 24, 2025 17:42
Sunburst chart with matplotlib
import matplotlib.pyplot as plt
plt.style.use('ggplot')
plt.rcParams['font.sans-serif'] = ['WenQuanYi Micro Hei']
plt.rcParams['legend.fontsize'] = 14
group_names = ['不依赖其他条目', '依赖其他条目']
group_size = [24, 40]
subgroup_names = ['', '1个', '2个', '3个', '4个', '5个', '9个', '13个']
subgroup_size = [24, 15, 13, 5, 3, 2, 1, 1]
@chriselsner
chriselsner / nix-on-macos-catalina.md
Last active October 19, 2025 12:44
Nix on macOS Catalina

Nix on macOS Catalina

I'm writing this gist for my own records but it might help someone else too.

Installing Nix

Support for Catalina has improved a lot since the update was first rolled out.

Note: See the NixOS manual for discussion of the --darwin-use-unencrypted-nix-store-volume option.

@iwinux
iwinux / barely-tweaks.js
Last active May 28, 2018 02:23
UI / UX Tweaks for BearyChat
// ==UserScript==
// @name barely-tweaks
// @namespace http://tampermonkey.net/
// @version 0.6
// @description UI / UX Tweaks for BearyChat
// @author E.T
// @match https://*.bearychat.com/*
// ==/UserScript==
/* global document, fetch */
@splhack
splhack / python2+3.md
Created May 18, 2016 06:01
MacVim with Python 2.x and Python 3.x
  • Install python 2.7.11

command line

$ PYTHON_CONFIGURE_OPTS="--enable-shared" \
    LDSHARED="clang -bundle" \
    LDCXXSHARED="clang++ -bundle" \
    BLDSHARED="clang -bundle -lpython2.7" \
    pyenv install 2.7.11
@flbuddymooreiv
flbuddymooreiv / passgitgpg.md
Last active June 27, 2025 17:40
Setting up pass on git with a gpg key

The following shell transcript shows how to:

  • Create a GPG key
  • Create a pass database
  • Add git support to the pass database
  • Create a remote git repository
  • Push the pass database to the remote git repository
  • Fetch and display your passwords from another host

It is assumed that the pass package has been installed on both the first and second computers.

@lucidlibrary
lucidlibrary / elasticsearch-snapshot-restore.md
Last active February 27, 2018 12:28
Elasticsearch Snapshot and Restore API

Elasticsearch introduced Snapshot and Restore API in Elasticsearch 1.0. With this module you can take backup/restore of the data easily.

To take snapshots or to restore them, first you need to create a repository. A repository is a just like allocating an address to your snapshots.

A repository can contain as many snapshots as you would like, and you can create any number of repositories.

Each repository is mapped to a location where your snapshot files will be stored. Elasticsearch first started with snapshots to FileSystem location, now you can take snapshots to Remove locations like AWS S3 directly.

Elasticsearch currently supports snapshtos to AWS S3,

@khelll
khelll / install-redis.sh
Last active March 12, 2024 08:33
Installing Redis on Amazon Linux
#!/bin/bash
###############################################
# To use:
# chmod +x install-redis.sh
# ./install-redis.sh
###############################################
version=3.2.0
echo "*****************************************"
echo " 1. Prerequisites: Install updates, set time zones, install GCC and make"