Skip to content

Instantly share code, notes, and snippets.

from langchain import OpenAI, LLMChain
from langchain import PromptTemplate, FewShotPromptTemplate
from langchain.llms import LlamaCpp
import csv
examples = [
{"product": "Toothpaste",
"category": "Health:Dental"},
{"product": "Toilet Flapper",
"category": "Home:Maintenance"},
from langchain import OpenAI, LLMChain, PromptTemplate
from langchain import PromptTemplate, FewShotPromptTemplate
from langchain.chains import LLMChain
from langchain.llms import LlamaCpp
from langchain.prompts import PromptTemplate
import csv
examples = [
{"product": "Toothpaste",
"category": "Health:Dental"},
@reedlaw
reedlaw / downgrade_psql_syntax.rb
Created November 30, 2020 18:52
Downgrade PostgreSQL 10 syntax for backwards compatibility
#!/usr/bin/env ruby
# typed: ignore
# Makes PostgreSQL > 9 syntax compatible with < 10
sql = File.open('./db/structure.sql', 'r+')
inside_create_sequence = false
out = ''
sql.each_line do |line|
if inside_create_sequence && line.strip == 'AS integer'
@reedlaw
reedlaw / eventlog.go
Last active November 12, 2019 16:31
Create custom Windows Event Source in Go
// +build windows
package main
import (
"errors"
"golang.org/x/sys/windows/registry"
"golang.org/x/sys/windows/svc/eventlog"
)
@reedlaw
reedlaw / rom_association.rb
Created October 20, 2017 23:09
ROM associations example
#!/usr/bin/ruby
require "rom"
require "rom/memory"
class Users < ROM::Relation[:memory]
schema do
attribute :id, Types::Int
attribute :name, Types::String
@reedlaw
reedlaw / rom_mapper_issue.rb
Created October 20, 2017 19:30
ROM mapper issue
#!/usr/bin/ruby
require 'rom'
configuration = ROM::Configuration.new(:memory, 'memory://test')
class AppointmentInfoRepository < ROM::Repository::Root
root :appointment_info
commands :create
@reedlaw
reedlaw / .zshrc
Created December 11, 2013 20:23
zsh config
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=100000
setopt appendhistory autocd beep nomatch
unsetopt notify
bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/reed/.zshrc'
@reedlaw
reedlaw / location_interactor.rb
Created October 31, 2013 17:21
CRUD action interactors
class LoadLocation < Interactor
def call
@response.location = location.attributes
@response
end
def location
LocationRepository.joins(:manager)
.select("*, user_repository.name AS manager_name")
.where(account_repository_id: @request.current_account_id)
@reedlaw
reedlaw / users_controller.rb
Last active December 27, 2015 02:39
Users controller
class UsersController < ApplicationController
respond_to :html
before_filter :authenticate_user!
def user_params
params.require(:user).permit :first_name, :last_name, :email, :password, :password_confirmation, :phone
end
private :user_params
def index
@reedlaw
reedlaw / user_repository.rb
Created October 31, 2013 17:10
User repository
# == Schema Information
#
# Table name: user_repository
#
# id :integer not null, primary key
# account_repository_id :integer
# first_name :text
# last_name :text
# state :text
# email :string(255) default(""), not null