Skip to content

Instantly share code, notes, and snippets.

View sawaYch's full-sized avatar
🐧
Focusing

Sawa sawaYch

🐧
Focusing
View GitHub Profile
@sawaYch
sawaYch / chall.py
Created December 6, 2023 15:12
hkcert23 ctf sign me a flag
import signal
import os
import hmac
import hashlib
import sys
def tle_handler(*args):
print('⏰')
sys.exit(0)
@sawaYch
sawaYch / b141.py
Created December 5, 2023 12:09
B141:【異世界コラボ問題】ガーベラ・コレクション
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ!!
def min_adjacent_swap(arr):
swap_times = 0
n = len(arr) / 2
iter = 0
while iter < len(arr) - 1:
# if current not ideal
if arr[iter] != iter % n:
@sawaYch
sawaYch / convert.js
Last active September 6, 2023 00:37
batch convert webp to webm, maybe useful for converting Whatsapp sticker to Telegram.
/**
require webp & libwebp, see https://developers.google.com/speed/webp/download
run:
cd working_dir # suppose working dir contains all webp that u want to convert
node ./convert.js # wait for it until done
*/
const child = require("child_process");
const fs = require("fs");
const path = require("path");
const util = require("util");
@sawaYch
sawaYch / example.ts
Created June 2, 2023 13:18
override yup date() default typeError validation message
// https://github.com/jquense/yup/issues/394
import i18next from "i18next";
import { setLocale } from "yup";
export const setFormikLocale = (i18n: typeof i18next): void => {
// Config yup validation schema default error message
setLocale({
mixed: {
notType: (_ref) => {
@sawaYch
sawaYch / mp4-to-gif.md
Created March 7, 2023 05:54
MP4 to gif
ffmpeg -i ./input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos" -c:v pam \
    -f image2pipe - | \
    convert -delay 10 - -loop 0 -layers optimize output.gif
@sawaYch
sawaYch / yt-dlp.md
Last active April 20, 2024 07:52
yt-dlp readme

yt-dlp usage

# check format & codec
yt-dlp -F https://www.youtube.com/watch?v=vWsmn3-7scs
# output
[info] Available formats for vWsmn3-7scs:
ID  EXT RESOLUTION FPS │   FILESIZE   TBR PROTO │ VCODEC        VBR ACODEC      ABR ASR MORE INFO
────────────────────────────────────────────────────────────────────────────────────────────────────────────
139 m4a audio only     │ ~ 66.18MiB   64k dash  │ audio only        mp4a.40.5   64k 22k DASH audio, m4a_dash
140 m4a audio only     │ ~148.90MiB  144k dash  │ audio only        mp4a.40.2  144k 44k DASH audio, m4a_dash
@sawaYch
sawaYch / drop_all_tables.sql
Created July 29, 2022 10:19
recursively drop all table (with FK constraint) on MSSQL DB
## create foreach storeprocedure first. If your db exist, then no need to do it.
CREATE proc [dbo].[sp_MSforeachtable]
@command1 nvarchar(2000), @replacechar nchar(1) = N'?', @command2 nvarchar(2000) = null,
@command3 nvarchar(2000) = null, @whereand nvarchar(2000) = null,
@precommand nvarchar(2000) = null, @postcommand nvarchar(2000) = null
AS
declare @mscat nvarchar(12)
select @mscat = ltrim(str(convert(int, 0x0002)))
if (@precommand is not null)
exec(@precommand)
@sawaYch
sawaYch / README.md
Created February 10, 2022 07:03
fix mac book dark screen and always boot to recovery assistant

This really scare me :/

The solution is to reset macbook's NVRAM / PRAM: https://support.apple.com/en-us/HT204063

  1. remember press Option + Command + P + R when the machine boot when you hear the first boot sound
  2. holding it around 20 seconds, until you hear second boot sound
  3. machine will boot
  4. success
@sawaYch
sawaYch / alacritty.yml
Last active January 12, 2022 21:36
Alacritty terminal configuration
env:
TERM: xterm-256color
cursor:
style: Block
font:
normal:
family: Source Code Pro for Powerline
size: 14
@sawaYch
sawaYch / aad-token-lifetime-payload.md
Last active December 22, 2021 04:53
Azure AD token lifetime payload

AAD Token lifetime payload

  1. Token Lifetime policy is apply to resource server (e.g. backend server app registration)
  2. Refresh Token lifetime is not use TokenLifeTimePolicy to config, but use conditional access sign-in frequency
{
  "TokenLifetimePolicy": {
    "Version": 1,
 "AccessTokenLifetime": "00:10:00",