Skip to content

Instantly share code, notes, and snippets.

@ekayxu
ekayxu / dim_date_2029.sql
Last active August 13, 2019 10:44
date dimension generator by MaxComputeSQL
-- DROP TABLE IF EXISTS dim_date_base;
CREATE TABLE IF NOT EXISTS dim_date_base (
`dt` BIGINT COMMENT '日期dt,示例:20160821',
`date_id` BIGINT COMMENT '日期id,示例:20160821',
`date` STRING COMMENT '日期,示例:2016-08-21',
`day_num` BIGINT COMMENT '日计数,起始日期开始',
`day_of_week` BIGINT COMMENT '所在周的第几天,从每周一开始',
`day_of_month` BIGINT COMMENT '所在月的第几天,从每月1号开始',
@ekayxu
ekayxu / gist:5743138
Created June 9, 2013 10:53
Make Flask support regular expressions in its URL routing
#http://stackoverflow.com/questions/5870188/does-flask-support-regular-expressions-in-its-url-routing
#Even though Armin beat me to the punch with an accepted answer I thought I'd show an abbreviated example of how I implemented a regex matcher in Flask just in case anyone wants a working example of how this could be done.
from flask import Flask
from werkzeug.routing import BaseConverter
app = Flask(__name__)
class RegexConverter(BaseConverter):
def __init__(self, url_map, *items):
@ekayxu
ekayxu / python_infrastructure.md
Created November 23, 2012 15:12 — forked from onlytiancai/python_infrastructure.md
python 基础设施讨论贴

python项目通用组件和基础服务

很多公司都大量使用了python,其中有一些开发规范,code guidline, 通用组件,基础框架是可以共用的。

每个公司都自己搞一套, 太浪费人力,我想开一帖和大家讨论一下这些python基础设施的搭建。

原则是我们尽量不重新发明轮子,但开源组件这么多,也要有个挑选的过程和组合使用的过程,在这里讨论一下。

另一方面,有些开源组件虽然强大,但我们不能完全的驾驭它,或只使用其中很少的一部分,我们就可以考虑用python实现一个简单的轮子,可控性更强,最好不要超过300行代码。

@ekayxu
ekayxu / bizip2up.sh
Created March 29, 2012 06:26
压缩最后距离修改时间大于1周的文件
cd `dirname $0`
cd $1
for f in `ls | grep -E '^'$1'_[[:digit:]]+$'`
do
modify=`date +%s -r $f`
weekago=`date +%s -d '-1 week'`
if [ $weekago -gt $modify ]; then
echo "Ziping file $f"
time bzip2 $f
fi
@ekayxu
ekayxu / dim.date.sql
Created April 7, 2011 07:46
date dimension generate procedure
##DELIMITER $$
DROP TABLE IF EXISTS `date_dimension`;
CREATE TABLE `date_dimension` (
`datekey` int(10) unsigned NOT NULL,
`date` date NOT NULL,
`day_of_week` tinyint(4) unsigned NOT NULL COMMENT '一星期中的第几天',
`day_num_in_month` tinyint(4) unsigned NOT NULL COMMENT '一个月中的第几天',
`day_num_overall` mediumint(6) unsigned NOT NULL COMMENT '日计数',
`day_name` varchar(9) NOT NULL COMMENT '星期几',