Skip to content

Instantly share code, notes, and snippets.

View chrischoy's full-sized avatar

Chris Choy chrischoy

View GitHub Profile
@chrischoy
chrischoy / task.cpp
Created March 2, 2019 04:52
task.cpp
#include <cmath>
#include <functional>
#include <future>
#include <iostream>
#include <thread>
// unique function to avoid disambiguating the std::pow overload set
int f(int x, int y) { return std::pow(x, y); }
class Functor {
# Copyright (c) Chris Choy ([email protected]).
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
import os
import time
import argparse
import numpy as np
from urllib.request import urlretrieve
try:
import open3d as o3d
except ImportError:
raise ImportError("Please install open3d with `pip install open3d`.")
@chrischoy
chrischoy / openai_completion.zsh
Created March 17, 2023 12:02
OpenAI API call from command line
# OpenAI call
export OPENAI_API_TOKEN=<YOUR_API_KEY from https://platform.openai.com/account/api-keys>
function openai-completion() {
# echo "\nCompleting $LBUFFER ..."
# echo '{ "model": "text-davinci-003", "prompt": "'$LBUFFER'", "max_tokens": 15, "temperature": 0.7 }\n\n'
local response=$(curl --progress-bar https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_TOKEN" \
-d '{ "model": "text-davinci-003", "prompt": "'$LBUFFER'", "max_tokens": 100, "temperature": 0.7 }')