Skip to content

Instantly share code, notes, and snippets.

View ramsayleung's full-sized avatar

0xae86 ramsayleung

View GitHub Profile
@ramsayleung
ramsayleung / LinuxFind.java
Created April 21, 2024 22:26
Solution for Unix Find command OOD design
package ramsayleung.github.io.ood;
// Problem statement:
// Design Unix File Search API to search file with different arguments as "extension", "name", "size" ...
// The design should be maintainable to add new contraints.
//
// Follow up: How would you handle if some contraints should support AND, OR conditionals.
import java.util.ArrayList;
import java.util.List;
@ramsayleung
ramsayleung / SearchCriteria.java
Last active April 21, 2024 21:21
OOD solution for search criteria design problem
/*
Problem statement:
Designed and implemet a search criteria model library, leverage proper OO principles and construct.
Your model should be able to handle criteria such as the following expression:
name == "foo"
age > 100
(age > 100 & age < 100)
(age > 100 & age < 100) or (name == "foo" and not(age == 50 or age == 51))
etc.
@ramsayleung
ramsayleung / hugomd2md.sh
Last active January 27, 2023 01:17
Hugo markdown to standard markdown
set -ex
remove_heading_tag () {
# ## <span class="section-num">1</span> 前言 {#前言} => ## <span class="section-num">1</span> 前言
# 删除 {#前言}
sed 's/{#.*}//' $1
}
remove_meta_info () {
# 删除下列信息
@ramsayleung
ramsayleung / benchmark.log
Last active November 19, 2019 14:04
benchmark log
# JMH version: 1.19
# VM version: JDK 1.8.0_171, VM 25.171-b11
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/jre/bin/java
# VM options: -Dvisualvm.id=214723528752700 -javaagent:/Users/samray/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/192.7142.36/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=61627:/Users/samray/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/192.7142.36/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8
# Warmup: 5 iterations, 1 s each
# Measurement: 10 iterations, 5 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: beanutils.BeanUtilsBenchmark.testApacheBeanUtils
@ramsayleung
ramsayleung / AlphaNum.java
Last active November 18, 2019 09:41
AlphaNum
/**
* @author RamsayLeung/ramsayleung@gmail.com
* @version : AlphaNum.java, v 0.1 2019年11月18日 14:33 samray Exp $
*/
public class AlphaNum {
private String _A;
private String _B;
private String _C;
private String _D;
private String _E;
@ramsayleung
ramsayleung / cloudSettings
Last active May 16, 2019 14:10
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-05-16T14:10:08.466Z","extensionVersion":"v3.2.9"}
@ramsayleung
ramsayleung / 0_reuse_code.js
Created July 27, 2016 10:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console