Skip to content

Instantly share code, notes, and snippets.

@Shu-Ji
Shu-Ji / adp-rule.txt
Last active August 29, 2015 14:04
我的Adblock Plus过滤规则
[Adblock Plus 2.0]
! Title: shuji's list
! Last modified: 13 April 2014 21:58 CST
! Expires: 1 days (update frequency)
! Homepage: https://gist.github.com/Shu-Ji/
!-------based on ChinaList+EasyList----------!
www.baidu.com###bottom_container
www.baidu.com###u_sp
@Shu-Ji
Shu-Ji / thrift.sh
Created July 23, 2014 06:04
thrift转换命令
thrift -r --gen cpp xxx.thrift
thrift -r --gen java xxx.thrift
thrift -r --gen py xxx.thrift
@Shu-Ji
Shu-Ji / netbase.py
Last active August 29, 2015 14:04
简单的支持cookie和代理的网络请求封装
# coding: u8
import urllib2
import urllib
import cookielib
class Net(object):
def __init__(self, cookie_path=None, encoding='u8', timeout=120,
proxy_host=None, proxy_port=None):
@Shu-Ji
Shu-Ji / designer.html
Created August 14, 2014 07:20
designer
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-checkbox/paper-checkbox.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../topeka-elements/category-images.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<polymer-element name="my-element">
@Shu-Ji
Shu-Ji / path_python_json_dumps_datetime_etc.py
Last active August 29, 2015 14:05
python中json自定义dump类型
#!/usr/bin/env python
# coding: u8
import datetime
import json
_dumps = json.dumps
def dumps(obj, *args, **kwargs):
@Shu-Ji
Shu-Ji / sanaholu_jinja2_rediscache.py
Last active January 15, 2022 21:23
jinja2 redis cache
from jinja2 import nodes
from jinja2.ext import Extension
class FragmentCacheExtension(Extension):
'''http://jinja.pocoo.org/docs/dev/extensions/#example-extension'''
# 其余部分略...
def _cache_support(self, name, timeout, caller):
//- index.jade
{% macro cache() %}
script.
{% if DEBUG %}
dg.static_url = {
vendor: '{{ static_url("vendor/vendor.js") }}',
'common/app.js': "{{ static_url('sanhaolu/default/common/app.js') }}",
'pages/404.html': "{{ static_url('sanhaolu/default/pages/404.html') }}"
};
{% else %}
# main.coffee
require.config
baseUrl: '/static'
paths:
vendor: dg.static_url['vendor']
# 其他配置略....
deps: [
dg.static_url['common/app.js'],
define [
'angularAMD',
dg.static_url['common/services.js'],
dg.static_url['common/filters.js']
], (angularAMD) ->
sanhaolu = angular.module('sanhaolu', [
'ngRoute',
'sanhaolu.common.services',
'sanhaolu.common.filters'
])
@sched_base.scheduled_job('interval', minutes=1 if settings.DEBUG else 5)
def expire_cached_static_files_hash():
u"""当有静态文件发生变化时,使redis中缓存的hash值失效"""
import re
p = r'?v=([a-f0-9]{32})'
html = str(g.render.macro('default/index.html').cache())
hashes_now = sorted(re.findall(p, html) or [])