Skip to content

Instantly share code, notes, and snippets.

@ymoslem
ymoslem / ChatGPT-translation.py
Last active May 4, 2024 16:50
Minimal working code for translation with GPT-4, "gpt-3.5-turbo" (a.k.a. ChatGPT) and "text-davinci-003"
# pip3 install openai
import openai
import time
OPENAI_API_KEY = "your_api_key_here"
openai.api_key = OPENAI_API_KEY
prompt = """French: La semaine dernière, quelqu’un m’a fait part de sa gratitude envers notre travail.
@ktmud
ktmud / __init__.py
Last active May 24, 2024 07:05
An extreme simple Python http server with auto reload and file-system based router
import os
from .app import start_cli_service
env = (os.environ.get("env") or "prod").lower()
is_dev = env == "dev" or env == "local"
port, autoreload_observer = start_cli_service(autoreload=is_dev)
if autoreload_observer:
# move autoreload observer to the foreground so process won't exit
@nielsuit227
nielsuit227 / SelectBrushPlot
Last active December 3, 2021 17:33
Time Series Plot (leeoniya/uPlot) with brush and selection option
import React, {useEffect, useRef, useState} from 'react';
import { Switch, Flex, Text } from '@chakra-ui/react';
import UplotReact from 'uplot-react';
import { toast } from 'react-toastify';
import 'uplot/dist/uPlot.min.css';
const colors = [
'#007BFF',
'#FFA62B',
@okld
okld / multipage_settings_app.py
Last active July 11, 2024 23:55
Streamlit - Settings page with session state
import streamlit as st
from persist import persist, load_widget_state
def main():
if "page" not in st.session_state:
# Initialize session state.
st.session_state.update({
# Default page.
"page": "home",
@ines
ines / streamlit_prodigy.py
Created October 3, 2019 20:37
Streamlit + Prodigy
"""
Example of a Streamlit app for an interactive Prodigy dataset viewer that also lets you
run simple training experiments for NER and text classification.
Requires the Prodigy annotation tool to be installed: https://prodi.gy
See here for details on Streamlit: https://streamlit.io.
"""
import streamlit as st
from prodigy.components.db import connect
from prodigy.models.ner import EntityRecognizer, merge_spans, guess_batch_size
@sloanlance
sloanlance / jq_jsonl_conversion.md
Last active October 22, 2024 04:35
jq: JSONL ↔︎ JSON conversion

jq: JSONL ↔︎ JSON conversion

Prerequisites

  • jqhttps://jqlang.github.io/jq/ — "like sed for JSON data"

    There are several options available for installing jq. I prefer to use Homebrew: brew install jq

  1. JSONL → JSON

@ilblackdragon
ilblackdragon / seq2seq.py
Last active May 22, 2022 21:42
Example of Seq2Seq with Attention using all the latest APIs
import logging
import numpy as np
import tensorflow as tf
from tensorflow.contrib import layers
GO_TOKEN = 0
END_TOKEN = 1
UNK_TOKEN = 2
@adamfeuer
adamfeuer / D3JS Tree Visualizer.md
Last active August 7, 2021 23:53
D3JS Tree Visualizer

d3js Tree Visualizer

This example pulls together various examples of work with trees in D3.js. See the d3js Tree Visualizer live here.

The panning functionality can certainly be improved in my opinion and I would be thrilled to see better solutions contributed.

One can do all manner of housekeeping or server related calls on the drop event to manage a remote tree dataset for example.

Panning can either be done by dragging an empty part of the SVG around or dragging a node towards an edge.

@Nazgolze
Nazgolze / reader_to_couchdb.py
Last active December 16, 2015 18:39
short python script to save your google reader data to couchdb.
#!/usr/bin/python2
import logging
import sys
import couchdb
import json
from libgreader import GoogleReader, ClientAuthMethod, Feed
"""
Original can be obtained here: https://gist.github.com/Nazgolze/5479539