Skip to content

Instantly share code, notes, and snippets.

@Nataila
Nataila / gist:8313743
Created January 8, 2014 08:48
自己写的一个密码生成脚本
#!/usr/bin/env python
#coding=utf-8
# Author: CC
# Created Time: Tue 07 Jan 2014 07:30:55 PM CST
#此脚本支持生成5位以上62以下的密码
import string
import random
from optparse import OptionParser
@Nataila
Nataila / gist:8142644
Created December 27, 2013 04:37
django中Mysql出现中文乱码问题(中文变成???)
应该是mysql 默认编码问题。可以换 sqlite3 数据库,或者改下 /etc/mysql/my.cnf 配置文件,在 [client] 和 [mysqld] 下加如下项:
[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
default-collation=utf8_general_ci
character-set-server=utf8
collation-server=utf8_general_ci
function containSpecial(str){
var specailStr = RegExp(/[(\ )(\~)(\!)(\@)(\#) (\$)(\%)(\^)(\&)(\*)(\()(\))(\-)(\_)(\+)(\=) (\[)(\])(\{)(\})(\|)(\\)(\;)(\:)(\')(\")(\,)(\.)(\/) (\<)(\>)(\?)(\)]+/);
return (specailStr.test(str));
};
function unique(arr) {
var ret = [];
var hash = {};
for (var i = 0; i < arr.length; i++) {
var item = arr[i];
var key = typeof(item) + item
if (hash[key] !== 1) {
ret.push(item);
hash[key] = 1;
};
django 数据库查询
2010-10-22 20:47:40
class Poll(models.Model):
slug = models.SlugField(unique_for_month='pub_date')
question = models.CharField(maxlength=255)
pub_date = models.DateTimeField()
expire_date = models.DateTimeField()
def __repr__(self):
return self.question
{% load i18n %}
{% load apps_filter %}
{% if paged_objects.has_other_pages %}
<div class="row-fluid">
<div class="pull-right">
<div class="pagination ks-pagination {{ position_css }}">
<ul>
{% if paged_objects.has_previous %}
<li><a href="?page={{ paged_objects.previous_page_number }}{% if params_str %}{{ params_str }}{% endif %}">{% trans '上一页' %}</a>
项目目录:
/var/www/knownsec
knownsec下会自动生成uwsgi.py(前提用apt-get安装nginx以及uwsgi)
nginx配置
/etc/nginx/sites-enabled/ks
1 server {
2
过滤器,变量的显示形式的改变
一、形式:小写
{{ name | lower }}
二、串联:先转义文本到HTML,再转换每行到 <p> 标签
mylist = [2,2,2,2,2,2,3,3,3,3]
mylist.sort()
myset = set(mylist)
for item in myset:
print mylist.count(item), " of ", item, " in list"
text-align:center;
width:90%\9; /* 兼容IE浏览器 */
margin:0 auto; /* 兼容Firefox , Opera */
font-size:20px;
color:#4e4a4c;
font-weight:bold;