require

Composer require local package

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've got a couple of libraries [Foo and Bar] that I'm developing in concert, but are still technically separate things. Previously I've just re-defined the autoloader to like "Foo\\": "../Foo/src" , but now that I've added a Guzzle dependency to Foo, Bar flips it's lid because it's not one of its dependencies. Directory structure: /home/user/src/ Foo/ src/ FooClient.php composer.json Bar/ src/ BarClient.php composer.json Theoretical Autoload Statement: [in Bar/composer.json] "require": { "local": "../Foo/composer.json" } Example code:

Enabling HTTPS on express.js

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to get HTTPS working on express.js for node, and I can't figure it out. This is my app.js code. var express = require('express'); var fs = require('fs'); var privateKey = fs.readFileSync('sslcert/server.key'); var certificate = fs.readFileSync('sslcert/server.crt'); var credentials = {key: privateKey, cert: certificate}; var app = express.createServer(credentials); app.get('/', function(req,res) { res.send('hello'); }); app.listen(8000); When I run it, it seems to only respond to HTTP requests. I wrote simple vanilla node.js based

passport.js passport.initialize() middleware not in use

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using node with express + mongoose and trying to use passport.js with restful api. I keep getting this exception after authentication success (I see the callback url on the browser): /Users/naorye/dev/naorye/myproj/node_modules/mongoose/lib/utils.js:419 throw err; ^ Error: passport.initialize() middleware not in use at IncomingMessage.req.login.req.logIn (/Users/naorye/dev/naorye/myproj/node_modules/passport/lib/passport/http/request.js:30:30) at Context.module.exports.delegate.success (/Users/naorye/dev/naorye/myproj/node_modules

rails server bin/rails:6: warning: already initialized constant APP_PATH error

匿名 (未验证) 提交于 2019-12-03 02:12:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've tried a number of things like uninstalling/reinstalling rails and gems but to no avail. When I go into my new project and run rails s or bundle exec rails server I'm getting this error: bin/rails:6: warning: already initialized constant APP_PATH /Users/toabui/Sites/cms/bin/rails:6: warning: previous definition of APP_PATH was here Usage: rails COMMAND [ARGS] Inside my bin/rails I see this code: #!/usr/bin/env ruby begin load File.expand_path("../spring", __FILE__) rescue LoadError end APP_PATH = File.expand_path('../../config

Ruby on Rails 3 - Reload lib directory for each request

匿名 (未验证) 提交于 2019-12-03 02:12:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm creating a new engine for a rails 3 application. As you can guess, this engine is in the lib directory of my application. However, i have some problems developing it. Indeed, I need to restart my server each time I change something in the engine. Is there a way to avoid this ? Can I force rails to completely reload the lib directory or a specific file and his requirements for each request ? Thanks for your help :) 回答1: TL;DR put this in config/application.rb config.eager_load_paths += ["#{Rails.root}/lib"] remove require statements for

Ruby on Rails 3 - Reload lib directory for each request

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm creating a new engine for a rails 3 application. As you can guess, this engine is in the lib directory of my application. However, i have some problems developing it. Indeed, I need to restart my server each time I change something in the engine. Is there a way to avoid this ? Can I force rails to completely reload the lib directory or a specific file and his requirements for each request ? Thanks for your help :) 回答1: TL;DR put this in config/application.rb config.eager_load_paths += ["#{Rails.root}/lib"] remove require statements for

Express.js req.body undefined

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have this as configuration of my Express server app.use(app.router); app.use(express.cookieParser()); app.use(express.session({ secret: "keyboard cat" })); app.set('view engine', 'ejs'); app.set("view options", { layout: true }); //Handles post requests app.use(express.bodyParser()); //Handles put requests app.use(express.methodOverride()); But still when I ask for req.body.something in my routes I get some error pointing out that body is undefined . Here is an example of a route that uses req.body : app.post('/admin', function(req, res){

Mismatched anonymous define() module

匿名 (未验证) 提交于 2019-12-03 02:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm getting this error when I browse my webapp for the first time (usually in a browser with disabled cache). Error: Mismatched anonymous define() module: function (require) { HTML : <html> . . . <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script> <script> var require = { urlArgs: "v=0.4.1.32" }; </script> <script data-main="assets/js/main" src="assets/js/libs/require.js"></script> <script src="assets/js/ace/ace.js?v=0.4.1.32"></script> </body> </html> JS : $(function () { define(function (require) { // do

Webpack ProvidePlugin vs externals?

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm exploring the idea of using Webpack with Backbone.js . I've followed the quick start guide and has a general idea of how Webpack works, but I'm unclear on how to load dependency library like jquery / backbone / underscore. Should they be loaded externally with <script> or is this something Webpack can handle like RequireJS's shim? According to the webpack doc: shimming modules , ProvidePlugin and externals seem to be related to this (so is bundle! loader somewhere) but I cannot figure out when to use which. Thanks 回答1: It's both possible

Parsing huge logfiles in Node.js - read in line-by-line

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to do some parsing of large (5-10 Gb)logfiles in Javascript/Node.js (I'm using Cube). The logline looks something like: 10:00:43.343423 I'm a friendly log message. There are 5 cats, and 7 dogs. We are in state "SUCCESS". We need to read each line, do some parsing (e.g. strip out 5 , 7 and SUCCESS ), then pump this data into Cube ( https://github.com/square/cube ) using their JS client. Firstly, what is the canonical way in Node to read in a file, line by line? It seems to be fairly common question online: http://www.quora.com/What-is