Skip to content

Instantly share code, notes, and snippets.

@braindevices
braindevices / systemd-timer-restart-bug.sh
Last active December 20, 2023 17:39
strange systemd timer bug: restart the timer trigger the unit run
#!/bin/bash
set -x
systemctl -T -o verbose daemon-reload
systemctl -T -o verbose disable --now test-timer.timer
set -e
wait_secs=20
run_at_time=$(date -d "+${wait_secs}sec" +"%H:%M:%S")
logfile=/tmp/test-timer-output
if [ -f ${logfile} ]
then
@braindevices
braindevices / how_docker_firewalld_libvirt_implement_rules.md
Last active November 4, 2023 19:25
how lbvirt/docker interact weith firewalld

docker just do not get along with libvirt, iptables, nptables, firewalld, etc

why my container isolation comes and gos? iptables, nptables, firewalld, who did what?!

there is almost NOT legacy iptables command (iptables) on modern OS (RHEL8, ubuntu22, etc) there can still be some lagecy ip_tables module loaded:

lsb_release -d; lsmod | grep tables; iptables -V
Description:    Fedora release 38 (Thirty Eight)
nf_tables             368640  1454 nft_compat,nft_chain_nat
nfnetlink              20480  8 nft_compat,nfnetlink_acct,nf_conntrack_netlink,nf_tables,ip_set
Description:    Red Hat Enterprise Linux release 8.8 (Ootpa)
@braindevices
braindevices / auto_textwrap_in_pandas_styler.md
Created February 14, 2023 21:47
how to autowrap the text in excel when export from pandas dataframe styler

The styler gives us a easy way to format the dataframe and maintain the format across different kind of output: html, excel, etc.

However, one of my friends has spot a problem of it, the styler.to_excel() output some how supressed some advanced formating of XlsxWriter. Here is an example:

import pandas as pd
data = pd.DataFrame({"A":list(range(10,12)), "B":["abcdefgafafadf", "afbafafafafadfadfadf"]})
with pd.ExcelWriter("/tmp/test.xlsx") as writer:
    data.style.apply(lambda x: ['background-color: red']*2 if x['A']==11 else [None]*2, axis=1).to_excel(writer, index=False)
 writer.sheets["Sheet1"].write(3, 1, "Some long text to wrap in a cell")
@braindevices
braindevices / #btrfs benchmark for daily used desktop OS
Last active April 24, 2024 10:46
which file sytem to use for daily work? should we turn on btrfs compression?
#btrfs benchmark for daily used desktop OS
1–10 11–20 20–30
6940 5839 6007
6615 6957 6314
6169 6877 6224
6142 6324 6210
6492 6685 6961
6908 5964 6475
@braindevices
braindevices / dnsmasq-gfwlist.py
Created May 31, 2017 17:58 — forked from lanceliao/dnsmasq-gfwlist.py
将gfwlist转换成带ipset的dnsmasq规则,适用于OpenWrt智能上网
#!/usr/bin/env python
#coding=utf-8
#
# Generate a list of dnsmasq rules with ipset for gfwlist
#
# Copyright (C) 2014 http://www.shuyz.com
# Ref https://code.google.com/p/autoproxy-gfwlist/wiki/Rules
import urllib2
import re
@braindevices
braindevices / get_tushare_data.py
Created April 10, 2017 16:46 — forked from xgdgsc/get_tushare_data.py
get tushare data
# coding: utf-8
import tushare as ts
import pandas as pd
import pickle
stock_list = ts.get_stock_basics()
# In[ ]: