Skip to content

Instantly share code, notes, and snippets.

View bwghughes's full-sized avatar

Ben Hughes bwghughes

View GitHub Profile
@Hellisotherpeople
Hellisotherpeople / blog.md
Last active May 4, 2024 01:57
You probably don't know how to do Prompt Engineering, let me educate you.

You probably don't know how to do Prompt Engineering

(This post could also be titled "Features missing from most LLM front-ends that should exist")

Apologies for the snarky title, but there has been a huge amount of discussion around so called "Prompt Engineering" these past few months on all kinds of platforms. Much of it is coming from individuals who are peddling around an awful lot of "Prompting" and very little "Engineering".

Most of these discussions are little more than users finding that writing more creative and complicated prompts can help them solve a task that a more simple prompt was unable to help with. I claim this is not Prompt Engineering. This is not to say that crafting good prompts is not a difficult task, but it does not involve doing any kind of sophisticated modifications to general "template" of a prompt.

Others, who I think do deserve to call themselves "Prompt Engineers" (and an awful lot more than that), have been writing about and utilizing the rich new eco-system

@jerry-git
jerry-git / vax_app.py
Last active September 19, 2022 04:14
Simple modern Python web app
import datetime as dt
import os
import motor
from beanie import Document, Indexed, PydanticObjectId, init_beanie, operators
from fastapi import FastAPI, Response, status
from pydantic import BaseModel
app = FastAPI()
@simonw
simonw / recover_source_code.md
Last active January 16, 2024 08:13
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@kissgyorgy
kissgyorgy / sqlalchemy_conftest.py
Last active May 6, 2024 08:06
Python: py.test fixture for SQLAlchemy test in a transaction, create tables only once!
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from myapp.models import BaseModel
import pytest
@pytest.fixture(scope="session")
def engine():
return create_engine("postgresql://localhost/test_database")
@Bochenski
Bochenski / app.go
Created July 9, 2014 14:41
Negroni golang mgo middleware example
package main
import (
"github.com/codegangsta/negroni"
"github.com/gorilla/context"
"github.com/unrolled/render"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"log"
"net/http"
@vsajip
vsajip / pyvenvex.py
Last active April 29, 2024 07:26
A script which demonstrates how to extend Python 3.3's EnvBuilder, by installing setuptools and pip in created venvs. This functionality is not provided as an integral part of Python 3.3 because, while setuptools and pip are very popular, they are third-party packages.The script needs Python 3.3 or later; invoke it using"python pyvenvex.py -h"fo…
#
# Copyright (C) 2013-2020 Vinay Sajip. New BSD License.
#
import os
import os.path
from subprocess import Popen, PIPE
import sys
from threading import Thread
from urllib.parse import urlparse
from urllib.request import urlretrieve
@santiycr
santiycr / selenium_sauce_tests.py
Created August 13, 2012 18:19
Run multiple browsers on Sauce in parallel using some python magic
#!/usr/bin/env python
# encoding: utf-8
from selenium import webdriver
import unittest
import nose
from nose.plugins.multiprocess import MultiProcess
import new
import json
import httplib
@starenka
starenka / .gitignore
Created September 18, 2011 20:02
fabfile to deploy flask app to nginx/supervisor/uwsgi stack
.idea/*
*.pyc
@justquick
justquick / fabfile.py
Created May 9, 2011 01:33
Simple fabfile to deploy my django projects on a gunicorn + nginx setup
import os
import sys
from fabric.api import abort, run, sudo, env, cd
from fabric.colors import red, green
from fabric.contrib.files import exists, put, upload_template
ROOT = '/home/jquick/code/'
WORKON = '/home/jquick/.virtualenvs'
VENVS = {