Skip to content

Instantly share code, notes, and snippets.

@fdgogogo
fdgogogo / fix_transmission_no_data_found.py
Created September 7, 2020 07:57
Fix the issue 'Error: No data found! Ensure your drives are connected or use "Move Data File To...". To re-download, remove the torrent and re-add it.' caused by disk failure or mistakenly deletion By re-download all the torrents.
# -*- coding: utf-8 -*-
"""
Fix the issue 'Error: No data found! Ensure your drives are connected or use "Move Data File To...". To re-download, remove the torrent and re-add it.'
caused by disk failure or mistakenly deletion By re-download all the torrents.
Make a copy of the "torrents" dir from transmission config dir, the original one will be modified when script is running.
Authored by: Fang Jiaan (fduodev@gmail.com)
"""
# coding: utf-8
# Authorized by: Jiaan Fang <fduodev@gmail.com>
# Blog: https://fangs.work
# 本gist为文章 https://fangs.work/sqlalchemy-mapper-inheritance/ 的示例代码
# pip install Flask Flask-SQLAlchemy
from sqlalchemy.ext.declarative import ConcreteBase
from flask_sqlalchemy import SQLAlchemy
@fdgogogo
fdgogogo / flatten.py
Created October 29, 2015 16:12
Flatten dict and vice versa
""" Flatten dict and vice versa
Authored by: Fang Jiaan (fduodev@gmail.com)
Example:
>>> example = {'a': 1, 'b': {}, 'c': {'d': [], 'e': {'f': 0, 'h': u'xxx', 'i': {'j'}, 'k': object()}}}
>>> flatten_dict(example) # doctest: +ELLIPSIS
{'a': 1, 'b': {}, 'c.d': [], 'c.e.k': <object object at ...>, 'c.e.i': set(['j']), 'c.e.h': u'xxx', 'c.e.f': 0}
>>> assert nestify_dict(flatten_dict(example)) == example
@fdgogogo
fdgogogo / gist:d011e0375bc90c24cf18
Created October 7, 2014 13:41
Automatically add subtitle to video files using folder action
on adding folder items to this_folder after receiving added_items
set SSCL to "~/Applications/sscl"
set theList to added_items as list
set theLog to ""
do shell script "rm -rf ~/Library/Application\\ Support/SPlayerX/SVPSub/"
repeat with theItem in theList
set theFile to theItem as alias
set thePath to POSIX path of theFile as string
tell application "Finder"
set theName to the name of theFile