Skip to content

Instantly share code, notes, and snippets.

@bonprosoft
bonprosoft / Makefile
Created Jul 20, 2022
Makefile for buf.build
View Makefile
BASE_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
define BUF
@docker run --volume "$(BASE_DIR):/workspace" -e HOME=/tmp --workdir /workspace -u `id -u`:`id -g` bufbuild/buf $(1)
endef
.PHONY: all generate lint
all: generate
@bonprosoft
bonprosoft / tile_video.py
Created Jun 27, 2022
Create a tiled layout video
View tile_video.py
import argparse
import itertools
import os
import pathlib
import shlex
from typing import List
def _accumulated_size(idx: int, prefix: str) -> str:
if idx == 0:
@bonprosoft
bonprosoft / solve_sandstorm.py
Last active Oct 20, 2019
SECCON 2019 Online CTF: sandstorm
View solve_sandstorm.py
import cv2
import numpy
image = cv2.imread('./sandstorm.png')
height, width = image.shape[:2]
new_height = height // 8
new_width = width // 8
new_image = numpy.zeros((new_height, new_width, 3))
@bonprosoft
bonprosoft / solve_repair.py
Last active Oct 20, 2019
SECCON 2019 Online CTF: repair
View solve_repair.py
import argparse
import fractions
import io
from itertools import count
from av import Codec
from av.packet import Packet
class Decoder:
@bonprosoft
bonprosoft / fuga.py
Last active Sep 20, 2019
mock.patch 検証2
View fuga.py
import hoge
from hoge import A
def print_value():
instance = A()
print(instance.value)
def print_value2():
@bonprosoft
bonprosoft / hoge.py
Created Sep 20, 2019
mock.patchの検証
View hoge.py
import threading
import time
from unittest import mock
class Hoge:
b = 10
a = Hoge()
@bonprosoft
bonprosoft / stdin_iter.py
Last active Aug 28, 2018
sys.stdinの挙動の違い
View stdin_iter.py
import sys
for x in sys.stdin:
sys.stdout.write('stdin: {}'.format(x))
sys.stdout.flush()
"""Output.
[py36]
hoge
View perf_cudnn.py
import cProfile
import random
import cupy
from cupy import cudnn
libcudnn = cudnn.cudnn
N_LAYER = 10
N_TESTCASE = 1000
@bonprosoft
bonprosoft / result
Last active Sep 11, 2017
Validation of cuDNN dropout function behavior
View result
False
True
View perf_cudnn.py
import cProfile
import random
import cupy
from cupy import cudnn
libcudnn = cudnn.cudnn
N_LAYER = 10
N_TESTCASE = 1000