Skip to content

Instantly share code, notes, and snippets.

View dacharyc's full-sized avatar

Dachary dacharyc

View GitHub Profile
@dacharyc
dacharyc / EmbeddingProviderExample.java
Created October 15, 2024 14:59
Example EmbeddingProvider with overloaded `getEmbeddings` method
import dev.langchain4j.data.embedding.Embedding;
import dev.langchain4j.data.segment.TextSegment;
import dev.langchain4j.model.huggingface.HuggingFaceEmbeddingModel;
import dev.langchain4j.model.output.Response;
import io.github.cdimascio.dotenv.Dotenv;
import org.bson.BsonArray;
import org.bson.BsonDouble;
import java.util.ArrayList;
import java.util.List;
@dacharyc
dacharyc / gist:a506616bebcd5c9ed47c270d975dea8c
Created July 19, 2024 16:08
Nested code block within Driver language selector reproduction case
==========
Page Title
==========
.. tabs-selector:: drivers
When you have content that is in a Drivers language tab...
And that content also contains code blocks that are in different languages...
The code blocks inherit the language from the parent tab language.
@dacharyc
dacharyc / LoginView.swift
Created June 14, 2024 14:36
Sign-in with Apple with Atlas Device SDK + SwiftUI
import SwiftUI
import RealmSwift
import AuthenticationServices
struct LoginView: View {
@State private var isLoggingIn = false
@State private var isInSignUpView = false
@EnvironmentObject var errorHandler: ErrorHandler
var body: some View {
@dacharyc
dacharyc / insertWeeklyData.js
Last active October 28, 2023 18:27
Insert data to MongoDB Atlas in an Atlas Function called by a HTTPS Endpoint
// This Gist goes with the article at http://dacharycarey.com/2023/11/01/hackathon-part-1/
// This function is the endpoint's request handler.
exports = function({ formData, headers }, response) {
// Data can be extracted from the request as follows:
// Headers, e.g. {"Content-Type": ["application/json"]}
const contentTypes = headers["Content-Type"];
// The "formData" here is the form data sent from Google Analytics