Skip to content

Instantly share code, notes, and snippets.

@briprowe
briprowe / scrape-scripts.go
Created February 26, 2024 15:20
scrape-scripts.go
package main
import (
"fmt"
"os"
"slices"
"golang.org/x/net/html"
)
import itertools
import pandas as pd
LIMIT = 100
def get_logs(page_number: int):
r = requests.get(
"https://ecomedes-prod.us.auth0.com/api/v2/logs",
headers={
from abc import ABC, abstractmethod
import csv
from typing import *
T = TypeVar("T")
class FromRow(ABC, Generic[T]):
"""
A class that can be constructed from a row of CSV data.
use std::path::PathBuf;
use crates_index;
fn main() {
let index = crates_index::Index::new(PathBuf::from("./cargo_index"));
if !index.exists() {
index
.retrieve()
use std::path::PathBuf;
use crates_index;
fn main() {
let index = crates_index::Index::new(PathBuf::from("./cargo_index"));
if !index.exists() {
index
.retrieve()
@briprowe
briprowe / cider-has-zero-stability.clj
Created March 19, 2021 18:07
Clojure's primary emacs tool, CIDER, breaks quite regularly for no apparent reason.
user> (go) ;; start my dev system
Syntax error (ClassNotFoundException) compiling at (dev.clj:1:1).
clojure.core.async.Mutex
ERROR: Unhandled REPL handler exception processing message {:nrepl.middleware.print/stream? 1, :nrepl.middleware.print/print cider.nrepl.pprint/pprint, :nrepl.middleware.print/quota 1048576, :nrepl.middleware.print/buffer-size 4096, :nrepl.middleware.print/options {:right-margin 70}, :op stacktrace, :session 5e397a7b-f0de-4453-bef1-bd98950e98ba, :id 8}
java.lang.NoClassDefFoundError: Could not initialize class clojure.core.async.impl.channels__init
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at clojure.lang.RT.classForName(RT.java:2211)
at clojure.lang.RT.classForName(RT.java:2220)
at clojure.lang.Compiler.maybeResolveIn(Compiler.java:7438)
(defn tree-seq
"Returns a lazy sequence of the nodes in a tree, via a depth-first walk.
branch? must be a fn of one arg that returns true if passed a node
that can have children (but may not). children must be a fn of one
arg that returns a sequence of the children. Will only be called on
nodes for which branch? returns true. Root is the root node of the
tree."
{:added "1.0"
:static true}
[branch? children root]
@briprowe
briprowe / delete_indexes.sh
Created January 24, 2020 21:57
Delete elasticsearch indexes that aren't in use.
#!/usr/bin/env bash
set -e
host=${1:-"`minikube ip`:30200"}
old_indexes=$(curl "$host/_all" | \
jq -r 'to_entries | map(select(.value.aliases|has("ecomedes")|not)) | map(.key) | map(select( . != "migrations"))|.[]')
for i in $old_indexes; do
@briprowe
briprowe / lmdb.clj
Created August 14, 2019 15:41
LMDB wrapper for clj
(ns ecomedes.lmdb
(:refer-clojure :exclude [read])
(:require [clojure.java.io :as io]
[com.stuartsierra.component :as comp]
[taoensso.nippy :as nippy])
(:import [org.lmdbjava
CursorIterator
DbiFlags
Env
EnvFlags
@briprowe
briprowe / layout.clj
Last active June 5, 2019 15:03
This is why lisps are good!
(defmacro layout
[layout]
(let [args-destructurer (into {} (comp (remove (comp not symbol?))
(map (juxt identity (comp keyword name))))
(flatten layout))]
`(fn [~args-destructurer]
~layout)))
(def layouts
{:default-with-sorts