Skip to content

Instantly share code, notes, and snippets.

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

delong.wang DeronW

🏠
Working from home
View GitHub Profile
"""
python建立pip.ini
使用国内的 豆瓣 作为安装源 加速安装过程
"""
import os
ini="""[global]
index-url = https://pypi.doubanio.com/simple/
[install]
@DeronW
DeronW / placeholder.js
Last active August 29, 2015 14:08
placeholder.js used jQuery support password type input
$(function () {
"use strict";
var placeholderColor = "#999999";
var addTextFieldPlaceholderSupport = function (elem, text) {
var e = $(elem);
if (!e.val())
e.val(text).data("textColor", e.css("color")).css("color", placeholderColor);
e.focus(function () {
if (e.val() == text)
// 16进制色值转换成rgba
function HEX2RGB(HEX, opacity){
opacity=opacity || "1.0";
HEX = HEX.replace("#","");
var r = parseInt(HEX.substring(0,2),16);
var g = parseInt(HEX.substring(2,4),16);
var b = parseInt(HEX.substring(4,6),16);
return "rgba("+r+","+g+","+b+","+opacity+")";
}
@DeronW
DeronW / video_url_convert.py
Created July 31, 2014 08:33
youku video url convert
url = urlparse('http://v.youku.com/v_show/id_XNzQ4MTcyMDE2.html?f=22598191')
if url.netloc == 'v.youku.com':
try:
video_id = url.path.split('/')[-1].split('.')[0][3:]
except:
pass
else:
video = 'http://player.youku.com/embed/%s' % video_id
@DeronW
DeronW / 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
@DeronW
DeronW / Virtualbox command
Last active December 20, 2015 16:29
VirtualBox 虚拟机常用命令
VBoxManage startvm "breadtrip" --type headless
VBoxManage controlvm "breadtrip" poweroff
@DeronW
DeronW / 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'
@DeronW
DeronW / 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()
@DeronW
DeronW / 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 的时间戳以秒为单位