Skip to content

Instantly share code, notes, and snippets.

View devdlabs's full-sized avatar
🎯
Focusing

Dev devdlabs

🎯
Focusing
View GitHub Profile
@aarushik93
aarushik93 / stoic_bot.py
Created April 28, 2023 19:46
stoic_bot
import streamlit as st
from langchain import LLMChain, OpenAI
from langchain.agents import AgentExecutor, Tool, ZeroShotAgent, ReActTextWorldAgent, initialize_agent
from langchain.chains import RetrievalQA, ConversationalRetrievalChain
from langchain.vectorstores.weaviate import Weaviate
from langchain.llms import OpenAI
from langchain.memory import ConversationBufferMemory
import weaviate
from langchain.utilities import GoogleSerperAPIWrapper
from langchain.chat_models import ChatOpenAI
type AnyFunction = (...args: any[]) => any
function useEvent<T extends AnyFunction>(callback?: T) {
const ref = useRef<AnyFunction | undefined>(() => {
throw new Error("Cannot call an event handler while rendering.")
})
// Or useInsertionEffect if it's React 18
useLayoutEffect(() => {
ref.current = callback
})
#!/bin/bash
# Find ClusterIPs of Redis nodes
export REDIS_NODES=$(kubectl get pods -l app=redis-cluster -n redis -o json | jq -r '.items | map(.status.podIP) | join(":6379 ")'):6379
# Activate the Redis cluster
kubectl exec -it redis-cluster-0 -n redis -- redis-cli --cluster create --cluster-replicas 1 ${REDIS_NODES}
# Check if all went well
for x in $(seq 0 5); do echo "redis-cluster-$x"; kubectl exec redis-cluster-$x -n redis -- redis-cli role; echo; done
@filipecosta90
filipecosta90 / Radix example for RedisTimeSeries OSS cluster connection
Last active December 14, 2022 01:53
Code snippet addressing question: https://github.com/RedisTimeSeries/redistimeseries-go/issues/63. Usage example (for cluster use --cluster-mode): ./radix-redistimeseries-example --host localhost:20002
package main
import (
"flag"
"fmt"
"github.com/mediocregopher/radix/v3"
"log"
"strconv"
"time"
)
@olegpolukhin
olegpolukhin / Run external Python script in Golang
Last active March 7, 2024 12:53
run external Python script in Golang
package main
import (
"bufio"
"fmt"
"io"
"os/exec"
)
func main() {
@kekru
kekru / traefik-redirect-path.md
Last active March 12, 2024 15:15
Traefik redirect / (root) to sub path with Docker labels

Traefik: redirect base or root path to a subpath

This is tested with Traefik 1.7

This is how to redirect the root or base path to a sub path in Traefik using Docker labels:
Goals

  • https://example.com -> https://example.com/abc/xyz/
  • https://example.com/ -> https://example.com/abc/xyz/
  • https://example.com/something -> no redirect
syntax = "proto3";
package main;
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
message Data {
bool boolValue = 1;
@pohzipohzi
pohzipohzi / redis-example.go
Last active March 22, 2022 15:59
Examples from redigo
// this is a file that puts together all redigo examples for convenience
// (see https://godoc.org/github.com/gomodule/redigo/redis#pkg-examples)
//
// start by ensuring that redis is running on port 6379 (`redis-server`)
// uncomment the main method as needed, and run the script (`go run main.go`)
package main
import (
"fmt"
"github.com/gomodule/redigo/redis"
@maqnouch
maqnouch / README.md
Last active May 3, 2024 19:15
Signal Installation Steps
@beginor
beginor / snowflake-id.sql
Last active May 11, 2024 18:48
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;