Skip to content

Instantly share code, notes, and snippets.

@oliveagle
oliveagle / d3lib.md
Last active August 29, 2015 14:11 — forked from widged/d3lib.md

chartFactory

/affini-tech/ChartFactory

Based on D3.JS and Dimple, ChartFactory provide the ability to build quickly D3.JS charts without coding any lines of javascript. Just define your dashboard in a JSON and voila !

charts: [
        {id:'chart1',
         width:800,height:250,

xAxis:{type:'Category',field: "Month",orderRule:'Date'},

@oliveagle
oliveagle / loggingConfig.py
Last active December 23, 2015 12:39
python logging configuration practices for fun :D
from logging import config
default_dict = {
'version':1,
'disable_existing_loggers':False, # this fixes the problem
'formatters':{
'verbose_name':{
'format':'%(asctime)s [%(levelname)s] %(name)s: %(message)s'
},
#! /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
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__': {
@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 ;
});
@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 / 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_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 / 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 / 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();