Skip to content

Instantly share code, notes, and snippets.

@glasslion
glasslion / github_repo_https_to_git.sh
Created October 15, 2019 08:13
将 repo 转为 git
git remote -v | head -1 |awk '{ print $2 }' | sed 's/https:\/\//git remote set-url origin git@/g' | sed 's/.com\//.com:/g'
@glasslion
glasslion / fix_url_encoded_filename.py
Created October 15, 2019 07:32
修复 Linux 下载的 urlencode 过的文件名
# -*- coding: utf-8 -*-
import glob
import os
import urllib
def confirm(text):
answer = raw_input(text)
answer = answer.lower()
return answer == 'y' or answer == 'yes'
# lastpass2keepass
# Supports:
# Keepass XML - keepassxml
# USAGE: python lastpass2keepass.py exportedTextFile
# The LastPass Export format;
# url,username,password,1extra,name,grouping(\ delimited),last_touch,launch_count,fav
import sys, csv, time, datetime, itertools, re, operator # Toolkit
import xml.etree.ElementTree as ET # Saves data, easier to type
@glasslion
glasslion / pip2poetry.py
Created July 12, 2019 02:21
一个把 pip requirements 转换成 poetry依赖的脚本
#!/usr/bin/env python
from __future__ import absolute_import
import argparse
import os
import subprocess
def normalize(line):
line = line.strip('\n')
if line.startswith('#') or line.startswith('-'):
@glasslion
glasslion / pushover-bookmarklet.js
Last active January 28, 2022 08:33
pushover bookmarklet
var text = window.prompt('Enter the message to push, or leave empty and push the current url.');
if (text=="") {
text=window.location.href
}
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://api.pushover.net/1/messages.json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
token: 'APP_TOKEN',
user: 'USER_KEY',
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Bilibili Screenshots Syncer
It can download `/Pictures/bili/screenshot` from a Android phone via ftp.
It also rename the picture so the timestamp comes first.
"""
from __future__ import print_function
import argparse
@glasslion
glasslion / ClipperHelper.js
Last active April 25, 2021 14:08
Bookmarklet that makes web page clipping easy.
var d = document,
useMine = true,
prevEl;
function AddHandler(orig, mine) {
return function(e) {
if (useMine) mine(e);
else if (orig) orig(e);
};
}
@glasslion
glasslion / vtt2text.py
Last active November 8, 2024 18:34
This script convert youtube subtitle file(vtt) to plain text.
"""
Convert YouTube subtitles(vtt) to human readable text.
Download only subtitles from YouTube with youtube-dl:
youtube-dl --skip-download --convert-subs vtt <video_url>
Note that default subtitle format provided by YouTube is ass, which is hard
to process with simple regex. Luckily youtube-dl can convert ass to vtt, which
is easier to process.
@glasslion
glasslion / outlook_web_batch_delete.js
Created July 3, 2017 07:11
批量删除outlook 里的邮件
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function deleteMails() {
jQuery('._n_U').click()
await sleep(500);
jQuery('.ms-fcl-np[title="删除(Del)"]').click()
}
@glasslion
glasslion / adminLteColors.html
Created March 31, 2017 07:21
Color table for AdminLte
<html>
<head>
<meta charset="utf-8">
<title>AdminLTE 2 Colors</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"`>
<link rel="stylesheet" href="https://almsaeedstudio.com/themes/AdminLTE/dist/css/AdminLTE.min.css">
</head>
<body>
<div class="container">
<table class="table table-bordered">