This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Cache the generic relation field of all the objects | |
in the queryset, using larger bulk queries ahead of time. | |
Improved from original by Daniel Roseman: | |
http://blog.roseman.org.uk/2010/02/22/django-patterns-part-4-forwards-generic-relations/ | |
and | |
justinfx's gist cache_generics.py : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/debug_toolbar/panels/sql.py b/debug_toolbar/panels/sql.py | |
index 18fffdc..a0bfce8 100644 | |
--- a/debug_toolbar/panels/sql.py | |
+++ b/debug_toolbar/panels/sql.py | |
@@ -193,8 +193,14 @@ class SQLDebugPanel(DebugPanel): | |
stacktrace = [] | |
for frame in query['stacktrace']: | |
params = map(escape, frame[0].rsplit('/', 1) + list(frame[1:])) | |
+ params_dict = dict((unicode(idx), v) for idx, v in enumerate(params)) | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from __future__ import print_function | |
import feedparser | |
import sys, codecs | |
if not sys.stdout.isatty(): | |
sys.stdout = codecs.getwriter('utf8')(sys.stdout) | |
if __name__ == '__main__': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Retry Google Sorry | |
// @description 当 Google 搜索遇到 We're sorry... 时, 自动刷新页面重试, 使用代理访问 Google 时, 常遇到这种现象 | |
// @namespace https://gist.github.com/glasslion | |
// @author glasslion | |
// @include http*://ipv4.google.com/sorry/index?* | |
// @version 1.2 | |
// @run-at document-end | |
// @grant none | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. jQuerify | |
// 2. Run in console | |
links = "" | |
$('a.ytd-grid-video-renderer').each(function(){ | |
links += 'https://www.youtube.com' + $(this).attr('href') + '\n' | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Piratebay Helper | |
// @description | |
// @namespace https://userscripts.org/users/glasslion | |
// @include *pirate* | |
// @license MIT | |
// @version 0.1 | |
// @require https://code.jquery.com/jquery-2.1.3.min.js | |
// @grant GM_addStyle | |
// @grant GM_setClipboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var d = document, | |
useMine = true, | |
prevEl; | |
function AddHandler(orig, mine) { | |
return function(e) { | |
if (useMine) mine(e); | |
else if (orig) orig(e); | |
}; | |
} |
OlderNewer