Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# -3- coding: utf-8 -3-
from __future__ import print_function
import sys
thismodule = sys.modules[__name__]
class BPUGBaseException(Exception):
" map the leader key to ,
let mapleader = ","
" Note: Skip initialization for vim-tiny or vim-small.
if !1 | finish | endif
if has('vim_starting')
set nocompatible " Be iMproved
import instapush
app = instapush.App(appid="52eed96ea2a8f0f", secret="9a96794fec44481de5")
app.notify(event_name="search", "trackers"={"term": "new term"})
from django.test.client import Client
#方法1: 构造实例的时候传入headers中的key value, 以后请求方法自动传递headers
client = HttpClient(REMOTE_ADDR='127.0.0.1')
#方法2: 请求的时候附带额外参数声明headers
client.get('/path/', {'param':'foo'}, **{'HTTP_USER_AGENT':'firefox-22', 'REMOTE_ADDR':'127.0.0.1'})
class Singleton(object):
def __new__(cls, *args, **kwds):
it = cls.__dict__.get("__it__")
if it is not None:
return it
cls.__it__ = it = object.__new__(cls)
it.init(*args, **kwds)
return it
def __init__(self, *args, **kwds):
pass
@adamwen829
adamwen829 / gist:5371878
Last active December 16, 2015 03:39
http://www.v2ex.com/t/65710 第一题 很简单的动态规划 分为3个原子操作: “A” | “Press Ctrl+A; Press Ctrl+C; Press Ctrl+V; Press Ctrl+V;” | "Press Ctrl+V;" 当天敲击按键x的次数的最大值为(list[x-1]+1, list[x-4] * 2, list[x-1]+copy_clipboard_num)里的最大值 当 list[x-4] * 2 与 list[x-1]+copy_clipboard_num 相等时 优先使用 list[x-4] * 2 ,这样在步数相同的情况下可以扩大clipboard 其实分析一下就可以看出PressA这种情况在第8次敲键盘之后不会出现, 也可以…
# -*- coding: utf-8 -*
class Operation:
a = "Press A;"
paste = "Press Ctrl+V;"
copy_and_paste = "Press Ctrl+A; Press Ctrl+C; Press Ctrl+V; Press Ctrl+V;"
def create_operation_list():
operation_list = [(i, Operation.a) for i in range(0, 5)]
return operation_list