Skip to content

Instantly share code, notes, and snippets.

View warren30815's full-sized avatar

Jordan Hsu warren30815

View GitHub Profile
@CivilEngineerUK
CivilEngineerUK / serialize_openai_output.py
Created December 5, 2023 09:38
Example of serializing OpenAI completions so that it can be transmitted easily via REST
"""
# OpenAI Chat Completions Serialization Example
## Description
This code snippet demonstrates how to serialize the response from the OpenAI Chat Completions API into a JSON format which is useful for sending using REST.
It includes a helper function, `serialize_completion`, that takes the completion response object and converts it into a JSON-compatible dictionary.
## Usage
To use this code, you will need to have a .env file in the same directory as this script with your openai key:
OPENAI_API_KEY = "sk-your_key_here"
@fschr
fschr / vector_combinations.cpp
Created October 12, 2016 19:54
kinda fast std::vector combinations function c++
#include <stdint.h>
#include <stdlib.h>
#include <vector>
#define uint32 uint32_t
std::vector<std::vector<uint32>> combinations(std::vector<uint32> src, uint32 r) {
std::vector<std::vector<uint32>> cs;
if (r == 1) {
for (auto i = 0; i < src.size(); i++) {
@abdullah
abdullah / selend.js
Last active April 30, 2024 11:00
Selection End Event
let selectionEndTimeout = null,
event = new Event('selectionEnd');
document.addEventListener('selectionEnd', function (evt/*event*/) {
console.log("End selection!")
}, false);
[
"mouseup",