Skip to content

Instantly share code, notes, and snippets.

@zeroxia
zeroxia / dl.py
Created May 14, 2016 14:21
Python 2.7.6 (on Ubuntu 14.04) does not support SSL verfication using urllib2, while with later python 2.7.x, ssl certificate verification is enabled by default. Here is some snippets on properly tackling these caveats.
#!/usr/bin/python
import socket
import httplib
import ssl
import urllib
import urllib2
# archaic python urllib2 documentation: 2.7.2
# https://python.readthedocs.io/en/v2.7.2/library/urllib2.html
@zeroxia
zeroxia / permutate_expr_sum.py
Last active May 24, 2016 13:17
For a list of numbers 1 2 3 4 5 6 7 8 9, add operators '+', '-', or none among them, to create an albegraic expression that evaluates to sum of 110.
#!/usr/bin/python
# vim: set ts=4 sts=4 et fileencoding=utf-8:
import itertools
target = 110
ops = [' + ', ' - ', '']
digit_list = list('123456789')
for op_list in itertools.product(ops, repeat=8):
expr = ''.join([ item for pair in zip(digit_list, op_list + ('',)) for item in pair ])
try:
战神系列发售时间表:
2005 PS2 《战神1》
2007 PS2 《战神2》
2007 java手游 《战神:背叛》
2009/2014 PS3/PSV 《战神1+2收藏版》
2008 PSP 《战神:奥林匹斯之链》
2010 PS3 《战神3》
2010 PSP 《战神:斯巴达之魂》
2011 PS3 《战神起源携带版合集》(收录了奥林匹斯之链+斯巴达之魂)
2012 PS3 《战神传说版》(收录了战神1、2、3+奥林匹斯之链+斯巴达之魂)
@zeroxia
zeroxia / torrent2magnet.py
Created February 7, 2017 13:44
Convert a .torrent seed file into a magnet:? magnetic link for easier batch import into some offline downloading service
#!/usr/bin/python
# vim: set fileencoding=utf-8:
# Code shamelessly copied from:
# http://stackoverflow.com/questions/12479570/given-a-torrent-file-how-do-i-generate-a-magnet-link-in-python
# How to install the `bencode' module for Python on Windows:
# Run a command line window as Administrator:
# % python -m pip install bencode
@zeroxia
zeroxia / linux-transmission.txt
Created November 10, 2017 14:53
Summary the setup of transmission-daemon on a Linux host
pacman -S transmission-cli
cd /var/lib/transmission/.config/transmission-daemon/
cp settings.json edit.txt
(EDIT edit.txt)
cat edit.txt >settings.json
cd /usr/share/transmission
git clone -o github 'https://github.com/ronggang/transmission-web-control.git'
cd /usr/share/transmission/web
mv index.html index.original.html
@zeroxia
zeroxia / visual_studio_2017_layout_commands.bat
Created January 14, 2018 14:05
Download Visual Studio 2017 installation files, for offline usage, using "vs_professional.exe" or "vs_community.exe" web installer
:: Managed Desktop download
vs_professional.exe --layout "%~dp0vs2017_layout_MD" ^
--add Microsoft.VisualStudio.Workload.ManagedDesktop ^
--lang en-US
:: Native Desktop download
vs_professional.exe --layout "%~dp0vs2017_layout_ND" ^
--add Microsoft.VisualStudio.Workload.NativeDesktop ^
--lang en-US
@zeroxia
zeroxia / fn_cksfv.sh
Created January 14, 2018 14:07
Check SFV and compare to the value extracted from respective filename
#!/bin/sh
for f in *.mkv; do
echo -n "$f"
checksum=$( echo "$f" | sed -e "s/^.*\[\([^][]\+\)\]\.mkv/\1/" )
#echo " Checksum: $checksum"
checksum_calc=$( cksfv "$f" | awk '/^[^;]/ { print $2; }' )
if [ "$checksum" == "$checksum_calc" ]; then
echo " - GOOD"
else
@zeroxia
zeroxia / call-subrename.bat
Last active March 12, 2018 13:11
Batch scripts on Windows, to rename subtitle files, for the drama Game of Thrones
@echo off
REM echo.ARG1: Video Directory, e.g., \\alarm\media\xiayitiao\download\Game.Of.Thrones.S01\
REM echo.ARG2: Season selection, e.g., S01
REM echo.ARG3: Subtitle directory, e.g., subs-1
REM echo.ARG4: Subtitle naming tag, e.g., zh-1
for %%i in (2 3) do (
call subrename.bat ^
"\\alarm\media\xiayitiao\download\HBO史诗巨著:冰与火之歌.权力的游戏.第六季全.2016.中英字幕£CMCT梦幻" ^
@zeroxia
zeroxia / 01-initial-S.M.A.R.T.txt
Created March 16, 2022 15:21
Misfortune of a Seagate HDD: Seagate Desktop HDD.15 (ST5000DM000-1FK178)
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.34-1-pve] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Seagate Desktop HDD.15
Device Model: ST5000DM000-1FK178
Serial Number: W4J0BAVZ
LU WWN Device Id: 5 000c50 07d53b6c5
Firmware Version: CC46
User Capacity: 5,000,981,078,016 bytes [5.00 TB]