Skip to content

Instantly share code, notes, and snippets.

import hashlib
import json
import os
import time
from concurrent.futures import Future, ThreadPoolExecutor
from functools import lru_cache
from pathlib import Path
from typing import Any, Dict, List, Literal, Optional
import requests
@carpedm20
carpedm20 / head_reducer.py
Last active September 27, 2025 00:14
head_reducer.py
# {ai/scripts/head/head_reducer.py}
"""
Head size adjustment based on head-to-body ratio
Pipeline
1) Person pose with YOLOv8 to estimate full body height in pixels
2) Head box with MediaPipe Face Detection
3) Compute shrink/enlarge factor from target head count (or ratio)
4) Apply smooth elliptical radial warp
https://docs.google.com/presentation/d/1EgG3jmUwJjZb64_U-x-yWZCJqajXwsQX/edit?usp=sharing&ouid=113640288960877923196&rtpof=true&sd=true

Intercepts HTTPs Traffic with Python & mitmproxy

Introduction

Modern applications usually make use of back-end API servers to provide their services. With a non-transparent HTTPs proxy, which intercepts the communication between clients and servers (aka the man-in-the-middle scheme), you can easily manipulate both API requests and responses.

This manual helps you create your own proxy with Python and mitmproxy/libmproxy. Mitmproxy ships with both a standalone command-line tool (mitmproxy) and a Python library (libmproxy).

@carpedm20
carpedm20 / matzip.py
Last active September 11, 2018 07:37
#-*- coding: utf-8 -*-
import json
import requests
from tqdm import tqdm
DIST = 0.01
HEADERS = {
@carpedm20
carpedm20 / resize.sh
Created October 7, 2014 14:39
Image-net 2012
#!/bin/sh
image_path=/home/carpedm20/imagenet
for name in $image_path/val/*.JPEG; do
convert -resize 256x256\! $name $name
done
@carpedm20
carpedm20 / Dockerfile
Last active December 4, 2016 15:51
Dockerfile
FROM dockerfile/ubuntu
MAINTAINER Taehoon Kim(carpedm20@gmail.com)
# Run upgrades
RUN apt-get update
# Install basic packages
RUN apt-get -qq -y install git curl build-essential openssl libssl-dev python-software-properties g++ make
# Install Python
@carpedm20
carpedm20 / README.md
Created July 14, 2016 19:01
NAF-tensorflow writeup

NAF-tensorflow

First, clone the project:

git clone https://github.com/devsisters/NAF-tensorflow/
cd NAF-tensorflow

To train a model for Pendulum:

python main.py --env_name=Pendulum-v0 --is_train=True

@carpedm20
carpedm20 / README.md
Last active June 20, 2016 03:42
DQN-tensorflow writeup

DQN-tensorflow

First, clone the project:

git clone https://github.com/devsisters/DQN-tensorflow/
cd DQN-tensorflow

To train a model for Breakout:

python main.py --env_name=Breakout-v0 --is_train=True

import requests
r = requests.get("http://naver.com")
html = r.text
idx = html.find("<title>")
print html[idx:idx+20]