Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# coding: utf-8
import pysubs2
import re
from stardict import DictCsv
# depend on https://github.com/skywind3000/ECDICT/
dict_filename="ecdict.csv"
sub_filename="01sub.srt"
@rainly
rainly / session-setup-script.sh
Created October 17, 2019 00:07 — forked from diyism/session-setup-script.sh
linux系统和应用目录都交错在一起了,用unionfs-fuse和pivot_root才能隔离,随系统启动:session-setup-script=session-setup-script.sh in /etc/lightdm/lightdm.conf @_:…boot+lib+(usr/)sbin+bin对SYS区,usr/(bin+lib+share)对APP区,etc+var公用
=================================pc lubuntu上, 2013年===========================================
#!/bin/sh
#chroot only for root user session
#pivot_root for whole system root directory changing
#sudo su
#mkdir /mnt/new_root #must be 755 root:root, or else sudo won't work: unable to stat /etc/sudoers: Permission denied
#mkdir /mnt/root #must be 755 root:root
#mkdir /mnt/rw #must be 755 root:root
@rainly
rainly / bj-unicom-iptv.m3u
Created August 4, 2019 17:17 — forked from sdhzdmzzl/bj-unicom-iptv.m3u
北京联通iptv列表
#EXTM3U name="bj-unicom-iptv"
#EXTINF:-1,天津卫视高清
rtp:///239.3.1.141:1234
#EXTINF:-1,爱上4K
rtp:///239.3.1.236:2000
#EXTINF:-1,山东教育
rtp:///239.3.1.52:4120
@rainly
rainly / 00README.md
Created June 13, 2019 02:16 — forked from natefoo/00README.md
Linux Distribution Detection

Distribution Detection

I am working on adding support for building and distributing (via PyPI) Python Wheels with C Extensions to the Python wheel and pip packages. The discussion on Distutils-SIG continues, but I believe it is fairly certain that some effort to correctly identify Linux distributions will need to be made. I've begun efforts to add this support to wheel.

How you can help

If you have a Linux distribution or version of a listed distribution not in this gist, or one of the ones I have not directly verified, I could use the following:

  • The contents of /etc/os-release, if it exists
import requests
import sys
import os
import json
MAX_PAGE = 10
if __name__ == "__main__":
'''https://<your_gitlab_site_address>/profile/personal_access_tokens'''
git_urls = []
@rainly
rainly / z.md
Created March 24, 2019 02:09 — forked from mischah/z.md
Installing und initializing z (https://github.com/rupa/z) with help of Homebrew.

#The power of z

Do you spend lots of time doing things like this?

cd this/is/the/path/that/i/want/so/i/type/it/all/out/to/get/whereiwant

With z, you could just do this:

pred='process matches ".*(ocker|vpnkit).*"
  || (process in {"taskgated-helper", "launchservicesd", "kernel"} && eventMessage contains[c] "docker")'

/usr/bin/log stream --style syslog --level=debug --color=always --predicate "$pred"
@rainly
rainly / gen_Corefile.sh
Created January 16, 2019 07:10 — forked from missdeer/gen_Corefile.sh
generate Corefile which uses your ISP's DNS servers to resolve domain names in China and uses OpenDNS/Cloudflare/Google DNS servers to resolve domain names outside China for CoreDNS. You should change 116.228.111.118 180.168.255.18 to your ISP's DNS server address or use public DNS server such as 114/DNSPod etc. directly.
#!/bin/bash
echo ". {" > Corefile
echo " forward . 208.67.222.222:443 208.67.222.222:5353 208.67.220.220:443 208.67.220.220:5353 tls://1.0.0.1 tls://8.8.8.8 tls://8.8.4.4 {" >> Corefile
china=`curl https://cdn.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/accelerated-domains.china.conf -s | while read line; do awk -F '/' '{print $2}' | grep -v '#' ; done | paste -sd " " -`
apple=`curl https://cdn.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/apple.china.conf -s | while read line; do awk -F '/' '{print $2}' | grep -v '#' ; done | paste -sd " " -`
google=`curl https://cdn.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/google.china.conf -s | while read line; do awk -F '/' '{print $2}' | grep -v '#' ; done | paste -sd " " -`
echo " except $china $apple $google" >> Corefile
echo " }" >> Corefile
echo " proxy . 116.228.111.118 180.168.255.18" >> Corefile
echo " log" >> Corefile
@rainly
rainly / decrypt_pdf.py
Created October 10, 2018 14:27 — forked from linyiru/decrypt_pdf.py
Decrypt password-protected PDF in Python.
# Decrypt password-protected PDF in Python.
# cleaned-up version of http://stackoverflow.com/a/26537710/329263
#
# Requirements:
# pip install PyPDF2
#
# Usage: decrypt_pdf('encrypted.pdf', 'decrypted.pdf', 'secret_password')
import sys
from PyPDF2 import PdfFileReader, PdfFileWriter
@rainly
rainly / checkportconn.sh
Created September 30, 2018 08:28 — forked from chenshaoju/checkportconn.sh
Check Service Port Connection Status
#!/bin/sh
#
# Change "currentserverport" Port 443 if not correct.
currentsship=$(w |grep pts/0 |awk '{print $3}')
currentserverip=$(ifconfig eth0 |grep broadcast |awk '{print $2}')
currentserverport="443"
currentserveripport=$currentserverip":"$currentserverport