Skip to content

Instantly share code, notes, and snippets.

View qiuchengxuan's full-sized avatar

qiuchengxuan qiuchengxuan

View GitHub Profile
@qiuchengxuan
qiuchengxuan / bj-unicom-iptv.m3u
Last active June 22, 2022 03:27
北京联通IPTV列表
#EXTM3U name="bj-unicom-iptv"
#EXTINF:-1 group-title="CCTV;高清",CCTV-1 综合 高清
http://ea6350.lan:4022/udp/239.3.1.129:8008
#EXTINF:-1 group-title="CCTV;高清",CCTV-2 财经 高清
http://ea6350.lan:4022/udp/239.3.1.60:8084
#EXTINF:-1 group-title="CCTV;高清",CCTV-4 中文国际 高清
http://ea6350.lan:4022/udp/239.3.1.105:8092
#EXTINF:-1 group-title="CCTV;高清",CCTV-5+ 体育赛事 高清
http://ea6350.lan:4022/udp/239.3.1.130:8004
#EXTINF:-1 group-title="CCTV;高清",CCTV-7 国防军事 高清
@qiuchengxuan
qiuchengxuan / bj-telecom-iptv.m3u
Last active April 9, 2024 10:07
北京电信IPTV列表
#EXTM3U name="bj-telecom-iptv"
#EXTINF:-1 group-title="CCTV",CCTV-1 综合 高清
http://tew823dru.lan:4022/udp/225.1.8.1:8008
#EXTINF:-1 group-title="CCTV",CCTV-2 财经 高清
http://tew823dru.lan:4022/udp/225.1.8.2:8084
#EXTINF:-1 group-title="CCTV",CCTV-3 综艺 高清
http://tew823dru.lan:4022/udp/225.1.8.88:8000
#EXTINF:-1 group-title="CCTV",CCTV-4 中文国际 高清
http://tew823dru.lan:4022/udp/225.1.8.4:8092
#EXTINF:-1 group-title="CCTV",CCTV-5 体育 高清
@qiuchengxuan
qiuchengxuan / hotplug.sh
Created December 11, 2019 12:56
A simple script to hotplug hard drives on linux
#!/bin/bash
entries=($(find /dev/disk/by-id -type l -printf '%l %f\n' | grep -v '\(part\|wwn\)' | sed 's#../../##g' | tr '\n' ' '))
entries+=('' '' 'rescan' 'RESCAN')
choice=$(whiptail --notags --title "Hotplug" --menu "Select device" 16 100 9 "${entries[@]}" 3>&1 1>&2 2>&3)
test -n "$choice" || exit 0
case $choice in
"rescan")
echo 'Rescan disks...'
echo '- - -' > /sys/class/scsi_host/host0/scan
@qiuchengxuan
qiuchengxuan / emacs-latest.spec
Last active March 2, 2021 02:06
build latest emacs into rpm package
Name: emacs25
Version: 25.3
Release: 1%{?dist}
Summary: GNU Emacs
#Group:
License: GPL
URL: http://www.gnu.org/software/emacs/
Source0: http://mirrors.ustc.edu.cn/gnu/emacs/emacs-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@qiuchengxuan
qiuchengxuan / mininet_sshd.py
Created December 10, 2017 03:50
Create a lot of sshd host for testing, based on mininet
#!/usr/bin/python
import ipaddress
import argparse
from mininet.topo import Topo
from mininet.nodelib import LinuxBridge
from mininet.net import Mininet
from mininet.cli import CLI
from mininet.util import waitListening
@qiuchengxuan
qiuchengxuan / huawei_cli.py
Last active July 13, 2023 08:39
Access HUAWEI Switch via CLI with python script
#!/usr/bin/python
import sys
_, ip, user, passwd = sys.argv
CLI_PROMPT = r'[\[<][^>\]]+[\]>]'
ssh = spawn('ssh %s@%s' % (username, ip))
if not ssh:
return
ssh.expect('password')
@qiuchengxuan
qiuchengxuan / netconf_h3c.py
Last active December 10, 2017 03:55
Access H3C switch via NETCONF with python script
#!/usr/bin/python
import sys
import code
from lxml import etree
from lxml.builder import E
from ncclient import manager
_, ip, user, passwd = sys.argv
netconf = manager.connect(host=ip, port=830, username=user, password=passwd,
@qiuchengxuan
qiuchengxuan / netconf_huawei.py
Last active October 20, 2022 18:56
Access Huawei switch via NETCONF with python script
#!/usr/bin/python
import sys
import code
from lxml import etree
from lxml.builder import E
from ncclient import manager
_, ip, user, passwd = sys.argv
netconf = manager.connect(host=ip, port=830, username=user, password=passwd,
@qiuchengxuan
qiuchengxuan / sudoku.py
Last active January 4, 2016 13:42
simple sudoku solver
#!/usr/bin/python
# -*- coding:utf-8 -*-
import sys
def parse(s):
return list(map(lambda c : 0 if c == ' ' else ord(c) - ord('0'), s))
board = [parse(input()) for i in range(9)]
# s = input()
# board = [parse(s[i * 9 : i * 9 + 9]) for i in range(9)]
# input()
# answer = [parse(input()) for i in range(9)]
@qiuchengxuan
qiuchengxuan / A simple shell script to attach usb device to kvm
Created September 12, 2015 05:48
A simple shell script to attach usb device to kvm
#!/bin/bash
IFS=$'\r\n'
array=(`lsusb -v 2> /dev/null | grep "\(Bus\|bInterfaceClass\)" | awk -F ' ' '{if(/Bus/){printf "%s ",$0} else {$1="";$2="-";print $0}}' | grep -o "ID.*"`)
for i in `seq 0 $(expr ${#array[*]} - 1)`; do
echo -n "$i "
echo "${array[$i]}"
done
echo -n "choose usb device: "
id=`echo ${array[$(read)]} | grep -o "[0-9]\+:[0-9]\+"`
virsh list --all