Skip to content

Instantly share code, notes, and snippets.

View jojohannsen's full-sized avatar

Joh Johannsen jojohannsen

View GitHub Profile
@jojohannsen
jojohannsen / gen_graph.py
Created August 19, 2024 14:46
python function to generate langgraph code from text form of graph
import re
def transform_graph_spec(graph_spec: str) -> str:
lines = graph_spec.split('\n')
transformed_lines = []
for line in lines:
if '=>' in line and not line[0].isspace():
parts = line.split('=>')
if parts[0].strip():
@jojohannsen
jojohannsen / gist:7eac10ce17dd0ec093f914be5ba81cbb
Created May 10, 2022 15:54
python code to extract Person names from processed image json (test was pictures of bookshelves, author_names is result)
import itertools
import json
import jmespath
import sys
file_names = sys.argv[1:]
def parsed_names(file_names):
for file in file_names:
names = jmespath.search("entitiesExtracted[?category=='Person'].content", json.loads(open(file).read()))
@jojohannsen
jojohannsen / fails.rb
Created August 26, 2021 19:39
something not right here
#!/usr/bin/env ruby
# This file is used by our CI to send build information to symphony for your viewing pleasure.
require 'open3'
require "uri"
require "net/http"
require 'json'
hash = ARGV[0]
service_account_key = ARGV[1]
service_account_secret = ARGV[2]