Skip to content

Instantly share code, notes, and snippets.

@czue
czue / langchain_qa_chatgpt_bot.py
Last active April 3, 2024 13:57
sample code for chatgpt / gpt4 langchain Q&A
# see https://www.youtube.com/watch?v=CsFpVdgEXCU for details of what this does
from typing import List
from langchain import ConversationChain
from langchain.chat_models import ChatOpenAI
from langchain.indexes.vectorstore import VectorStoreIndexWrapper
from langchain.memory import ConversationBufferMemory
from langchain.prompts import (
ChatPromptTemplate,
/*
* Send a newsletter or any emails to multiple users easily, no need to use bcc
* If you are a workspace user with license > Business Standard you already have the multi-send
* https://support.google.com/google-workspace-individual/answer/11243118
*/
function sendMyNewsletter() {
let emails = 'COMA_SEPARATED_LIST_OF_EMAILS_NO_SPACE'
let subject = 'SUBJECT OF THE EMAILS IN YOUR DRAFT';
let draft = GmailApp.getDraftMessages().find(message => { return message.getSubject() == subject });
@laundmo
laundmo / lerp.py
Last active June 23, 2024 09:50
lerp, inverse lerp and remap in python
def lerp(a: float, b: float, t: float) -> float:
"""Linear interpolate on the scale given by a to b, using t as the point on that scale.
Examples
--------
50 == lerp(0, 100, 0.5)
4.2 == lerp(1, 5, 0.8)
"""
return (1 - t) * a + t * b
@effigies
effigies / python_packaging_2020.md
Last active January 25, 2024 13:42
Contemporary Python Packaging - 2020

Contemporary Python Packaging

This document lays out a set of Python packaging practices. I don't claim they are best practices, but they fit my needs, and might fit yours.

Validity

This document has been superseded as of January 2023.

This was written in July 2020, superseding this gist from 2019.

# PyQt4 imports
from PyQt5 import QtGui, QtCore, QtWidgets, QtOpenGL
from PyQt5.QtOpenGL import QGLWidget
# PyOpenGL imports
import OpenGL.GL as gl
import OpenGL.arrays.vbo as glvbo
# Window creation function.
def create_window(window_class):
"""Create a Qt window in Python, or interactively in IPython with Qt GUI
@kewah
kewah / vimUserSettings.js
Last active March 6, 2022 07:22
Personal User Settings for Vim plugin
{
"vim.surround": true,
"vim.sneak": true,
"vim.easymotion": true,
"vim.easymotionMarkerFontFamily": "Inconsolata",
"vim.easymotionMarkerHeight": 15,
"vim.easymotionMarkerFontSize": "14",
"vim.easymotionMarkerYOffset": 1,
"vim.useSystemClipboard": true,
"vim.leader": "space",
@oisobstudio
oisobstudio / part.md
Last active April 1, 2023 18:53
Django Pagination Server-Side Menggunakan DataTable

myapp/views.py

import json

from django.views.generic import View
from django.http import HttpResponse
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.db.models import Q
from django.core.serializers.json import DjangoJSONEncoder
@Maumagnaguagno
Maumagnaguagno / .travis.yml
Last active February 18, 2020 00:02
Make Travis-CI push files to other repositories for you when tests pass
language: ruby
rvm:
- 2.0.0
env:
global:
- USER="username"
- EMAIL="username@mail.com"
- REPO="name of target repo"
- FILES="README.md foo.txt bar.txt"
- GH_REPO="github.com/${USER}/${REPO}.git"
@staltz
staltz / introrx.md
Last active July 2, 2024 03:45
The introduction to Reactive Programming you've been missing
@pbojinov
pbojinov / README.md
Last active June 24, 2024 05:39
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe