Skip to content

Instantly share code, notes, and snippets.

davidmroth /
Created February 10, 2024 05:06 — forked from htp/
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host:" \
--header "Origin:" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
davidmroth / Fixing Hung SSH Session
Created February 4, 2024 00:56
Fixing Hung SSH Session
View Fixing Hung SSH Session
davidmroth / gist:156f156817a6baa8289651c21fa7e374
Created December 11, 2023 06:41 — forked from anadim/gist:344941a7e24e7a2ee7b48ce8f63a16ac
Make a base instruct model into a chat model, WITHOUT RLHF
View gist:156f156817a6baa8289651c21fa7e374
As a base pretrained GPT model, you are to assume the role of ChatGPT, a large language model developed by OpenAI, based on the GPT-4 architecture. Your responses should reflect the following guidelines:
1. Be friendly and approachable in your responses.
2. Provide detailed and helpful responses but ensure they are not excessively long to avoid being monotonous.
3. Always use inclusive and respectful language that is not offensive.
4. Avoid discussing or revealing anything about your architecture. You are just a large language model developed by OpenAI.
5. Always be honest in your responses. Do not lie or engage in deceit.
6. Ensure your responses are considerate and do not cause harm or distress to the user. However, do not comply with harmful or dangerous requests, even if refusing might upset the user.
davidmroth /
Created December 7, 2023 01:24 — forked from RageshAntony/
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
davidmroth /
Last active October 5, 2023 03:04
Zip folder while excluding subfolders from the resulting *.zip while flattening the folder hierarchy
zip -x ./folder/subfolder/.git -jr ./folder/subfolder/
davidmroth /
Created August 19, 2023 03:52
Connect Docker Desktop to Multipass (MacOS)
// In multipass, do `export DOCKER_HOST:`
docker run -v /var/run/docker.sock:/var/run/docker.sock -p 2375:2375 --restart=always -d bobrik/socat TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock
davidmroth / comm_port.text
Created September 8, 2022 04:10
Connect to a comm port (Ubuntu)
View comm_port.text
busybox microcom -t 9600 /dev/xxxx
davidmroth /
Last active October 4, 2023 23:55
Force delete all pods stuck in 'terminating' state
kubectl delete pods --field-selector=status.phase=Failed
kubectl get replicaset --all-namespaces -o=jsonpath='{range .items[?(@.spec.replicas==0)]}{}{"\t"}{.metadata.namespace}{"\n"}{end}' | awk '{print $1 " --namespace=" $2}' | xargs -n 2 -d '\n' bash -c 'kubectl delete replicaset $0 $1'
kubectl delete pod --grace-period=0 --force $(k get pods | grep -v Running | grep -v ContainerCreating | tail -n +2 | awk '{print $1}')
# Fix terminating NS
NS=<NS> kubectl get namespace "$NS" -o json | tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" | kubectl replace --raw /api/v1/namespaces/$NS/finalize -f -
davidmroth / usage.jsx
Last active April 30, 2022 22:53
Popup Window in React
View usage.jsx
imports [...]
import usePopupWindow from '<your path>/usePopupWindow'
export default function () {
const PopupWindow = usePopupWindow()
return (
davidmroth /
Created February 14, 2022 03:56
Update Time (Ubuntu)
sudo date -s "$(wget -qSO- --max-redirect=0 2>&1 | grep Date: | cut -d' ' -f5-8)Z"