Skip to content

Instantly share code, notes, and snippets.

@JaHIY
JaHIY / decode_m_notation.cpp
Created April 22, 2022 05:27
decode M notation from cat -v
#include <iostream>
using std::cin;
using std::cout;
using std::getline;
using std::endl;
#include <string>
using std::string;
#include <string_view>
@JaHIY
JaHIY / rime2fcitx.awk
Last active April 7, 2022 06:11
convert rime dict format to fcitx dict format
#!/usr/bin/awk -f
# Requirement:
# - pypinyin
# - sed
# How to use
# $ ./rime2fcitx.awk '/usr/share/rime-data/opencc/emoji_category.txt' > emoji_category_fcitx.txt
BEGIN {
@JaHIY
JaHIY / emoji_category_fcitx.txt
Created April 4, 2022 13:45
emoji dict files for fcitx pinyin ( from https://github.com/rime/rime-emoji )
👳🏽 a'la'bo'ren 0.9
🧔🏽 a'la'bo'ren'nan 0.9
👳🏽‍♂️ a'la'bo'ren'nan 0.9
🧕🏽 a'la'bo'ren'nv 0.9
👳🏽‍♀️ a'la'bo'ren'nv 0.9
🧓🏼 bai'ren 0.9
🧑🏼 bai'ren 0.9
🧒🏼 bai'ren 0.9
👱🏼 bai'ren 0.9
👶🏼 bai'ren 0.9
@JaHIY
JaHIY / uniq_array.cpp
Last active March 27, 2022 08:08
uniq array in-place
#include <iostream>
using std::cout;
using std::endl;
#include <vector>
using std::vector;
#include <algorithm>
using std::swap;
@JaHIY
JaHIY / tgvs-to-gif.sh
Last active March 23, 2022 11:23
convert telegram video sticker (webm) to animated gif
#!/usr/bin/env sh
find . -name '*.webm' -type f -print0 | xargs -0 -I'{}' -n 1 -- bash -c 'ffmpeg -y -loglevel warning -c:v libvpx-vp9 -i "$0" "${0%.*}.webp"' '{}'
gimp -d -f -n -i -b '(define (webp->gif filename) (let* ((image (car (file-webp-load RUN-NONINTERACTIVE filename filename))) (drawable (car (gimp-image-get-active-layer image))) (new-filename (string-append (substring filename 0 (- (string-length filename) 5)) ".gif"))) (gimp-image-convert-indexed image CONVERT-DITHER-NONE CONVERT-PALETTE-GENERATE 255 FALSE TRUE "") (file-gif-save RUN-NONINTERACTIVE image drawable new-filename new-filename FALSE TRUE 0 2) (gimp-image-delete image))) (define (batch-webp->gif pattern) (let* ((filelist (cadr (file-glob pattern 1)))) (for-each webp->gif filelist))) (batch-webp->gif "*.webp")' -b '(gimp-quit 0)'
@JaHIY
JaHIY / replaceAll.cpp
Created February 26, 2022 10:21
replaceAll function in C++
#include <iostream>
using std::cout;
using std::endl;
#include <string>
using std::string;
using std::basic_string;
#include <string_view>
using std::basic_string_view;
@JaHIY
JaHIY / PKGBUILD
Last active October 12, 2019 08:18
Arch Linux PKGBUILD for nim 1.0.0
# Modified by JaHIY (https://github.com/JaHIY)
# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Alexander F Rødseth <[email protected]>
# Contributor: Dominik Picheta <[email protected]>
# Contributor: Sven-Hendrik Haase <[email protected]>
# Contributor: Jesus Alvarez <[email protected]>
pkgname=nim
pkgver=1.0.0
@JaHIY
JaHIY / yanghui.fs
Last active August 5, 2018 14:11
Yang Hui's triangle, Pascal's triangle in F#
let rec getNext' (line : int list) result i =
if i < (List.length line) - 1 then
getNext' line ((line.[i] + line.[i + 1]) :: result) (i + 1)
else
1 :: result
let getNext line =
getNext' line [1] 0
let rec get' n result i =
@JaHIY
JaHIY / soundex.erl
Last active April 12, 2018 13:07
Soundex algorithm in Erlang
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname soundex -mnesia debug verbose
main([String]) ->
Word = soundex(String),
io:format("~s => ~s\n", [String, Word]);
main(_) ->
usage().