Skip to content

Instantly share code, notes, and snippets.

@leocomelli
leocomelli / git.md
Last active June 2, 2023 10:51
Lista de comandos úteis do GIT
View git.md

GIT

Estados

  • Modificado (modified);
  • Preparado (staged/index)
  • Consolidado (comitted);

Ajuda

@lewangdev
lewangdev / default.custom.yaml
Last active June 2, 2023 10:50
雾凇拼音自定义配置,MacOS-like & Wechat-like Dark/Light Color Scheme For Rime
View default.custom.yaml
patch:
# 菜单
menu:
page_size: 8 # 候选词个数
# alternative_select_labels: [ ①, ②, ③, ④, ⑤, ⑥, ⑦, ⑧, ⑨, ⑩ ] # 修改候选项标签
# alternative_select_keys: ASDFGHJKL # 如编码字符占用数字键,则需另设选字键
# ascii_mode、inline、no_inline、vim_mode 等等设定,可参考 /Library/Input Methods/Squirrel.app/Contents/SharedSupport/squirrel.yaml
# 中西文切换
#
# 【good_old_caps_lock】 CapsLock 切换到大写或切换中英。
@Birch-san
Birch-san / llama-convert.md
Created June 1, 2023 18:24
Converting LLaMA model weights to huggingface format + safetensors
View llama-convert.md

Loading LLaMA via Huggingface + Safetensors, with 4-bit quantization

Let's say we're trying to load a LLaMA model via AutoModelForCausalLM.from_pretrained with 4-bit quantization in order to inference from it:

python -m generate.py

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, LlamaTokenizerFast, LlamaForCausalLM
import transformers
@mxmason
mxmason / webflow-disable-scroll-prefers-reduced-motion.js
Last active June 2, 2023 10:49
These snippets completely disable the smooth-scroll animation that is present on all Webflow sites. Animated scrolling can disorient or surprise users, or even cause motion sickness!
View webflow-disable-scroll-prefers-reduced-motion.js
// Disable smooth scrolling for users who have set `prefers-reduced-motion` in their operating system
// 1. Place this snippet before the end of the <body> tag;
// NOT in the <head> tag!
// 2.Make sure it's inside $(function() {})!
$(function() {
const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
if (mediaQuery.matches) $(document).off('click.wf-scroll');
})
@Birch-san
Birch-san / fine-tuning.md
Last active June 2, 2023 10:48
Fine-tuning LLaMA-7B on ~10GB VRAM with QLoRA, 4-bit quantization
View fine-tuning.md

Fine-tuning LLaMA-7B on ~10GB VRAM with QLoRA, 4-bit quantization

nvidia-smi said this required 11181MiB, at least to train on the sequence lengths of prompt that occurred initially in the alpaca dataset (~337 token long prompts).
You can get this down to about 10.9GB if (by modifying qlora.py) you run torch.cuda.empty_cache() after PEFT has been applied to your loaded model and before you begin training.

Setup

All instructions are written assuming your command-line shell is bash.

Clone repository:

@robbmcleod
robbmcleod / clr_array_convert.md
Last active June 2, 2023 10:47
Convert NumPy `ndarray` to C# `System.Array` and back again
View clr_array_convert.md

Originally for Python 3.7 and PythonNet 2.4.0 I wrote a snippet of code to transform NumPy ndarray into System.Array from CLR and back again using pure python and the ctypes package memmove function:

https://github.com/pythonnet/pythonnet/issues/514
https://github.com/pythonnet/pythonnet/issues/652

However, after the release of PythonNet 2.5.0 there were some changes to the PythonNet interface that created some small breaks in my code snippet:

@royshil
royshil / AndroidCamera2TouchToFocus.java
Last active June 2, 2023 10:47
How to implement Touch-to-Focus in Android using Camera2 APIs
View AndroidCamera2TouchToFocus.java
//Override in your touch-enabled view (this can be differen than the view you use for displaying the cam preview)
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
final int actionMasked = motionEvent.getActionMasked();
if (actionMasked != MotionEvent.ACTION_DOWN) {
return false;
}
if (mManualFocusEngaged) {
Log.d(TAG, "Manual focus already engaged");
return true;
@elibolonur
elibolonur / cloudSettings
Last active June 2, 2023 10:44
VS Code settings - Public
View cloudSettings
{"lastUpload":"2021-03-29T14:30:37.960Z","extensionVersion":"v3.4.3"}
@neubig
neubig / dispatch_openai_requests.py
Last active June 2, 2023 10:44
A simple script to get results from the OpenAI Asynchronous API
View dispatch_openai_requests.py
import openai
import asyncio
from typing import Any
async def dispatch_openai_requests(
messages_list: list[list[dict[str,Any]]],
model: str,
temperature: float,
max_tokens: int,
top_p: float,
@tanaikech
tanaikech / submit.md
Last active June 2, 2023 10:41
Report: Images put with IMAGE function on Google Spreadsheet
View submit.md

Report: Images put with IMAGE function on Google Spreadsheet

This is a report about images put with "=IMAGE(IMAGE_URL)" function on Google Spreadsheet.

Experiment

When "=IMAGE(IMAGE_URL)" is put to a cell "A1" on Spreadsheet, the image is shown in the cell as shown in the following image.