Skip to content

Instantly share code, notes, and snippets.

View teticio's full-sized avatar

Robert Dargavel Smith teticio

View GitHub Profile
@teticio
teticio / pipenv_migrate
Last active August 16, 2022 19:36
Pipenv automatically assigns names to the virtual environments based on a hash of the directory where the Pipfile resides. If this directory is moved, then pipenv will no longer find the venv. Not only does the virtual environment (venv) have to be renamed, but all references to it (e.g., in shebangs) must also be updated.
#/usr/bin/env bash
######################################################################
# Pipenv automatically assigns names to the virtual environments #
# based on a hash of the directory where the Pipfile resides. If #
# this directory is moved, then pipenv will no longer find the venv. #
# Not only does the virtual environment (venv) have to be renamed, #
# but all references to it (e.g., in shebangs) must also be updated. #
######################################################################
@teticio
teticio / competitive-landscape.py
Last active February 14, 2022 15:06
Rank competitors by leveraging Google's autocomplete function while searching for "<target> vs"
import argparse
import requests
from tqdm import tqdm
from pprint import pprint
from itertools import islice
from urllib.parse import quote
from functools import lru_cache
from collections import Counter, OrderedDict
@teticio
teticio / config
Last active December 26, 2021 18:19
Jupyter notebook extension code prettifier configuration for Rust
"rust": {
"library": "extern crate serde_json; extern crate rustfmt;",
"prefix": "{ use std::fs::File; use serde_json::json; use crate::rustfmt::{format_input, Input, config::Config}; let config = Config::default(); let input = Input::Text(",
"postfix": ".into()); let (summary, filemap, _) = format_input::<File>(input, &config, Option::None).unwrap(); if summary.has_no_errors() { let (_, output) = &filemap[0]; println!(\"{}\", json!(output.to_string())); } }"
}
@teticio
teticio / model.py
Created April 5, 2021 00:09
Run inference with Tensorflow Lite on iOS, Android, MacOS, Windows and Linux using Python
import numpy as np
from kivy.utils import platform
if platform == 'android':
from jnius import autoclass
File = autoclass('java.io.File')
Interpreter = autoclass('org.tensorflow.lite.Interpreter')
InterpreterOptions = autoclass('org.tensorflow.lite.Interpreter$Options')
Tensor = autoclass('org.tensorflow.lite.Tensor')