不知道有沒有人會直接用django form fields來做輸入驗證, 不過我是做了..
像是這樣
from django import forms
forms.DateTimeField().clean('2013-02-01')datetime.datetime(2013, 2, 1, 0, 0)
可以直接幫你把字串解成時間..
| from django.db import models | |
| from django.utils.encoding import smart_str | |
| from Crypto.Cipher import AES | |
| import base64 | |
| class AESField(models.TextField): | |
| __metaclass__ = models.SubfieldBase | |
| python import gtk | |
| python import vim | |
| vmap <silent> <C-C> y:let @0=substitute(@0,"\\","\\\\\\","gi")<CR>:let @0=substitute(@0,"\'","\\\\'","gi")<CR>:python gtk.clipboard_get().set_text('''<C-R>0''')<CR>:python gtk.clipboard_get().store()<CR> |
不知道有沒有人會直接用django form fields來做輸入驗證, 不過我是做了..
像是這樣
from django import forms
forms.DateTimeField().clean('2013-02-01')datetime.datetime(2013, 2, 1, 0, 0)
可以直接幫你把字串解成時間..
| function myip { | |
| result=`wget -qO- http://myip.is/|grep "The IP used to connect to this webserver is "|sed 's/The IP used to connect to this webserver is//'` | |
| echo $result | |
| } |
| #! /usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # | |
| # Copyright © 2013 george | |
| # | |
| # Distributed under terms of the MIT license. | |
| __all__ = [] | |
| import os | |
| import sys |
| #! /usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # | |
| # Copyright © 2013 george | |
| # | |
| # Distributed under terms of the MIT license. | |
| __all__=[] | |
| import os | |
| import sys | |
| import re |
| pp='ps -aux|grep ' | |
| function pk(){ | |
| echo kill -9 `ps -aux|grep $1|awk '{print \$2}'` | |
| } |
| class FormForAdvancedSearch(forms.Form): | |
| #you can put any field here this is an example so only 1 simple CharField | |
| form_field1 = forms.CharField() | |
| class MyModelAdmin(admin.ModelAdmin): | |
| # the auxiliary search form | |
| advanced_search_form = FormForAdvancedSearch() | |
| # a dictionary of key that will be removed from the GET QueryDict | |
| # this is necessary otherwise ChangeList will complain for malformed | |
| # query string |
| "height ligth cusor | |
| set t_Co=256 | |
| set cursorline | |
| set cursorcolumn | |
| highlight CursorColumn cterm=none ctermbg=236 | |
| highlight CursorLine cterm=none ctermbg=236 | |
| highlight ColorColumn ctermbg=none ctermbg=240 | |
| " Dim inactive windows using 'colorcolumn' setting | |
| " This tends to slow down redrawing, but is very useful. |
| def json_api(func): | |
| def deco(*args, **kwargs): | |
| result = {} | |
| try: | |
| result['status'] = 0 | |
| result['msg'] = "success" | |
| result['data'] = func(*args, **kwargs) | |
| except Exception,e: | |
| result['status'] = e.errorno if hasattr(e, 'errorno') else 1 |