Skip to content

Instantly share code, notes, and snippets.

View delong8's full-sized avatar
🏠
Working from home

delong.wang delong8

🏠
Working from home
View GitHub Profile
@delong8
delong8 / upload_path.py
Last active December 17, 2015 08:39
django 模型里重新设定上传文件名称,使用时间随机数代替原有的文件名 在文件(图片)字段中设置上传路径参数:upload_to=uplaod_path
def upload_path(instance, old_filename):
extension = os.path.splitext(old_filename)[1].lower()
today = datetime.datetime.today()
timestamp = str(time.time())
file_path = 'media/{year}{month}/{timestamp}{extension}'.format(
year=today.year,
month=today.month,
timestamp=timestamp,
extension=extension)
return file_path
@delong8
delong8 / ellipsis.html
Last active May 18, 2016 10:01
CSS 将显示不完的多余字符用省略号代替兼容各主要浏览器 IE6+、FF、Chrom
单行文本方法, 通过CSS即可解决
<style>
p{
width: 100px;
display: block;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
-icab-text-overflow: ellipsis;
-khtml-text-overflow: ellipsis;
@delong8
delong8 / gray-page.css
Last active December 11, 2015 23:59
CSS 将整个网页变灰色
html {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
filter: gray;
filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
}
@delong8
delong8 / clearfix.css
Last active December 11, 2015 23:59
CSS的闭合浮动代码,兼容IE6、7
.clearfix:after {
content: "";
display: block;
height: 0;
clear: both;
}
.clearfix {
zoom: 1;
}