Skip to content

Instantly share code, notes, and snippets.

@gd3kr
gd3kr / script.js
Created February 15, 2024 06:30
Download a JSON List of twitter bookmarks
/*
the twitter api is stupid. it is stupid and bad and expensive. hence, this.
Literally just paste this in the JS console on the bookmarks tab and the script will automatically scroll to the bottom of your bookmarks and keep a track of them as it goes.
When finished, it downloads a JSON file containing the raw text content of every bookmark.
for now it stores just the text inside the tweet itself, but if you're reading this why don't you go ahead and try to also store other information (author, tweetLink, pictures, everything). come on. do it. please?
*/
@amix
amix / query_customer_feedback.py
Last active July 25, 2023 17:52
Use LlamaIndex and GPT-3 to query customer insights
import os
import logging
import sys
import textwrap
from llama_index import (
GPTKeywordTableIndex,
SimpleDirectoryReader,
LLMPredictor,
)
@amtseng
amtseng / histogram.sh
Last active April 20, 2022 16:03
Simple commandline program to construct ASCII histograms
set -beEo pipefail
DEFAULTNUMBINS=10
DEFAULTMAXWIDTH=75
show_help() {
cat << EOF
Usage: ${0##*/} [OPTIONS]
Takes a set of numbers and plots an ASCII histogram. The input must be fed in
through stdin, and must consist of one number on each line.
@mwaskom
mwaskom / right_side_title.py
Created July 18, 2021 20:52
Put a title on the right y axis of a matplotlib axes using the set_title API.
import matplotlib as mpl
import matplotlib.pyplot as plt
f, ax = plt.subplots(figsize=(5, 5))
ax.set_title("Col title", y=1)
title = ax.set_title(
"Row title", loc="right", y=.5,
rotation=270, ha="left", va="center",
)
offset_trans = mpl.transforms.ScaledTranslation(
@33eyes
33eyes / commit_jupyter_notebooks_code_to_git_and_keep_output_locally.md
Last active April 19, 2024 12:41
How to commit jupyter notebooks without output to git while keeping the notebooks outputs intact locally
  1. Add a filter to git config by running the following command in bash inside the repo:
git config filter.strip-notebook-output.clean 'jupyter nbconvert --ClearOutputPreprocessor.enabled=True --to=notebook --stdin --stdout --log-level=ERROR'  
  1. Create a .gitattributes file inside the directory with the notebooks

  2. Add the following to that file:

*.ipynb filter=strip-notebook-output  
@thesamovar
thesamovar / legend2d.ipynb
Created August 18, 2020 15:42
2D Legend for matplotlib
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simonw
simonw / macos-machine-learning-models.md
Created May 21, 2020 15:46
Machine learning models installed on macOS is part of Vision.framework

Machine learning models installed on macOS is part of Vision.framework

I found these while poking around at the list of open files for photoanalysisd in Activity Monitor.

% ls -lahS /System/Library/Frameworks/Vision.framework/Versions/A/Resources
total 465616
-rw-r--r--    1 root  wheel    40M Dec 13 16:32 landmarks_v2.bin
-rw-r--r--    1 root  wheel    31M Dec 13 16:32 scenenet_sc2.4_sa1.4_ae1.4_r9_opt_int8.espresso.weights
-rw-r--r--    1 root  wheel    29M Dec 13 16:32 scenenet_sc2.4_sa1.4_ae1.6_r13.4_opt_int8_asymetric.espresso.weights
@ipudu
ipudu / rename_pdf.py
Created October 4, 2019 01:51
Rename an academic article pdf with human readable format
import sys
import requests
import PyPDF2
import requests
import os
crossref = 'http://api.crossref.org/'
def rename(pdf):
"""Rename an academic article pdf file with human readable format
@mgbckr
mgbckr / install_zsh_on_sherlock.sh
Last active April 8, 2024 05:49
Compiling and installing Zsh without root privileges on Stanford's Sherlock (https://sherlock.stanford.edu) for use in tmux
# Update 2023-07-20:
# I've recently switched to installing `zsh` via `conda` which is a lot less hassle.
# I added it to start automatically in `tmux` with
# `set-option -g default-shell "~/miniconda3/envs/default/bin/zsh"`
#
# # Install Zsh on Sherlock
# Installs Zsh with Oh-My-Zsh without root privileges
# on Stanford's Sherlock (https://sherlock.stanford.edu) for use in tmux
#
# ## Instructions
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API