很多公司都大量使用了python,其中有一些开发规范,code guidline, 通用组件,基础框架是可以共用的。
每个公司都自己搞一套, 太浪费人力,我想开一帖和大家讨论一下这些python基础设施的搭建。
原则是我们尽量不重新发明轮子,但开源组件这么多,也要有个挑选的过程和组合使用的过程,在这里讨论一下。
另一方面,有些开源组件虽然强大,但我们不能完全的驾驭它,或只使用其中很少的一部分,我们就可以考虑用python实现一个简单的轮子,可控性更强,最好不要超过300行代码。
| // | |
| // PSPDFThreadSafeMutableDictionary.m | |
| // | |
| // Copyright (c) 2013 Peter Steinberger, PSPDFKit GmbH. All rights reserved. | |
| // | |
| // Permission is hereby granted, free of charge, to any person obtaining a copy | |
| // of this software and associated documentation files (the "Software"), to deal | |
| // in the Software without restriction, including without limitation the rights | |
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| // copies of the Software, and to permit persons to whom the Software is |
| #!/bin/bash | |
| NAME="hello_app" # Name of the application | |
| DJANGODIR=/webapps/hello_django/hello # Django project directory | |
| SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket | |
| USER=hello # the user to run as | |
| GROUP=webapps # the group to run as | |
| NUM_WORKERS=3 # how many worker processes should Gunicorn spawn | |
| DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use | |
| DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name |
| // Taken from the commercial iOS PDF framework http://pspdfkit.com. | |
| // Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved. | |
| // Licensed under MIT (http://opensource.org/licenses/MIT) | |
| // | |
| // You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it. | |
| // PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit. | |
| #import <objc/runtime.h> | |
| #import <objc/message.h> |
| DSYM_ZIP_FPATH="/tmp/$DWARF_DSYM_FILE_NAME.zip" | |
| # create dSYM .zip file | |
| echo "Compressing .dSYM to ${DSYM_ZIP_FPATH} ..." | |
| test -e "${DSYM_SRC}" && (echo "Creating zip of dSYM file" && /usr/bin/zip -r "${DSYM_ZIP_FPATH}" "${DSYM_SRC}" -dc |
| # Install Homebrew | |
| ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go) | |
| # Follow on-screen instructions (X11 isn't necessary for this if it shows as not installed) | |
| brew install node | |
| # Open .bashrc and add this line (create .bashrc if its not in your home directory already) |
| """ | |
| Dependencies: | |
| pip install tabulate simplejson ujson yajl msgpack | |
| """ | |
| from timeit import timeit | |
| from tabulate import tabulate | |
| setup = '''d = { | |
| 'words': """ |
| i386 : iPhone Simulator | |
| x86_64 : iPhone Simulator | |
| arm64 : iPhone Simulator | |
| iPhone1,1 : iPhone | |
| iPhone1,2 : iPhone 3G | |
| iPhone2,1 : iPhone 3GS | |
| iPhone3,1 : iPhone 4 | |
| iPhone3,2 : iPhone 4 GSM Rev A | |
| iPhone3,3 : iPhone 4 CDMA | |
| iPhone4,1 : iPhone 4S |
| Why is there no such DataImportHandler thing in ElasticSearch? Uhm, well ... but because: | |
| 1. You should really consider your own scripts | |
| (be it jvm based, perl, ruby, php, nodejs/javascript) | |
| to feed ElasticSearch via bulk indexing: | |
| http://www.elasticsearch.org/guide/reference/java-api/bulk.html | |
| 2. There are two projects doing it already: | |
| * http://code.google.com/p/sql-to-nosql-importer/ | |
| * https://github.com/Aconex/scrutineer (keeps DB in synch with ES or solr!) |