w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
module as folder, but index.js under the folder only contains some require statements
I looked at the source you're talking about, and the basic answer to your question is that the code in those requires gets run. Normally, you're right that you need to have some kind of export to make use of objects inside those files, but hexo is being a bit nonstandard. Instead of having each module be independent and fairly agnostic (except via requires), what they're doing is creating an object called 'extend' (look in extend.js) then each of those individual files (e.g. ./init, ./migrate, etc) require extend.js and hang new objects and functions on it in a sort of namespaced fashion. If you look at the end of those files you'll see something calls to extend.tag.register and others. Modules are cached when required, so in practice it acts something like a singleton in other langu

Categories : Javascript

Nodejs module and require binding to global object
Every source file is wrapped into a function by node.js module helpers: see NativeModule.wrapper, NativeModule.wrap in node.js. In your source file exports, require, module, __filename, __dirname are arguments to that function. When running repl, require and others are referenced from repl context - see REPLServer.prototype.createContext in repl.js

Categories : Node Js

asp.net app in virtual directory to look for bin folder in parent website in iis7
Few solutions: 1) Create symbolic link 2) Install DLLs into GAC Hope these help!

Categories : Asp Net

Including a file in an included folder's parent directory fails
The relative paths are always interpreted from the current working directory (usually referred to as CWD). With web requests this is usually the file's directory that got the request to handle, but can be changed any time with chdir(), you can check it's current value with getcwd(). If you want your code to be resilient against the cwd, you can use the __DIR__ magic constant or if you are on an ancient php version (before 5.3) the dirname(__FILE__) in your includes, like this: require_once __DIR__.'/../DB.php';

Categories : PHP

Run nodejs command line module to output in nodejs web server?
you could have 2 node instances. One the http server and the second instance the command line instance to run jasmine. The http server instance would spawn the command line instance. Then you could register a GET route on the http server such as someexample.com/runtests which would call the tests and wait for the tests to finish and respond with the console output. This is sort of unorthodox, but there wouldn't be a direct way to run command line applications through the browser without modifying their source.

Categories : Node Js

Require fay code from nodejs
It's possible to use fay code from javascript, but at the moment it's a bit verbose, you need to use fully qualified names and manually force function calls. var m = new Main(); document.body.innerHTML = "The 10th fibonacci number is : " + m._(m.Main$fibN(9)); Everything is flat inside Main at the moment, we'd want to separate the compilation of each module so each can be output separately. (then we can also migrate to haskell-packages) Then we need the possibility to output a wrapper that does forcing and type conversions for each module so you don't need to this manually when called from JavaScript. Here are some related tickets: #279, 260

Categories : Node Js

How to access a file in a directory from other directory, when both are in same parent directory with HTML
if dir1 and dir2 are in the same parent directory then this is how you access 2.html from 1.html: <a href="../dir2/2.html">link to 2.html</a> hope it helped :)

Categories : HTML

Understanding NodeJS's exports/require
That is what's called a circular dependency (the node docs call it a "cycle") when two modules both require each other. It is almost always a design choice you can and should avoid. Node has to load one module first, so the second one ends up getting an empty object due to this circular dependency edge case. The solution is to not make gets.js require app.js, just have app.js require gets.js. //app.js var app = require('express')(); var gets = require('./gets'); gets.setup(app); then //gets.js function setup (app) { app.get('/blah', myHandler); } exports.setup = setup;

Categories : Node Js

Nodejs + Require instanceof behaviour
Cannot reproduce the problem. Working for me using version 0.12 and 4.0.0 (tested both). What you should consider in future is that you reference your OWN modules using relative paths (absolute ones are not system independent). If you don't, you normally reference core modules of Node.js directly or NPM installed ones. So change 'mymodule' to './mymodule' (change path accordingly).

Categories : Node Js

Change default source directory for perl module Module::Build
use Module::Build; use File::Copy 'cp'; my $class = Module::Build->subclass(code => <<''); sub process_EXTRALIB_files { my ($self, $target) = @_; while (my ($from, $to) = each %{ $self->{properties}{"${target}_files"} }) { cp $from, $to; $self->_add_to_manifest('MANIFEST', $to); } } my $self = Module::Build->new( ⋮ RESOURCES_files => {'RESOURCES/prepare/form.html' => 'RESOURCES/new/prepare/form.html'}, EXTRALIB_files => {'../../LIBS/perl/Private/DB.pm' => '../lib/Private/DB.pm'}, ); $self->add_build_element('RESOURCES'); $self->add_build_element('EXTRALIB'); $self->create_build_script; perl Build.PL ./Build ./Build manifest ./Build dist

Categories : Perl

If a nodejs module exports an object to two other modules, do changes made to that object in one downstream module propagate to the other?
here is the way I do it: var datastore = {}; module.exports = datastore; var redis = require('redis'); var client = ''; var testResults = ''; datastore.CreateDataStore = function(storePort, storeUrl, passwd) { client = redis.createClient(storePort,storeUrl); redisClient.auth(passwd, function() { console.log("redisAuth Connected!"); }); testResults = createSiteUpdater(""); } datastore.setdata = function(data, callback){ client.set(data.key, data.value, callback); } the second function is accessor functions to my database. Not sure that this is the best way, but lets me swap out different databases easily if I need to and should save any changes to the datastore object. Instead of requiring it more than one module, pass the single object around Here is a

Categories : Javascript

application Support folder doest not iphone folder while creating a directory
make sure you're not searching for it because you will get the wrong application folder, you have to go to your "user name" folder and make it show hidden files and that will show the hidden library file so you can start navigating your way to that address... try that and anymore issues with it ill try and help further.

Categories : Objective C

Copy entire directory to output folder maintaining the folder structure?
Try XCOPY instead of COPY; e.g. XCOPY "$(SolutionDir)ResourcesTemplate" "$(TargetDir)" /s /i /y More info on XCOPY here... http://www.computerhope.com/xcopyhlp.htm

Categories : Visual Studio

How can I copy only files and folder created in the past hour in one directory to a new directory?
Robocopy doesn't have the granularity, but XXcopy seems to handle it. /DA#30m selects files made within the last 30 minutes. XXcopy is free for non commercial use and can be downloaded from http://www.xxcopy.com XXcopy is xcopy on steroids.

Categories : Batch File

Composer - installing packages in parent folder path not a new folder
I wonder what file layout you actually want, but here is what I got: mkdir projectDir cd projectDir That is your empty directory to be filled. composer require slim/slim "2.3.*" That adds the slim framework to your empty directory, i.e. it adds a newly created composer.json file, adds that requirement as well, and installs it. At this point this directory looks pretty much exactly like your myProject -> my project files here.

Categories : PHP

coffeescript + nodejs: caching the compiled server-side javascript using require
Well if you don't want to "clutter up your directory with a bunch of .js files", I think you're SOL. If you don't store the .js files on disk ever, you need to compile .coffee to javascript on the fly every time. The coffee command to my knowledge does not do any comparison of mtime between the .js and .coffee files, although in theory it could, in which case leaving the .js files around could help your situation. Given your preferences, the only thing that I can suggest is: run a watcher that builds all your .coffee files into a separate build subdirectory tree start your app with node build/app.js instead of coffee ignore the build directory in your .gitignore You'll have to give up on running things via coffee though. Curious to see if others have better suggestions. My projects don

Categories : Node Js

nodejs unit testing framework that does not require an external test runner
The node.js project itself simply uses the built-in assert module and JavaScript exceptions. They have a fairly straightforward script that runs every .js file in a directory tree and if the file doesn't throw any exceptions, the test is considered passing. You could use something like that. However, although most frameworks do have a command line runner, you absolutely never need to install them (or anything) with -g. If you understand the basic concept of the unix PATH environment variable, you can npm install --save-dev mocha (for example) and then run your tests with ./node_modules/.bin/mocha. No -g required. See also http://peterlyons.com/problog/2012/09/managing-per-project-interpreters-and-the-path

Categories : Node Js

Python joining current directory and parent directory with os.path.join
You can use normpath, realpath or abspath: import os goal_dir = os.path.join(os.getcwd(), "../../my_dir") print goal_dir # prints C:/here/I/am/../../my_dir print os.path.normpath(goal_dir) # prints C:/here/my_dir print os.path.realpath(goal_dir) # prints C:/here/my_dir print os.path.abspath(goal_dir) # prints C:/here/my_dir

Categories : Python

How to add a file thats copied from one directory to a folder in another directory thats incremented
I would recommend using time stamps rather than sequential numbering. Also here is everything in one command and it is user independent. @xcopy "%LocalAppData%GoogleChromeUser DataDefaultookmarks*" "%UserProfile%DesktopBackup of Bookmarks\%Date:~10,4%-%Date:~4,2%-%Date:~7,2%" /I /Y This will copy both the bookmarks and bookmarks.bak file to a time-stamped folder inside the Backup of Bookmarks folder.

Categories : Batch File

Require.js, module dependencies
EDIT: Misread something, skip ahead. Original reply below: Part of the point of requirejs is that a module only be instantiated once. This is actually running counter to how your setup is at the moment, though. Run "Mouse.js"' define function, store returned result (a constructor function) as module path "Mouse" Run "Selection.js"' define function, store returned result (selection, which has not received a value yet) as module path "Selection" Anything requiring "Selection" will have 'undefined' as a result. I think the goal you want here is to return some sort of unchanging object, or even a function, from Selection. Then, whatever is requiring it can do something like this: require('Selection', function(getSelection) { var currentElement = getSelection(); // and so on... }); Sin

Categories : Javascript

Can a require.js module depend on itself
(Comment added as an answer by request.) If ds refers to a method within itself, couldn't you call your example function of assoc() directly, rather than try to use ds.assoc()? (This also eliminates the perceived need for ds to load itself.)

Categories : Javascript

Best way to access a parent Module from a Sub Module with Marionette
Unfortunately, while Marionette gives you the ability to drill down the app/module/submodule chain via the submodules property, it doesn't offer easy access to identify a Module's parent. We've encountered a few times where this could have been helpful, but never ran into a situation where not having it became an issue. That said, if you think it'll make your codebase cleaner you might try wrapping the _addModuleDefinition function to create a parent property: var func = Marionette.Module._addModuleDefinition; Marionette.Module._addModuleDefinition = function(parentModule, module) { module.parent = parentModule; func.apply(this, arguments); }; This would give you the ability to do something like App.module("Parent.Child", function(self, App, ...) { self.parent.trigger('what

Categories : Javascript

Get parent directory's parent directory name in java
Have a look at http://developer.android.com/reference/java/io/File.html#getParentFile() Applying this twice will probably get you the right directory. But note that you program might or might not be allowed to go there, based on the settings in the file system and the context your code runs in.

Categories : Java

Using require syntax instead of module in Typescript
No - you can choose to use RequireJS or a different module loader if you prefer. RequireJS isn't built in, so you need to add that if you want it. The syntax for importing modules is compiled into either AMD (for loaders such as RequireJS) or CommonJS (for loaders such as the NodeJS module loader) - so anything that is compatible with one of those can be used.

Categories : Typescript

Require.js Module load order
Module load order should not matter. E.g. links1.js define(function() { return { addLinks: function() { ... } }; }) links2.js define(function() { return { addLinks: function() { ... } }; }) events.js define(function() { return { addEvents: function() { ... } }; }) app.js require(["links1", "links2", "events"], function(links1, links2, events) { links1.addLinks(...); links2.addLinks(...); events.addEvents(...); }); In other words, don't have your modules execute something when they load, have them return methods that can be executed when you are ready. The modules above can load in any order ... links1, links2, events links1, events, links2 links2, links1, events links2, events, links1 events, links1, links2 events, links2, links1 and it does not ma

Categories : Javascript

how can access require.js module's function?
You shouldn't usually assign to globals from a RequireJS module (i.e. set properties on window). /path/test.js define(function() { function test(val) { alert(val); } return test; } /path/app.html <!-- import requirejs ... --> <script> // Use the return value from the "test" module. require(["test"], function(testFn) { testFn("hello"); }); </script>

Categories : Javascript

Passing Parameters to Require.js module
I would allow your module to accept a parameter and then pass it along from within the require callback. Something like: module.js define(['depA', 'depB'], function(depA, depB) { return { foo: function(param) { // Do something with param } } }); main.js require(['module'], function(module) { module.foo('myparam') }); You could also grab it from a link if you liked, by attaching events in the require: require(['module'], function(module) { document.querySelector('.link').addEventListener(function(event) { module.foo(this.href); event.preventDefault(); }); });

Categories : Asp Net Mvc

Require.js optional module loading
You can set the config for require.js by ether calling require.config or settings a global require object before fetching require.js source file: require.config({ paths: { 'calc-lib': window.hasFeature('web-workers') ? 'webworker-calc' : 'server-calc' } }); Or: <script> var require = { paths: {...} } </script> <script src="require.js" data-main="script/main"></script> and then require it in a "normal" way and r.js compressable way: require(["other-dependencies", "calc-lib"], function (deps, calc) { // Code goes here }); As long as the "api" for both the files is the same you will not have to make any other precautions.

Categories : Javascript

Is it posible to set dependencies for a folder using require.js
No, you cannot easily create a wildcard to add dependencies to all files under a folder from the configuration itself. You can however create a loop before the config and add whichever dependencies you want. var config = { shim: { 'plugin/backbone/xyz': { deps: ['lib/dependency'], exports: 'Backbone' } } }; for(var shim in config.shim) { if(shim.indexOf('plugin/backbone/') == 0) { if(config.shim[shim].deps == null) { config.shim[shim].deps = []; } config.shim[shim].deps.push('lib/backbone'); } } require.config(config); This is the only way I can think of without having to override one of require's functions yourself. Not elegant, I will admit, but it will do the job.

Categories : Javascript

How to Invalidate Dojo/Require's Module Cache?
According to the dojo site, the function is not automatically included in "built" dojo files. If you look at an uncompressed dojo.js you will see it there. From:http://dojotoolkit.org/reference-guide/1.9/loader/amd.html The following table provides a list of options that are leveraged within the loader. The first column is the Option/Feature as defined within the loader, the second options is whether this is a detected feature (via has.add()) or if it is just an option and its default value. With “unbuilt” source, all the features and options are available. If the loader has been built, then some of these features may have been set as staticHasFeatures and not be configurable anymore. Also here it says that you might be able to turn the function back on by adding a

Categories : Javascript

can not have require multiple modules with module.exports in it
It looks like you're attempting to pass require() an undefined variable two times. require() needs to take a string as an argument to determine what module you want to load. If the other two modules are in the same directory as app.js, try m1 = require('./module1') m2 = require('./module2') EDIT: What you're forgetting to do is m1 = new require('./module1')() m2 = new require('./module2')() Assuming that you modules look like: module.exports = function() { this.method = function(){} } Personally, instead of a function I would just return an object literal from my module: module.exports = { method1: function(){}, method2: function(){} } Then I could invoke the methods from the module's export like such: m1 = require('./module1'); m1.method1();

Categories : Node Js

How do i require and include a module in the initialize method
The reason that you can't call include in initialize like that is that include is a method that's only defined on classes and modules, but inside of an instance method like initialize the implicit receiver is an object of your class, not the class itself. Since you only need the methods to be available on the newly created object, you can just use extend instead of include. extend is like a per-object version of include in that it adds the methods of the given module as singleton methods to an object rather than adding them as instance methods to a module or class.

Categories : Ruby

How to redirect all sub-directory pages to parent directory?
Add this to your .htaccess file RedirectMatch 301 ^/folder/$ http://example.com/folder What this basically does in corresponding to your question is redirect anything (be it sub directories, or files) inside the folder directory to your parent folder.

Categories : PHP

How to print the name of my current directory's parent directory
You can use ${PWD%/*}: $ echo $PWD /home/me/test/t $ echo ${PWD%/*} /home/me/test As the expression ${string%substring} Strips shortest match of $substring from back of $string (reference).

Categories : Shell

Emacs - Require All Files In a Directory
You could try something like this: (mapc (lambda (name) (require (intern (file-name-sans-extension name)))) (directory-files ".emacs.d" nil "\.el$")) Explanation: retrieve the list of elisp files using directory-files remove extension using file-name-sans-extension get the symbol associated to the file base name using intern, and require it

Categories : Emacs

Store models in folder, use index.js to require them all
In node.js, modules are cached after the first time they are loaded. So you don't need to pass the mongoose from the app.js. For example, in models/index.js: require('./counters') exports.User = require('./user') require('./token'); require('./team'); require('./role'); require('./layer'); require('./feature'); // I prefer to use a loop to require all the js files in the folder. in models/user.js: var mongoose = require('mongoose'); var userSchema = mongoose.Schema({ // ... Define your schema here }); var User = module.exports = mongoose.model('User', userSchema); module.exports.getUserById = function(id, callback) { User.findById(id, callback); } module.exports.getUserByUsername = function(username, callback) { var query = {username: username}; User.findOne(query, callback)

Categories : Node Js

Can't require php files from another folder - permission denied
You may not have group permissions on that file. You could try this in your SSH shell: chmod /home/script1/public_html/SSI.php 774 Make sure that you are using the correct ACL, 774 is group/user writable, readable and executable and world readable only.

Categories : PHP

Require a downstream job to use the same commit as its parent
You need the parameterized trigger plugin for jenkins, installed along the Git plugin that you probably already have installed. It allows to specify Git SHA1 commit id for next build as predefined parameter.

Categories : GIT

require an external module in jade in a node.js webserver
You can register helpers from within Express. In a request handler. var utils = require('../../app/server/modules/queries.js') function(req, res) { res.render("sample", { locals: { title: "Welcome to Derpco", someUtilFunction: utils.someUtilFunction } }); }; Also you can register helpers globally using app.locals.helpername = ...

Categories : Node Js

Using require with casperjs returns "Can't find module" erorr
You should try to upgrade to the lastest master build of CasperJS as this pull request that I made should fix the problem that you're having. However, if you don't want to upgrade, you could also try running CasperJS with the following: casperjs test ./testStage.js

Categories : Misc



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.