Skip to content

Instantly share code, notes, and snippets.

@6david9
6david9 / resize-png.rb
Last active November 13, 2024 09:31
Down scale png image from @3x to @2x, @1x
#! /usr/bin/env ruby
require 'mini_magick'
# gem install mini_magick
def resize_image(image_name, output_name)
current_scale = 3
if image_name.include?("@3x")
current_scale = 3
@6david9
6david9 / python_doc.js
Last active April 28, 2024 05:40
add table of contents to python library reference page.
// ==UserScript==
// @name Python doc toc
// @namespace http://tampermonkey.net/
// @version 2024-04-27
// @description Add table of contents to python doc.
// @author You
// @match https://docs.python.org/3/library/*.html
// @icon https://www.google.com/s2/favicons?sz=64&domain=python.org
// @grant none
// @run-at document-idle
payload:
- '+.openai.com'
- '+.sentry.io'
- '+.oaistatic.com'
- '+.livekit.cloud'
- '+.oaiusercontent.com'
- '+.ai.com'
- '+.openai.com.cdn.cloudflare.net'
- 'openaiapi-site.azureedge.net'
- 'openaicom-api-bdcpf8c6d2e9atf6.z01.azurefd.net'
#!/bin/bash
if ! command -v ffmpeg &> /dev/null
then
echo "ffmpeg could not be found"
echo "installing ffmpeg"
apt install ffmpeg -y
fi
if ! command -v whisper &> /dev/null
@6david9
6david9 / v2ex_cell.js
Last active April 14, 2023 05:40
simplify timeline cell.
// ==UserScript==
// @name v2ex_cell
// @namespace http://tampermonkey.net/
// @version 0.1
// @description simplify timeline cell.
// @author 6david9
// @match https://*.v2ex.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=v2ex.com
// @require https://code.jquery.com/jquery-3.6.3.min.js
// @run-at document-idle
@6david9
6david9 / v2ex.js
Last active January 20, 2023 04:17
remove background image.
// ==UserScript==
// @name v2ex
// @namespace http://tampermonkey.net/
// @version 0.1
// @description remove background image.
// @author 6david9
// @match https://*.v2ex.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=v2ex.com
// @grant none
// @run-at document-idle
// ==UserScript==
// @name v2ex_comment
// @namespace http://tampermonkey.net/
// @version 0.1
// @description simplify comment cell.
// @author 6david9
// @match https://*.v2ex.com/t/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=v2ex.com
// @require https://code.jquery.com/jquery-3.6.3.min.js
// @grant none
@6david9
6david9 / keybinding.json
Created February 8, 2022 10:20
custom shortcut for karabiner
{
"title": "Custom shortcut",
"maintainer": "ly",
"rules": [
{
"description": "format code in xcode",
"manipulators": [
{
"type": "basic",
"from": {
@6david9
6david9 / transcoding.txt
Last active February 12, 2022 16:59
transcoding video using nvidia gpu
# https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new
ffmpeg -c:v h264_cuvid -i "input.flv" -c:v h264_nvenc "output.mp4"
# add srt
ffmpeg -i infile.mp4 -i infile.srt -c copy -c:s mov_text outfile.mp4
ffmpeg -i infile.mkv -i infile.srt -c copy -c:s srt outfile.mkv
# resize
ffmpeg -i input.avi -filter:v scale=720:-1 -c:a copy output.mkv
ffmpeg -c:a ac3 -c:v hevc_cuvid -i "input.ts" -filter:v scale=-1:1080 -c:a aac -c:v hevc_nvenc "output.mp4"
@6david9
6david9 / cairo.cpp
Created December 28, 2021 08:27
hello world of cairo
#include <iostream>
#include <cairo/cairo.h>
#include <cairo/cairo-quartz.h>
int main(int argc, const char * argv[]) {
cairo_surface_t *surface = cairo_quartz_surface_create(CAIRO_FORMAT_RGB24, 320 * 3.0, 560 * 3.0);
cairo_t *cr = cairo_create(surface);
cairo_set_antialias(cr, CAIRO_ANTIALIAS_BEST);