Skip to content

Instantly share code, notes, and snippets.

from functools import cache
import pygraphviz as pgv
import binarytree as btree
null = None
def from_adj_list(edges):
G = pgv.AGraph()
def process(s, d):
for v in [s, d]:
if not G.has_node(v):
@ayush--s
ayush--s / Dockerfile
Created December 17, 2023 07:27
docker custom runtime
FROM public.ecr.aws/lambda/provided:latest
COPY bootstrap ${LAMBDA_RUNTIME_DIR}
COPY function.sh ${LAMBDA_TASK_ROOT}
RUN chmod a+x ${LAMBDA_RUNTIME_DIR}/bootstrap
CMD [ "function.handler" ]
FROM caddy:2.6.2-builder-alpine AS builder
RUN xcaddy build \
--with github.com/caddyserver/nginx-adapter \
--with github.com/hairyhenderson/[email protected]
FROM caddy:2.6.2-alpine
COPY Caddyfile /etc/caddy/Caddyfile
@ayush--s
ayush--s / finds.csv
Last active September 5, 2022 07:56
spotify playlist dump
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 3.
"Track URI","Track Name","Artist URI(s)","Artist Name(s)","Album URI","Album Name","Album Artist URI(s)","Album Artist Name(s)","Album Release Date","Album Image URL","Disc Number","Track Number","Track Duration (ms)","Track Preview URL","Explicit","Popularity","Added By","Added At"
"spotify:track:4axJVUV9DMlM9YdeI0uhOM","1972","spotify:artist:4HF38EKEfCpf5qexvLmt2E","Tobias","spotify:album:2bKTPc28bPoq57uE4FXxw9","1972","spotify:artist:4HF38EKEfCpf5qexvLmt2E","Tobias","2020-02-14","https://i.scdn.co/image/ab67616d0000b273e2c4a4d38ef2a11eb8d85389","1","1","525769","https://p.scdn.co/mp3-preview/af0384223822b0060b31c8d58c5d4be349846ea6?cid=9950ac751e34487dbbe027c4fd7f8e99","false","7","spotify:user:ayush--s","2020-03-21T20:45:54Z"
"spotify:track:4cOVTA2GfYTHw99AJDQpHo","The Worst In Me","spotify:artist:6qgnBH6iDM91ipVXv28OMu, spotify:artist:0NIIxcxNHmOoyBx03SfTCD","KAYTRANADA, Tinashe","spotify:album:5FQ4sOGqRWUA5wO20AwPcO","BUBBA","spotify:artist:6qgnBH6iDM91ipVXv28OMu","KAYTRANADA","2019-12-13","https://i.sc
@ayush--s
ayush--s / chunk-details.sql
Created October 15, 2021 10:27
get chunk size + start, end for given table in timescaledb
WITH size AS (
SELECT
concat(chunk_schema, '.', chunk_name) AS name,
round(table_bytes / (1024 * 1024.0), 2) AS table_megs,
round(index_bytes / (1024 * 1024.0), 2) AS index_megs,
round(total_bytes / (1024 * 1024.0), 2) AS total_megs
FROM
chunks_detailed_size ('%%table%%')
ORDER BY
chunk_name,
#!/usr/bin/bash
# convert '*.png[800x>]' main.png
for i in *.png ; do
pngquant --quality 90 --speed 1 $i --output fin/final-$i --force
done
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
@ayush--s
ayush--s / Dockerfile
Created September 20, 2020 10:13
poetry
FROM ubuntu:focal
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python3.8 wget python3-distutils python3-venv \
&& rm -fr /var/cache/apt/*
RUN wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py -O get-pip.py \
&& python3.8 get-pip.py \
#!/bin/bash
intern=LVDS-1
extern=HDMI-1
if xrandr | grep "$extern disconnected"; then
xrandr --output "$extern" --off --output "$intern" --auto
else
xrandr --output "$intern" --off --output "$extern" --auto
fi
import os
from datetime import date
import requests
from slugify import slugify
BASE = "https://www.bing.com"
URL = "https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt={}"
MARKETS = {"en-US", "en-GB", "ja-JP"}