This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "node-mongo-lab", | |
| "version": "1.0.0", | |
| "main": "index.js", | |
| "license": "MIT", | |
| "devDependencies": { | |
| "@types/bluebird": "^3.0.36", | |
| "@types/mongodb": "^2.1.36", | |
| "@types/node": "^6.0.54", | |
| "typescript": "^2.1.4" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /usr/lib/gnome-terminal/gnome-terminal-server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as path from 'path'; | |
| import * as fs from 'fs'; | |
| import * as Promise from 'bluebird'; | |
| import { CWD } from './config'; | |
| // global variables | |
| const LIB_PATH = path.resolve(CWD, 'lib'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Promise = require('bluebird'); | |
| // You can input any argument in this function to test workflow of promise | |
| function testPromise(input) { | |
| let promise = Promise.resolve(input); | |
| promise | |
| .then(makeTask('Task1')) | |
| .then(makeTask('Task2')) | |
| .then(makeTask('Task3')) | |
| .catch(makeErrorPredicate('Task1'), taskLog('Task1')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime | |
| from timeit import timeit | |
| un = datetime.utcnow | |
| timeit("hasattr(un, '__call__')", 'from __main__ import un') # 0.12641560214373812 | |
| timeit("'__call__' in dir(un)", 'from __main__ import un') # 5.613213103966963 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Timestamps 用于自动产生数据的创建时间和更新时间 | |
| * | |
| * 使用方法: | |
| * | |
| * schema.plugin(require('./timestamp')); | |
| * | |
| */ | |
| var timestampsPlugin = function (schema) { | |
| if (schema.path('_id')) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* The API controller | |
| Exports 3 methods: | |
| * post - Creates a new thread | |
| * list - Returns a list of threads | |
| * show - Displays a thread and its posts | |
| */ | |
| var Thread = require('../models/thread.js'); | |
| var Post = require('../models/post.js'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| upstream $repo_name { | |
| server unix://$service_deployment_filename/websock.sock; | |
| } | |
| # configuration of the server | |
| server { | |
| # the port your site will be served on | |
| listen 80; | |
| # the domain name it will serve for | |
| server_name localhost; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Queue | |
| import threading | |
| import urllib2 | |
| # called by each thread | |
| def get_url(q, url): | |
| q.put(urllib2.urlopen(url).read()) | |
| theurls = ["http://google.com", "http://yahoo.com"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SignUpSerializer(serializers.ModelSerializer): | |
| class Meta: | |
| model = User | |
| fields = ('username', 'email', 'password', 'first_name', 'last_name') | |
| def save(self, *args, **kwargs): | |
| """create user | |
| """ | |
| User.objects.create_user(**self.validated_data) | |
| ''' |