This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple example of how to send prompts to an LLM using LiteLLM: | |
# | |
# Set your API key as shown in the Google Colab | |
# | |
import os | |
from google.colab import userdata | |
api_key = userdata.get('OPENAI_API_KEY') | |
os.environ['OPENAI_API_KEY'] = api_key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic CMakeLists.txt file with a basic project directory. | |
# project_dir | |
# | | |
# |-- include | |
# |-- src | |
# | |
cmake_minimum_required(VERSION 3.15) | |
project(MyProject) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Minimal CMakeLists.txt file with all source files in the same directory as the CMakeLists.txt file. | |
# | |
cmake_minimum_required(VERSION 3.15) | |
project(MyProject) | |
set(SRC_DIR "${CMAKE_CURRENT_LIST_DIR}") | |
set(SOURCES "${SRC_DIR}/main.cpp" "${SRC_DIR}/file1.cpp" "${SRC_DIR}/file2.cpp") | |
add_executable(${PROJECT_NAME} ${SOURCES}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Search only within a single file | |
rg <pattern> <filename> | |
rg <pattern> -g <filename pattern> | |
rg <pattern> --glob <filename pattern> | |
# Use ripgrep to extract unique 4 digit numbers from a file | |
`rg -o '\b\d{4}\b' <file_name> | sort -u` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os/exec" | |
) | |
func main() { | |
app := "echo" | |
arg0 := "-e" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From: https://doc.rust-lang.org/rust-by-example/std_misc/file/read_lines.html | |
use std::fs::File; | |
use std::io::{self, BufRead}; | |
use std::path::Path; | |
fn main() { | |
// File hosts.txt must exist in the current path | |
if let Ok(lines) = read_lines("./hosts.txt") { | |
// Consumes the iterator, returns an (Optional) String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"strings" | |
) | |
func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
project(cpp_condition) | |
set(CMAKE_CXX_STANDARD 17) | |
add_executable(cpp_condition cpp-condition.cpp) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <thread> | |
#include <mutex> | |
#include <condition_variable> | |
std::mutex m; | |
std::condition_variable cv; | |
std::string data; | |
bool ready = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(non_upper_case_globals)] | |
#![allow(non_camel_case_types)] | |
#![allow(non_snake_case)] | |
include!("../bindings.rs"); | |
fn main() { | |
unsafe { | |
let size = fooGetCtxSize(); | |
println!("Ctx Size: {}", size); |
NewerOlder