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 / clearfix.css
Last active December 11, 2015 23:59
CSS的闭合浮动代码,兼容IE6、7
.clearfix:after {
content: "";
display: block;
height: 0;
clear: both;
}
.clearfix {
zoom: 1;
}
@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 / 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 / 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 / time.py
Last active October 25, 2017 15:59
python 拿当前的时间戳 秒数和毫秒数,time的经度跟系统相关,windows小数点后3位,linux后面6位
import time
from datetime import datetime, date
# 今天
datetime.datetime.today().date().isoformat()
# 通过日期对象生成时间戳
int(time.mktime(datetime.now().timetuple()))
# 通过时间戳生成日期对象,timestamp 的时间戳以秒为单位
@delong8
delong8 / remove_BOM.py
Created May 30, 2013 01:05
去掉文件的BOM头
import codecs
import os
includes = ['*.php', '*.html', '*.htm']
for root, dirs, files in os.walk('pay.lvye.cn'):
for filename in files:
filename = os.path.join(root, filename)
with open(filename) as f:
content = f.read()
@delong8
delong8 / fabfile.py
Created June 2, 2013 11:16
部署脚本 git + ssh + fabric + fexpect
from __future__ import with_statement
from ilogue.fexpect import expect, expecting, run as erun
from fabric.api import settings, local, put, cd, run
import time
import datetime
import random
import logging
GIT_HOST = 'git@localhost'
@delong8
delong8 / Virtualbox command
Last active December 20, 2015 16:29
VirtualBox 虚拟机常用命令
VBoxManage startvm "breadtrip" --type headless
VBoxManage controlvm "breadtrip" poweroff
@delong8
delong8 / create_template_postgis-debian.sh
Last active December 20, 2015 16:39
djagno gis set template db script
#!/bin/bash
GEOGRAPHY=0
POSTGIS_SQL=postgis.sql
# For Ubuntu 8.x and 9.x releases.
if [ -d "/usr/share/postgresql-8.3-postgis" ]
then
POSTGIS_SQL_PATH=/usr/share/postgresql-8.3-postgis
POSTGIS_SQL=lwpostgis.sql