Provider | Singleton | Instantiable | Configurable |
---|---|---|---|
Constant | Yes | No | No |
Value | Yes | No | No |
Service | Yes | No | No |
Factory | Yes | Yes | No |
Decorator | Yes | No? | No |
Provider | Yes | Yes | Yes |
This file contains 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 re | |
import sys | |
import requests | |
import gitlab | |
URL = 'https://gitlab.com' | |
SIGN_IN_URL = 'https://gitlab.com/users/sign_in' |
This file contains 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
/** | |
* Autowire Quartz Jobs with Spring context dependencies | |
* @see http://stackoverflow.com/questions/6990767/inject-bean-reference-into-a-quartz-job-in-spring/15211030#15211030 | |
*/ | |
public final class AutowiringSpringBeanJobFactory extends SpringBeanJobFactory implements ApplicationContextAware { | |
private transient AutowireCapableBeanFactory beanFactory; | |
public void setApplicationContext(final ApplicationContext context) { | |
beanFactory = context.getAutowireCapableBeanFactory(); | |
} |
This file contains 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
function versionCompare(a, b) { | |
var i; | |
var len; | |
if (typeof a + typeof b !== 'stringstring') { | |
return false; | |
} | |
a = a.split('.'); | |
b = b.split('.'); |
This file contains 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
function createCORSRequest(method, url) { | |
var xhr = new XMLHttpRequest(); | |
if ("withCredentials" in xhr) { | |
// 此时即支持CORS的情况 | |
// 检查XMLHttpRequest对象是否有“withCredentials”属性 | |
// “withCredentials”仅存在于XMLHTTPRequest2对象里 | |
xhr.open(method, url, true); | |
} else if (typeof!= "undefined") { | |
This file contains 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
启动 | |
pm2 start app.js -i max | |
监控 | |
pm2 monit | |
log | |
pm2 logs |
This file contains 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
Client = (function() { | |
var d = {engine: {ie: 0,gecko: 0,webkit: 0,opera: 0,khtml: 0},browser: {ie: 0,firefox: 0,chrome: 0,opera: 0,safari: 0,konq: 0}}; | |
var b = navigator.userAgent; | |
var c = d.engine; | |
var a = d.browser; | |
if (window.opera) { | |
a.version = c.version = window.opera.version(); | |
a.opera = c.opera = parseFloat(c.version) | |
} else { | |
if (/AppleWebKit\/(\S+)/.test(b)) { |
This file contains 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
function getTransitionEndEventName() { | |
var obj = { | |
TransitionEvent: "transitionend", | |
WebKitTransitionEvent: "webkittransitionEnd", | |
OTransitionEvent: "OTransitionEnd", | |
otransitionEvent: "otransitionEnd", | |
MSTransitionEvent: "MSTransitionEnd" | |
} | |
// var ev = document.createEvent("TransitionEvent"); // FIXME: un-specified | |
// ev.initTransitionEvent("transitionend", true, true, "some-unknown-prop", -4.75); |
This file contains 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 nodemailer = require('nodemailer'); | |
var config = require('../config/config.js'); | |
// Create a SMTP transport object | |
var transport = nodemailer.createTransport("SMTP", { | |
service: config.email.service, | |
auth: { | |
user: config.email.user, | |
pass: config.email.pass | |
} |
This file contains 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
module.exports = function (options) { | |
var randFn = (options && options.fn) || Math.random; | |
function random(schema, options) { | |
var path = (options && options.path) || 'random'; | |
var field = {}; | |
field[path] = { | |
type: { type: String, default: 'Point' }, | |
coordinates: { type: [Number], default: function () { return [randFn(), randFn()] } } | |
}; |
NewerOlder