Skip to content

Instantly share code, notes, and snippets.

@RageshAntony
RageshAntony / chat.py
Created August 1, 2023 12:59
Chat with Documents with Memory using LangChain
import openai
from colorama import Fore
from langchain import PromptTemplate
from langchain.chains import ConversationalRetrievalChain, RetrievalQA
from langchain.chat_models import ChatOpenAI
from langchain.document_loaders import TextLoader
from langchain.embeddings import HuggingFaceEmbeddings
from langchain.memory import ConversationBufferMemory
from langchain.schema import SystemMessage
from langchain.text_splitter import RecursiveCharacterTextSplitter
@moaaz-bhnas
moaaz-bhnas / withoutEdgesAndNodes.ts
Last active June 11, 2023 17:04
A function that removes edges and nodes from Shopify Storefront data
function isArray(data: any): Boolean {
return data && data.constructor === Array;
}
function isObject(data: any): Boolean {
return data && data.constructor === Object;
}
function withoutEdgesAndNodes(data: any): any {
let result = Array.isArray(data) ? [] : {};
@broofa
broofa / checkForUndefinedCSSClasses.js
Last active January 21, 2024 17:22
ES module for detecting undefined CSS classes (uses mutation observer to monitor DOM changes). `console.warn()`s undefined classes.
/**
* Sets up a DOM MutationObserver that watches for elements using undefined CSS
* class names. Performance should be pretty good, but it's probably best to
* avoid using this in production.
*
* Usage:
*
* import cssCheck from './checkForUndefinedCSSClasses.js'
*
* // Call before DOM renders (e.g. in <HEAD> or prior to React.render())
@davidmroth
davidmroth / compile_cpuminer-multi.sh
Last active February 25, 2021 00:08
Compile cpuminer-multi for Raspberry Pi
#!/bin/bash
#
# WARNING: CPU MINING IS UNPROFITABLE! (FOR HOBBY / EXPERIMENT / RESEARCH ONLY)
#
# RASPBERRY PI CPUMINER-MULTI SETUP SCRIPT
#
# RASPBERRY PI, DOGE, DOGECOIN, PROHASHING.COM, LITECOIN, MINING
#
@davidmroth
davidmroth / .bash_profile
Last active November 11, 2022 01:04
Homebrew Setup Mac M1
# !!! IMPORTANT
# Must point to the correct director or this entire script breaks
eval $(/opt/homebrew/bin/brew shellenv)
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/usr/local/google-cloud-sdk/path.bash.inc' ]; then . '/usr/local/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/usr/local/google-cloud-sdk/completion.bash.inc' ]; then . '/usr/local/google-cloud-sdk/completion.bash.inc'; fi
@jkutner
jkutner / atik-indi-phd2-raspbian-instructions.md
Last active January 19, 2024 19:09
Turn a Raspberry Pi into an Astrophotography Autoguider
@ricjcosme
ricjcosme / dump-restore
Created September 13, 2017 17:33
DUMP / RESTORE PostgreSQL Kubernetes
DUMP
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
kubectl exec [pod-name] -- bash -c "pg_dump -U [postgres-user] [database-name]" > database.sql
RESTORE
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
@jboursiquot
jboursiquot / dumptransport.go
Created January 17, 2017 13:52
Dump transport will dump Go HTTP request/response for debugging
package dumptransport
import (
"fmt"
"net/http"
"net/http/httputil"
)
type DumpTransport struct {
r http.RoundTripper
@tablekat
tablekat / main.ts
Created June 30, 2016 20:24
Making gmail push notifications to webhook
import * as request from 'request';
import * as fs from 'fs';
import * as readline from 'readline';
var google = require('googleapis');
var googleAuth = require('google-auth-library');
/*************** STEPS
- made a project on https://console.cloud.google.com/cloudpubsub/topicList?project=testmabs thing?
@kdabir
kdabir / heredoc_json.bash
Last active January 11, 2024 02:25
json in heredoc in bash script alongwith variable substitution
_BUCKET_NAME="foo.example.com"
_POLICY=$(cat <<EOT
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadForGetBucketObjects",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],