Skip to content

Instantly share code, notes, and snippets.

@jcdiv47
jcdiv47 / git_checkout_commit.md
Created August 21, 2024 06:34
Git Checkout Certain Commit
  1. To visit the state of a repository under certain commit, first clone the repo without checkout:
git clone https://github.com/karpathy/build-nanogpt.git --no-checkout

This command downloads all the repository data, but does not check out the working files.

  1. Navigate to the directoryone should see an seemingly empty directory.
@jcdiv47
jcdiv47 / openai_assistant_api.py
Created July 15, 2024 09:45
OpenAI Assistant API
import os
import time
from dotenv import load_dotenv
from openai import OpenAI
load_dotenv()
client = OpenAI()
model = "gpt-4o-2024-05-13"
assistant = client.beta.assistants.create(
@jcdiv47
jcdiv47 / nvim_options.md
Created June 13, 2024 02:04
Neovim options

display multiple sign columns

set signcolumn=yes:2
@jcdiv47
jcdiv47 / nvim_plugins.md
Created June 13, 2024 02:04
Neovim plugins

floating filesystem window at current working directory

keys = {
  {
    '\\',
    ':Neotree action=focus source=filesystem position=left toggle=true<CR>',
  },
@jcdiv47
jcdiv47 / nvim_autocmd.md
Last active June 17, 2024 03:03
Neovim autocmd snippets

File Editing

Obsidian callout in markdown files

> [!INFO] foo bar
> 
@jcdiv47
jcdiv47 / stopping_criteria.py
Last active June 13, 2024 02:00
Stopping criteria for text-to-sql task with text-generation pipeline
from transformers import AutoTokenizer, AutoModelForCausalLM, \
GenerationConfig, BitsAndBytesConfig, StoppingCriteria, \
TextStreamer, pipeline
import torch
class GenerateSqlStoppingCriteria(StoppingCriteria):
def __call__(self, input_ids, scores, **kwargs):
# stops when sequence "```\n" is generated
@jcdiv47
jcdiv47 / Array_FourSum.py
Created January 7, 2020 01:25
This is a directory of algorithm problems in regards of array that I did in AlgoExpert
#!/usr/bin/env python3
# Write a function that takes in a non-empty array of distinct integers and an integer representing a target sum.
# The function should find all quadruplets in the array that sum up to the target sum and return a two-dimensional
# array of all these quadruplets in no particular order. If no four numbers sum up to the target sum, the function
# should return an empty array.
# Sample input: [7, 6, 4, -1, 1, 2], 16
# Sample output: [[7, 6, 4, -1], [7, 6, 1, 2]]