Skip to content

Instantly share code, notes, and snippets.

// ==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
@glasslion
glasslion / extract_youtube_play_list.js
Last active July 17, 2019 07:11
Extract Youtube playlist links
// 1. jQuerify
// 2. Run in console
links = ""
$('a.ytd-grid-video-renderer').each(function(){
links += 'https://www.youtube.com' + $(this).attr('href') + '\n'
})
@glasslion
glasslion / retry_google_sorry.user.js
Last active October 14, 2016 09:18
当 Google 搜索遇到 We're sorry... 时, 自动刷新页面重试 的油猴脚本
// ==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==
@glasslion
glasslion / pyvideo_feedparser
Last active August 29, 2015 13:59
A simple script extract metadata from a Pyvideo category feed url, and print to stdout.
# 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__':
@glasslion
glasslion / django-debug-toolbar-v0.9.4-Python25
Created August 22, 2013 06:24
A patch that make django-debug-toolbar work in Python 2.5
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:
@glasslion
glasslion / generic_relations.py
Created August 16, 2013 07:25
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 : https://gist.github.com/justinfx/3095246#file-cache_generics-py Su…
'''
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 :