Skip to content

Instantly share code, notes, and snippets.

@jizhilong
jizhilong / Parsers.java
Created October 13, 2019 05:51
a simple parsec like parer combinator toll in java 8
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@jizhilong
jizhilong / cswsnoop
Last active October 19, 2019 07:47
snoop commands with context switch freqency more than 1000/s
#!/usr/bin/env python
'''
count occurence rate of lines with certain keyword with ewma algorithm.
'''
import math
import time
import sys
@jizhilong
jizhilong / cswsnoop_jvm.py
Created May 25, 2020 11:45
count and sort jvm threadpool's context switch rate
#!/usr/bin/env python
"""
Author: Ji.Zhilong <[email protected]>
Description: count and sort jvm threadpool's context switch rate
Usage: python cswsnoop_jvm.py
"""
import sys
import time
import os
@jizhilong
jizhilong / gitlab-ci-job-rules-cheatsheet.md
Created December 22, 2021 07:52
gitlab ci job rules cheat sheet

only if

only master branch

rules:
  - if: '$CI_COMMIT_BRANCH == "master"'
    when: always
  - when: never

only tags

@jizhilong
jizhilong / timerfd.py
Last active February 20, 2024 05:32
timerfd_create/timerfd_settime/timerfd_gettime implementations based on ctypes and libc
"""
timerfd_xx functions and demos for python versions prior to 3.13, implemented with ctypes and libc.
"""
try:
from os import timerfd_create, timerfd_settime, timerfd_gettime, timerfd_settime_ns, timerfd_gettime_ns
from os import TFD_NONBLOCK, TFD_CLOEXEC, TFD_TIMER_ABSTIME, TFD_TIMER_CANCEL_ON_SET
except ImportError:
import os
import time
from typing import Optional
@jizhilong
jizhilong / generate-toc-for-afciaa-pdf.sh
Last active February 10, 2025 10:14
toc file for a-first-course-in-abstract-algebra-jb-fraleigh-7ed2003.pdf
$ pip install -U pdf.tocgen
$ pdftocio in.pdf < toc