Skip to content

Instantly share code, notes, and snippets.

@roychri
roychri / README.md
Created May 2, 2024 17:50
Stream Ollama (openai) chat completion API on CLI with HTTPie and jq

Stream Ollama (openai) chat completion API on CLI with HTTPie and jq

Explanation

This command sends a request to the Chat Completion API to generate high-level documentation for the file @src/arch.js. The API is configured to use the llama3-gradient model and to respond in Markdown format.

The messages array contains two elements:

  • The first element is a system message that provides the prompt for the API.
  • The second element is a user message that specifies the file for which to generate documentation.
@wildlyinaccurate
wildlyinaccurate / add.js
Created February 7, 2014 08:51
Bitwise addition
// Fuck the addition operator. Real programmers work in binary!
function add(a, b) {
// XOR to get the sum of the bits
var sum = a ^ b;
// "Carry" bits are common to both numbers
var carry = (a & b) << 1;
if (sum & carry) {
// Rinse and repeat until there are no leftover bits
@puppybits
puppybits / image64.sh
Created January 5, 2012 14:18
Create data URI image from Terminal command
#!/bin/sh
# Examples:
# ./image64.sh myImage.png
# outputs: data:image/png;base64,xxxxx
# ./image64.sh myImage.png -img
# outputs: <img src="data:image/png;base64,xxxxx">
filename=$(basename $1)
xtype=${filename##*.}
append=""
@ih2502mk
ih2502mk / list.md
Last active May 2, 2024 20:55
Quantopian Lectures Saved
@thegreatestminer
thegreatestminer / encoded-20201212150102.txt
Created December 12, 2020 15:01
MobaXTerm Professional x64 License Key [READ COMMENTS]
UEsDBBQAAAAIABNQjFGCf/GfLgAAACwAAAAHAAAAUHJvLmtleTMqdncpCXQOKDAp9woMzEo1MTVOrHAzTjTLME7VNs1LK8owTjQpcU8tcuLlAgBQSwECFAAUAAAACAATUIxRgn/xny4AAAAsAAAABwAAAAAAAAAAAAAAAAAAAAAAUHJvLmtleVBLBQYAAAAAAQABADUAAABTAAAAAAA=
@sindresorhus
sindresorhus / esm-package.md
Last active May 2, 2024 20:54
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@RamonLopezEscudero
RamonLopezEscudero / Merge_Sort.c
Last active May 2, 2024 20:51
Código del método de ordenamiento "Merge Sort"
#include <stdio.h>
#include <stdlib.h>
void merge(int *array, int p, int q, int r)
{
// Declaracion de variables
int i, j, k;
int n_1 = (q - p) + 1;
int n_2 = (r - q);
int *L, *R;
@ArthurZucker
ArthurZucker / mamba_peft.py
Created March 7, 2024 09:32
Mamba peft finetuning
from datasets import load_dataset
from trl import SFTTrainer
from peft import LoraConfig
from transformers import AutoTokenizer, AutoModelForCausalLM, TrainingArguments
tokenizer = AutoTokenizer.from_pretrained("state-spaces/mamba-130m-hf")
model = AutoModelForCausalLM.from_pretrained("state-spaces/mamba-130m-hf")
dataset = load_dataset("Abirate/english_quotes", split="train")
training_args = TrainingArguments(
output_dir="./results",
num_train_epochs=3,
@leocomelli
leocomelli / git.md
Last active May 2, 2024 20:46
Lista de comandos úteis do GIT

GIT

Estados

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

Ajuda

@tvst
tvst / streamlit_app.py
Last active May 2, 2024 20:46
Simple way to run heavy computations without slowing down other Streamlit users
import streamlit as st
import concurrent.futures # We'll do computations in separate processes!
import mymodule # This is where you'll do the computation
# Your st calls must go inside this IF block.
if __name__ == '__main__':
st.write("Starting a long computation on another process")
# Pick max number of concurrent processes. Depends on how heavy your computation is, and how
# powerful your machine is.