Right now there are a few ways we can create UDF:
- With standalone function:
| from django.core.exceptions import MiddlewareNotUsed | |
| from django.conf import settings | |
| from django.db import connection | |
| from pymongo.connection import Connection | |
| from time import time | |
| import struct | |
| import bson | |
| from bson.errors import InvalidBSON | |
| class SqldumpMiddleware(object): |
| package main | |
| import ( | |
| "github.com/codegangsta/martini" | |
| "github.com/martini-contrib/oauth2" | |
| "github.com/martini-contrib/sessions" | |
| ) | |
| func main() { | |
| m := martini.Classic() |
| #!/bin/bash -x | |
| # Description:L2TP/IPsec for CentOS 6.5 64bit | |
| # 2014/01/06 @ysaotome | |
| ( | |
| ### setting | |
| /bin/cat << _SECRETS_ > /tmp/SECRETS_TMP.txt | |
| #============================================== | |
| # username auth_server password auth_ipaddress | |
| "hoge001" "xl2tpd" "hoge##123" * |
| import tornado | |
| class RequestContextHandler(tornado.web.RequestHandler): | |
| def _execute(self, transforms, *args, **kwargs): | |
| # following the example of: | |
| # https://github.com/bdarnell/tornado_tracing/blob/master/tornado_tracing/recording.py | |
| global_data = {} # add whatever here, e.g. self.request |
| #coding: utf-8 | |
| from nose.plugins.skip import SkipTest | |
| from mongoengine.python_support import PY3 | |
| from mongoengine import connect | |
| try: | |
| from django.test import TestCase | |
| from django.conf import settings | |
| except Exception as err: |
| from flask import Flask, url_for | |
| from werkzeug.serving import run_simple | |
| from werkzeug.wsgi import DispatcherMiddleware | |
| app = Flask(__name__) | |
| app.config["APPLICATION_ROOT"] = "/abc/123" | |
| @app.route("/") | |
| def index(): |
| import ( | |
| "bytes" | |
| "crypto/tls" | |
| "crypto/x509" | |
| "io/ioutil" | |
| "net/http" | |
| ) | |
| wechatCertPath = "/path/to/wechat/cert.pem" | |
| wechatKeyPath = "/path/to/wechat/key.pem" |
| package common | |
| import ( | |
| "fmt" | |
| "time" | |
| ) | |
| // Timestamp 自定义时间戳类型,支持Mysql的TIMESTAMP,DATETIME,DATE类型 | |
| type Timestamp int64 |
| worker_processes 2; | |
| error_log /var/log/nginx/error.log; | |
| pid /var/run/nginx.pid; | |
| events { | |
| worker_connections 1024; | |
| use epoll; | |
| } |