几个小脚本

栏目: 数据库 · 发布时间: 5年前

内容简介:随便翻一下谷歌浏览器调试工具(F12)执行过的脚本,摘几个贴一下。导出 GVP 项目列表,做个参考。get database password from heidisql settings file

随便翻一下谷歌浏览器调试工具(F12)执行过的脚本,摘几个贴一下。

Gitee GVP

导出 GVP 项目列表,做个参考。

var jqEleProjects = $('#gvp-index-segment > div.ui.four.cards.all-projects > div > div.content.description-content');
var projects = {};
var languages = {};
var types = {};
jqEleProjects.each(function(){
    var name = $(this).find('h3 > a').text();
    var url = $(this).find('h3 > a').attr('href');
    var type = $(this).find('div > div > div:nth-child(1)').text();
    var language = $(this).find('div > div > div:nth-child(2)').text();
    projects[name] = {name: name, url: url, type: type, language: language};
    if (!languages.hasOwnProperty(language)) { languages[language] = []; }
    languages[language].push(name);
    if (!types.hasOwnProperty(type)) { types[type] = []; }
    types[type].push(name);
    // console.log(name + ' - ' + type + ' - ' + language + ' - ' + url);
});
console.log(projects);
console.log(languages);
console.log(types);

API 测试时先调登录接口

xhr = new XMLHttpRequest();
xhr.open('post', 'http://localhost:9996/login', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send('username=catroll&password=123456');

heidiSQL 找回数据库密码

get database password from heidisql settings file

有个配置文件,就在 heidisql 安装目录下,叫 settings.txt,自己找找。

function heidiDecode(hex) {
    var str = '';
    var shift = parseInt(hex.substr(-1));
    hex = hex.substr(0, hex.length - 1);
    for (var i = 0; i < hex.length; i += 2)
      str += String.fromCharCode(parseInt(hex.substr(i, 2), 16) - shift);
    return str;
}

Python 版本:

from __future__ import print_function

import re
import codecs

HEIDI_CONF = '/media/sf_D_DRIVE/Program Files/HeidiSQL/settings.txt'
HEIDI_CONF_SEP = re.compile(re.escape('<|||>'))


def heidi_pw_decode(code):
    shift = int(code[-1])
    code = code[:-1]
    password = ''.join(map(lambda x: chr(int(x, 16) - shift), re.findall(r'\w{2}', code)))
    return password


def main():
    with codecs.open(HEIDI_CONF, encoding="utf8") as fp:
        lines = [line.strip() for line in fp.readlines()
                 if line.startswith('Servers') and '\\Password<' in line]

    passwords = []
    for line in lines:
        parts = HEIDI_CONF_SEP.split(line)
        server_name = parts[0].split('\\')[1]
        password = heidi_pw_decode(parts[-1])
        passwords.append((server_name, password))

    if passwords:
        print(' All Database Passwords '.center(80, '-'))
        print()
        for server_name, password in passwords:
            print('Database: %s' % server_name)
            print('Password: %s' % password)
            print()
    else:
        print('[INFO] No password can be found!')


if __name__ == '__main__':
    main()

列出 Python 文档中的章节

我当时好像是为了比对 2 和 3 的文档章节差异,看看 3 多了些什么...

  • https://docs.python.org/2/library/
  • https://docs.python.org/3/library/
var chapters = {};
var arrL1 = $('.toctree-l1 > a');
var arrL2 = $('.toctree-l2 > a');
var content = '';
$('.toctree-l1').each(function() {
    var l1Title = $(this).find(arrL1).text();
    content += '- ' + l1Title + '\n';
    chapters[l1Title] = [];
    $(this).find(arrL2).each(function() {
        var l2Title = $(this).html();
        l2Title = l2Title.replace(/<code class="docutils literal notranslate"><span class="pre">|<\/span><\/code>/g, '`');
        l2Title = l2Title.replace(/<strong class="program">|<\/strong>/g, '**');
        chapters[l1Title].push(l2Title);
        content += '  - ' + l2Title + '\n';
    });
});
// console.log(JSON.stringify(chapters));
console.log(content);

自动删除网易邮箱的邮件

有些文件夹下的邮件实在太多,好几千封,两百大几十页,要是一个一个的全选、删除、等执行完成,那不累死,不是 程序员 该做的事。

写了个脚本,自动勾选删除。

PS:脚本没有找到,等找到了再补上。


以上所述就是小编给大家介绍的《几个小脚本》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Writing Apache Modules with Perl and C

Writing Apache Modules with Perl and C

Lincoln Stein、Doug MacEachern / O'Reilly Media, Inc. / 1999-03 / USD 39.95

Apache is the most popular Web server on the Internet because it is free, reliable, and extensible. The availability of the source code and the modular design of Apache makes it possible to extend Web......一起来看看 《Writing Apache Modules with Perl and C》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

随机密码生成器
随机密码生成器

多种字符组合密码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试