Skip to content

Instantly share code, notes, and snippets.

@davidmroth
davidmroth / docker_compose_alias_with_completion.sh
Last active April 7, 2024 05:00
Enabling `docker compose` alias, i.e., dc vs. docker compose
# Add to your .bashrc
# https://www.gnu.org/software/gnuastro/manual/html_node/Bash-TAB-completion-tutorial.html
if which docker >/dev/null 2>&1; then
__docker_compose_cmdline_completion() {
local commands cur prev words cword
COMPREPLY=()
_get_comp_words_by_ref -n : cur prev words cword
@davidmroth
davidmroth / docker.bash
Created April 6, 2024 01:21
Docker ENV
export DOCKER_DEFAULT_PLATFORM=linux/amd64
export DOCKER_HOST="tcp://"$(ifconfig enp0s1 | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | head -1 | awk -F"." '{print $1"."$2"."$3".1"}')":2375"
@davidmroth
davidmroth / Conversation Settings
Last active March 23, 2024 11:26
Custom GPTs OAuth Settings and API for Google Sheets
Converstations Starter: Create a new project: Type: Project, Assignee: John, Category: Job
Instructions (appended to your exsting instructions): When a project data is provided, please update Google Sheets ID: `<sheet id>` using `sheets.spreadsheets.values.append` api call with the information provided and starting at range: `Sheet1!A2`, and continue adding rows as needed.
NOTE: How to find the Google Sheet ID - https://stackoverflow.com/questions/36061433/how-do-i-locate-a-google-spreadsheet-id
@davidmroth
davidmroth / curl-websocket.sh
Created February 10, 2024 05:06 — forked from htp/curl-websocket.sh
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@davidmroth
davidmroth / Fixing Hung SSH Session
Created February 4, 2024 00:56
Fixing Hung SSH Session
https://serverfault.com/a/283130/486852
@davidmroth
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
Instructions:
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
davidmroth / chat.py
Created December 7, 2023 01:24 — forked from RageshAntony/chat.py
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
davidmroth / zip_folder.sh
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 file.zip ./folder/subfolder/
@davidmroth
davidmroth / connect.sh
Created August 19, 2023 03:52
Connect Docker Desktop to Multipass (MacOS)
#!/bin/bash
// In multipass, do `export DOCKER_HOST:192.168.64.1:2375`
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
davidmroth / comm_port.text
Created September 8, 2022 04:10
Connect to a comm port (Ubuntu)
busybox microcom -t 9600 /dev/xxxx