Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
set -e
is_wsl() {
case "$(uname -r)" in
*microsoft* ) true ;; # WSL 2
*Microsoft* ) true ;; # WSL 1
* ) false;;
esac
}
#!/bin/bash
# install docker (with aliyun yum repo)
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
@ImSingee
ImSingee / save_with_encoding.py
Created July 14, 2020 08:20
以指定编码保存文件
target_encoding = "utf-16"
text = '''
# coding: utf-16
print("你好,世界")
'''
with open("/tmp/utf-16", "w", encoding="utf-16") as f:
f.write(text)
"""
Varint encoder/decoder
varints are a common encoding for variable length integer data, used in
libraries such as sqlite, protobuf, v8, and more.
Here's a quick and dirty module to help avoid reimplementing the same thing
over and over again.
For both python 2 and 3
"""
@ImSingee
ImSingee / README.md
Last active July 2, 2020 07:41 — forked from Ivlyth/README.md
zookeeper / kafka cluster 搭建及 kafka 集群加密认证, 客户端加密认证设置方法

zookeeper 与 kafka 集群设置教程, 作为教程, 下文描述的步骤是在 1台 服务器上部署 启动三个 zookeeper 和 kafka 服务以组成模拟集群, 多机上的注意事项会在相关位置说明

⚠️: 该教程完成于内网 10.0.81.9 这台 sensor 机器, 因此以下步骤中提到的 IP 10.0.81.9, 请在自己实验中更换为自己实验用机器的 IP 地址.
⚠️: 标记 FIXME 的均为在实际环境中需要注意的值(比如 ip, 端口, 文件路径), 其余值新增内容均为固定值

1. 创建必要的测试目录

mkdir -p /data/kafka-cluster-test/{kafka,zookeeper}-data-{1,2,3}

Keybase proof

I hereby claim:

  • I am imsingee on github.
  • I am singee (https://keybase.io/singee) on keybase.
  • I have a public key ASBguY9l2BZrkJ6wjo4vFkzx3dXxAa2VKROLs_e5RTiecAo

To claim this, I am signing this object:

@ImSingee
ImSingee / OmniFocus-计算任务时间.scpt
Created August 26, 2019 13:14
OmniFocus-计算任务时间,计算选中的一个或多个动作/项目的预估时间,如果选中的项目没有设定预估时间则会遍历求和未完成的子项的预估时间
on run {}
tell application "OmniFocus"
tell content of first document window of front document
set validSelectedItemsList to value of (selected trees where class of its value is not item and class of its value is not folder)
-- 未选择
if (count of validSelectedItemsList) is 0 then
display alert "未选择任何项" message "请选择一个或多个动作/项目后重试" as critical
return
end if
@ImSingee
ImSingee / OmniFocus-随机设定推迟时间.scpt
Created August 26, 2019 11:16
OmniFocus-随机设定推迟时间,将任务随机推迟至 14-90 天后的 5:00(推迟日期的上下界和时间可以在代码中相应位置修改)
--
-- based on a script originally file downloaded from:
-- http://c-command.com/scripts/omnifocus/defer-to-tomorrow
--
-- ========================================
-- Script to defer Omnifocus task to
-- random date in the future (emulation of "defer to random date" from iOS version
-- ========================================
-- It chooses a random number of days ranging from 14 to 90 days and adds to today's date
-- NB: That's the same values Omnifocus uses in their iOS version
@ImSingee
ImSingee / OmniFocus-设定连续的截止时间.scpt
Created August 26, 2019 11:14
OmniFocus-设定连续的截止时间,将选中的任务批量递增的设置截止时间;ADD_DAYS 用于配置每次加几天、PERIOD_TIMES 用于配置几个任务后进行增加。选中的首个任务的截止时间是「今天 + ADD_DAYS 天的 23:59」,即 ADD_DAYS 设置为 1 则首个任务的截止时间是明天的 23:59
on run {}
set ADD_DAYS to 1
set PERIOD_TIMES to 1
set _time to 0
set _date to current date
repeat with _action in my selectedActions()
if _time mod PERIOD_TIMES is equal to 0 then
set _date to calculateDate(_date, ADD_DAYS)
@ImSingee
ImSingee / OmniFocus - 清除推迟时间.scpt
Created August 26, 2019 11:12
OmniFocus - 清除截止时间,将选中的项目 / 动作的推迟时间删除
on run {}
set i to 1
repeat with _action in my selectedActions()
my processAction(_action, i)
set i to i + 1
end repeat
tell application "OmniFocus"
tell default document
compact
end tell