Skip to content

Instantly share code, notes, and snippets.

@oliveagle
oliveagle / script.sh
Created January 31, 2013 10:26 — forked from kapkaev/script.sh
#step 1
yum -y install python-setuptools
#step 2
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
# or
# rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
#step 3
# if you using centOS 6.2 enable rpmforge-extras (enabled =1)
@oliveagle
oliveagle / py-header.py
Last active December 16, 2015 10:39
python-header
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Created on ${0:iso}
# @mail: [email protected]
@oliveagle
oliveagle / gist:5460427
Created April 25, 2013 15:08
validate datetime in javascript
//校验日期
function isdate(object) {
var s = document.getElementById(object.id).value;
var pattern = /^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[0-9])|([1-2][0-3]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))))?$/;
if (s != "") {
if (!pattern.exec(s)) {
alert('请输入正确的日期');
object.value = "";
object.focus();
@oliveagle
oliveagle / gist:5460474
Created April 25, 2013 15:13
javascript: validate chinese mobile number
function isMobile(object) {
var s = document.getElementById(object.id).value;
var reg0 = /^13\d{5,9}$/;
var reg1 = /^153\d{4,8}$/;
var reg2 = /^159\d{4,8}$/;
var reg3 = /^0\d{10,11}$/;
var my = false;
if (reg0.test(s)) my = true;
if (reg1.test(s)) my = true;
if (reg2.test(s)) my = true;
@oliveagle
oliveagle / validate_zipcode_cn.js
Created April 25, 2013 15:24
javascript: validate chinese zipcode
function isPostalCode(object) {
//校验(国内)邮政编码
var s = document.getElementById(object.id).value;
var pattern = /^[0-9]{6}$/;
if (s !== "") {
if (!pattern.exec(s)) {
alert('请输入正确的邮政编码');
object.value = "";
object.focus();
}
@oliveagle
oliveagle / validate_email_addr.js
Created April 25, 2013 15:27
javascript: validate email address
function isEmailAddr(object) {
var s = document.getElementById(object.id).value;
var pattern = /^[a-zA-Z0-9_\-]{1,}@[a-zA-Z0-9_\-]{1,}\.[a-zA-Z0-9_\-.]{1,}$/;
if (s !== "") {
if (!pattern.exec(s)) {
alert('请输入正确的邮箱地址');
object.value = "";
object.focus();
}
}
@oliveagle
oliveagle / validate_number.js
Created April 25, 2013 15:30
javascript: validate number input
function testisNum(object) {
var s = document.getElementById(object.id).value;
if (s !== "") {
if (isNaN(s)) {
alert("请输入数字");
object.value = "";
object.focus();
}
}
}
@oliveagle
oliveagle / requirejs-boilerplate.js
Last active December 16, 2015 16:09
javascript: backbone boilerplate
// Filename:
define(['jquery', 'underscore', 'backbone',
// load module
], function($, _, Backbone, ){
return ;
});
from __future__ import with_statement
from datetime import datetime
from sys import exit
from fabric.api import env, run, local, task, settings, sudo
import re
env.hosts = ['[email protected]']
environments = {
'__base__': {
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db