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 September 19, 2024 16:20
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}"
@RayPS
RayPS / convert-clipboard-image.py
Last active August 13, 2024 03:37
Converting image format in clipboard - macOS Python (Copied as PNG, Paste as JPG)
from PIL import Image
import io
import pasteboard
pb = pasteboard.Pasteboard()
pb_image = pb.get_contents(pasteboard.TIFF)
if pb_image:
image = Image.open(io.BytesIO(pb_image))
if image.mode == 'RGBA':
image.load()
@FreddieOliveira
FreddieOliveira / docker.md
Last active November 19, 2024 14:45
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 September 17, 2024 19:18
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 August 3, 2024 02:58
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 November 2, 2024 21:02
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
#