Skip to content

Instantly share code, notes, and snippets.

@raphaeljolivet
raphaeljolivet / api.py
Created November 15, 2023 16:48
Add custom rest API to streamlit app
# This code adds custom REST api handler at runtime to a running Streamlit app
#
from tornado.web import Application, RequestHandler
from tornado.routing import Rule, PathMatches
import gc
import streamlit as st
@st.cache_resource()
@tyanyaw
tyanyaw / clean-docker-for-mac.sh
Created September 2, 2023 10:20
Cleaning Docker.raw on Mac OS
#!/bin/bash
# Copyright 2017 Théo Chamley
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
# to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
@hyperupcall
hyperupcall / settings.jsonc
Last active July 21, 2024 10:53
VSCode config to disable popular extensions' annoyances (telemetry, notifications, welcome pages, etc.)
// I'm tired of extensions that automatically:
// - show welcome pages / walkthroughs
// - show release notes
// - send telemetry
// - recommend things
//
// This disables all of that stuff.
// If you have more config, leave a comment so I can add it!!
{
@mskyttner
mskyttner / duckdb_buenavista_psql.sh
Created January 16, 2023 06:48
duckdb exposed by buenavista proxy and accessed with psql
# start a proxy server for a duckdb in-memory db, using the postgres wire format
docker run -it --rm -p 8080:5433 -e BUENAVISTA_HOST=0.0.0.0 -e BUENAVISTA_PORT=5433 ghcr.io/jwills/buenavista
# somewhere else (or here on the same host), start psql to issue a query against the proxy server
docker run --network host -it --rm postgres:latest psql -h $(hostname) -p 8080 -c "select 42"
@esc5221
esc5221 / delete_gha_runs_by_name.py
Created December 14, 2022 10:36
delete github actions workflow runs by name
# resolves : Is there a way to delete or hide old/renamed Workflows? #26256
# https://github.com/community/community/discussions/26256
from multiprocessing.dummy import Pool as ThreadPool
import requests
TOKEN = "{YOUR_GH_TOKEN}"
OWNER_REPO = "esc5221/example_repo"
DELETE_TARGET_RUN_NAME = "{RUN NAME}"
@FreddieOliveira
FreddieOliveira / docker.md
Last active July 17, 2024 01:42
This tutorial shows how to run docker natively on Android, without VMs and chroot.

Docker on Android 🐋📱

Edit 🎉

All packages, except for Tini have been added to termux-root. To install them, simply pkg install root-repo && pkg install docker. This will install the whole docker suite, left only Tini to be compiled manually.


Summary

@xiaopc
xiaopc / draw_table.py
Last active April 29, 2024 08:27
Draw a table using only Pillow
from PIL import Image, ImageFont, ImageDraw
from collections import namedtuple
def position_tuple(*args):
Position = namedtuple('Position', ['top', 'right', 'bottom', 'left'])
if len(args) == 0:
return Position(0, 0, 0, 0)
elif len(args) == 1:
return Position(args[0], args[0], args[0], args[0])
@veuncent
veuncent / youtube_analytics_oauth.md
Last active May 16, 2024 19:28
Authentication for Google / YouTube Analytics using a Brand Account

Google / YouTube Authentication using a Brand Account

Below describes the only way I was able to get (programmatic) access to the YouTube Analytics API on behalf of our Brand Account. Google documentation is convoluted, to say the least, so if you know a more straightforward way, please do share.

Getting a Client ID and Refresh Token

  1. Create a Project in the Developers Console - https://console.developers.google.com/
  2. Go to the Library tab and enable desired APIs (e.g. YouTube Analytics)
  3. Go to OAuth consent screen and make project external. Select Test mode
@mkczyk
mkczyk / .git-plugin-bash.sh
Last active June 14, 2024 06:26
Git aliases for bash (based on Oh My Zsh Git plugin)
#!/bin/bash
# To ~/.bashrc file add line:
# source ~/.git-plugin-bash.sh
# Based on Oh My Zsh Git plugin (without zsh functions):
# https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/git/git.plugin.zsh
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git
#
@carlwgeorge
carlwgeorge / yum-clean-all-demystified.md
Last active May 16, 2024 05:16
yum clean all demystified

TLDR:

  • yum clean all == clean most
  • rm -rf /car/cache/yum/* == really clean everything

From the man page:

Note that these commands only operate on files in currently enabled
repositories. If you use substitution variables (such as $releasever) in your cachedir configuration, the operation is further restricted to the current
values of those variables.