w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
C++ modules with nodejs in heroku
Ok, the mechanism was evident Create in root directory a binding.gyp with data of the build. Place C++ scripts in root directory. Modify actual package.json and add in structure two commands to execute during install period (on each push): "scripts": { "install": "node-gyp configure; node-gyp build " } git add file1.cpp, file2.cpp, binding.gyp, etc. Commit and push. [Optional] Add flags to binding.gyp to silence warnings. C++ module should start to compile with additional packages.

Categories : Node Js

NodeJS binary modules vs those written in JS
Most MongoDB drivers are written in the language that they are used with. The Python driver is written in Python, the Perl driver in Perl. There are a few exceptions, as the PHP driver is written in C and the Python driver as an optional C extension to speed things up. The node-mongodb-native driver is written all in JavaScript: https://github.com/mongodb/node-mongodb-native. It make sense as the NodeJS platform is optimised for this and there should be no adverse effects.

Categories : Database

NodeJS required module not available in other modules
Each file has to include references to modules index.js var fs = require("fs"), other = require("./otherfile"); // you can now use `fs` otherfile.js var fs = require("fs"); // you can now use `fs` here One of the best parts about this is you're not locked into naming the variable a certain way in any given file. Every file is pretty much isolated from all the other files in your lib, and that's a very good thing. Also know that you can include just parts a module if you'd like var read = require("fs").readFile; read("myfile.txt", function(err, data) { if (error) { return throw error; } console.log(data); }; Explanation: Node.js does not encourage the use of globals; and as such, you should not try to implement things that depend on global variables. Whe

Categories : Node Js

nodejs on windows: nmp install does not download modules
You have a typo in your package.json, it should be "dependencies". Make sure to generate your package.json with npm init, so to avoid this kind of problems.

Categories : Node Js

Cross compile nodejs modules to Windows with node-gyp
There are two problems here. First, you have to get cross-compiling set up to go from your ARM box to Windows. This should help: http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux Then (assuming your compilers and linker are set up: CXX, etc.), you just need to specify the architecture when running node-gyp: node-gyp --arch x64 rebuild That should do it.

Categories : Node Js

Writing async http returns in Nodejs
Async functions will never return something that has to fetched with async. getWebPageBody in your case returns undefined, and then later your callbacks happen. In synchronous programming you return a value. But in async, you provide it as an argument to a callback function. So instead, make your function accept a callback argument, and simply call it when you are done. var getWebPageBody = function(res, callback) { var pageRes = ""; res.setEncoding('utf8'); res.on('data', function(requestBody) { pageRes = requestBody; console.log('[ DEBUG ] BODY: ' + pageRes);

Categories : Node Js

nodejs + ejs for if express returns a unexpected catch
If the example you provided is indeed all of your code, you aren't closing all of your tags, specifically, you aren't closing your for loop, one of your divs, or your form. When I close all of these, the view will render for me without errors. This is the ejs that I used: <!DOCTYPE html> <html> <head> <title><%= title %></title> <link rel='stylesheet' href='/stylesheets/style-min.css' /> </head> <body> <h1 id="page-title"><%= title %></h1> <div id="list"> <form action="user/create/" method="post" accept-charset="utf-8"> <div class="item-new"> <% for (var key in userData){ %> <% if(key != 'birthdate'){ %> <input class="in

Categories : Node Js

How to write modules that are both nodejs compatible and browser compatible?
I really recommend giving another look at Browserify. Other than that, add a Universal Module Definition (UMDJS) exporter in your files. This will allow you to expose your modules in node, browserify, requirejs/amd, or just thrown into a script tag on any site. Can also use a module transpiler -- write in a ES6 module exporter, and have it convert for use in a browser, or a commonjs/node environment.

Categories : Node Js

How to get size of zip files in a folder and save the name of file and size of zip file in excel
(for %%I in (*.zip) do echo(%%~nI,%%~zI)>C:UsersanoopnDesktopout.csv To get only the folder's name with the calculated size of all ZIP files together use this: @ECHO OFF &SETLOCAL FOR /f "tokens=3" %%a IN ('dir *.zip') DO ( CALL SET "size=%%free%%" SET "free=%%a" ) (ECHO(%cd%,%size%)>C:UsersanoopnDesktopout.csv

Categories : Batch File

RangeError: Maximum call stack size exceeded Nodejs mongoose
This line: setTimeout (testCUPwrite (i), 1); is not doing what you think it is. That's directly executing the testCPUWrite function in the current stack. It's not using setTimeout like you think. Something like setTimeout(testCUPwrite.bind(null, i), 1); Might get you going.

Categories : Node Js

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

Json Parser returns size=0 Android
You're parsing the initial string as an array. It isn't an array, its an object that contains a single array named "data". You need to parse it into a JSONObject, then get the array named data from it, then loop like you do. try { JSONArray articlesArray = new JSONObject(jString).getJSONArray("data"); JSONObject aObject; for(int i=0; i<articlesArray.length(); i++){ aObject=articlesArray.getJSONObject(i); SearchTrack a=new SearchTrack(); a.setId(aObject.getString("id")); a.setLink(aObject.getString("link")); a.setName(aObject.getString("name")); a.setPicture(aObject.getString("picture")); a.setNbAlbum(aObject.getString("nb_album")); a.setNbFan(aObject

Categories : Android

size() returns 1 where matrix dimension should not exist
size(X,3) is the size of the third dimension which in your case IS 1. Try X = rand(2, 3, 5, 23, 4,2, 6) for example, now size(X, 3) should give 5. After all a 2D matrix is really the same a a 3D matrix where the size of the third dimension is 1

Categories : Matlab

mysql Length() for different languages returns different size
use : CHAR_LENGTH() (the number of characters) reference : http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_char-length

Categories : Mysql

PHP copy file A if size bigger than size of file B
You need to use > instead of < As of right now you're checking to see if the $newFile is smaller and if so copy it to the old directory. <?php $newfile = 'somefile.txt'; $oldfile = 'old/somefile.txt'; if (filesize($newfile) > filesize($oldfile)){ chmod($oldfile, 0777); if(!copy($newfile,$oldfile)) { echo $newfile. 'is copied and larger'; } else { echo $newfile. 'is larger but could not be copied'; } } else { echo $newfile. 'is smaller'; } ?>

Categories : PHP

get file size and split the file based on size
You can use du -BG <file> to get the size in GB. Hence, you can do: size=$(du -BG your_file | cut -dG -f1) And then [ $size -ge 3 ] && split -d -b2G your_file file which will give files like file00 file01 Explanation [ $size -ge 3 ] && split -d -b2G your_file file ---------------------------------------------------------------------- condition of size split your_file in blocks of 2GB (-b2G) >=3 GB with name "file" with numerical suffix (-n)

Categories : Unix

Python User-Defined Global Variables Across Modules: Issues calling them when other modules are run
Running a module as a script does not count as importing it as a module. When the Functions_Practice_Main.py script imports Functions_Practice, and Functions_Practice imports Functions_Practice_Main, Python doesn't care that the code in Functions_Practice_Main.py is already running as the main script. Python will run it again to produce the module. How do you fix this? Well, there are several things you should do. First, avoid circular imports if at all possible. Instead of having Functions_Practice import Functions_Practice_Main, pass any data Functions_Practice needs from Functions_Practice_Main as function arguments. In Functions_Practice_Main: Functions_Practice.interactive_remainder_test(name) In Functions_Practice: def interactive_remainder_test(name): number = inputData(na

Categories : Python

Including admin parts in modules(bundles) in symfony2 ansd calling them from other modules and templates
I think you misunderstood what Symfony2 offers you. I'll try to explain some of them for your use case. What I understood You want to create an admin panel on your website. It's a common case. What to do You should create a bundle for this whole content. Like AdminBundle Step by step Let's look at a Symfony2 directory structure. Here's an excerpt. project/ app/ config/ config.yml parameters.yml cache/ AppKernel.php src/ Acme/ DemoBundle/ Controller/ Resources/ config/ public/ views/ AcmeDemoBundle.php vendor/ symfony/ autoload.php web/ .htaccess app.php a

Categories : Symfony2

Ambient declations for javascript modules that add fields to interfaces in other modules
If the item you are extending is an interface, they are open in TypeScript, so you can just add the extras like so: interface ExpressServerRequest { myAdditionalThing(): void; } There are ways of declaring pretty much anything, so if this isn't the trick for your case just post the exiting ExpressServerRequest and I'll update the example. The version of express.d.ts I checked on Definitely Typed has ExpressServerRequest as an interface.

Categories : Node Js

Drupal modules .info file
You can't create a module that works in both, in the sense that you can't say core = 7.x and core = 6.x. There are too many differences between Drupal 6 and 7 for that to be practical. Unfortunately this means that you'll need to maintain two separate codebases for your Drupal Module. Good luck!

Categories : Drupal

Remove all VBA modules from excel file?
Obviously, you can. The following code will do the job: Sub compact_code() On Error Resume Next Dim Element As Object For Each Element In ActiveWorkbook.VBProject.VBComponents ActiveWorkbook.VBProject.VBComponents.Remove Element Next End Sub This will remove all modules including ClassModules and UserForms but keep all object modules (sheets, workbook).

Categories : Excel

tSQL how to write a view/function which returns a table of dynamic size
if you have to use this output in report. Than you have to fix column name in SQL as below. Group year4 year3 year2 year1 A 1 2 3 2 B 4 3 3 4 C 4 3 1 1 and in report tools you can convert year1 = current year, year2 = current year - 1 and so on. update 2 using this method you can easily design your report. Group year5 year4 year3 year2 year1 A 1 2 3 2 2 B 4 3 3 4 2 C 4 3 1 1 3

Categories : SQL

Configuring AngularJS modules - how does it affect the other modules in the app?
Here is what i think. Like any other angular $httpProvider is also singleton in nature which very well means any changes to it from any where including any module would affect other, or in other words changes are global.

Categories : Angularjs

getting "defined" modules from a CPAN dist file?
The actual code that does it for PAUSE is on GitHub here. The subroutines that parse package and version declarations are in lib/PAUSE/pmfile.pm (packages_per_pmfile and parse_version). This is authoritative as far as what happens to make CPAN work, but it's not code that you'd ever want to use for yourself — PAUSE is almost 20 years old and even after some recent cleanup it's still pretty gross. Instead, look at Module::Metadata. You give it a file, and it provides a pretty simple interface to discover the names of the packages inside of that file and what their versions might be. It's about as simple as: my $mm = Module::Metadata->new_from_file("My/Module.pm"); for my $package ($mm->packages_inside) { print "$package: ", $mm->version($package), " "; } And indeed this

Categories : Perl

How to load Dojo modules defined in the same file
The best way to do this would be to build all your required files into a single file using the dojo build tool. Simply add all the files/modules you need as a single layer in the xml file and build it. In this way you can maintain all required file list in the xml file and run the build tool to create one big js file which you can always include in you desktop app. http://dojotoolkit.org/reference-guide/1.9/build/ Add a layer as such layers : { "all/all":{ include:["dojo/dojo","dojo/i18n","dojo/ready","dojo/domReady"] } }

Categories : Javascript

How to have a config file automatically add 'global' modules for all pages
This is not an obvious thing at all. The Exporter module provides an export_to_level function that can help with this problem. Normally, using Exporter (i.e., making a package a subclass of Exporter) exports symbols into the calling package. The export_to_level method makes it possible to export symbols into a package higher up the stack trace, which is what you want to do here. Here's a proof-of-concept: First some modules with exported functions: # Module1.pm package Module1; use base 'Exporter'; our @EXPORT = ('foo'); sub foo { "FOO" } 1; # Module2.pm package Module2; use base 'Exporter'; our @EXPORT_OK = ('bar'); sub bar { "BAR" } 1; # Module3.pm package Module3; use base 'Exporter'; our @EXPORT_OK = ('baz'); our %EXPORT_TAGS = ('all' => [ 'baz' ]); sub baz { "BAZ" } 1; And ra

Categories : Windows

SyntaxError: Non-ASCII character 'xd1' in file modules/commands.pyc
(As nobody seemed to want the rep, I'll write an answer myself) The method load_source() from the imp-module has been marked obsolete, and even removed completely from the documentation of python 3.X. The solution was to use find_module() and load_module() from the same imp-module instead. After changing to them it started working flawlessly. The obsolete functions seem to be somewhat buggy in that behavior (atleast in python 2.6.6 on Centos 6)

Categories : Python

How to link JS file with modules, controls & templates in dotnetnuke?
If you want to include JS files you should put them into a folder in your module (typically a JS folder) Then in the Codebehind you can use the following syntax ClientResourceManager.RegisterScript(Parent.Page, "~/Resources/Shared/scripts/knockout.js"); ClientResourceManager.RegisterScript(Parent.Page, "~/desktopmodules/DnnChat/scripts/moment.min.js"); ClientResourceManager.RegisterScript(Parent.Page, "~/desktopmodules/DnnChat/scripts/DnnChat.js",150); example from: https://github.com/ChrisHammond/dnnCHAT/blob/master/View.ascx.cs

Categories : Javascript

Validate file extensions and file size on Drupal 7 file field using the form API
It should work actually. We just need to mention file_validate_extensions & file_validate_size under upload_validators. Example: '#upload_validators' => array( 'file_validate_extensions' => array('gif png jpg jpeg'), 'file_validate_size' => array(MAX_FILE_SIZE*1024*1024), ),

Categories : Forms

pgql/Hibernate File up/download - download size twice file size?
It looks like your library for connecting to PostgreSQL does not know how to decode the hex format for bytea. You could try changing your PostgreSQL setting for bytea_output to 'escape'. (If that works, it suggests your library is rather out of date.) I had the same problem with Perl's DBD::Pg, only to discover that I was using a much older version than I thought I was, and after updating it then it automatically did the correct thing regardless of bytea_output setting.

Categories : Hibernate

How to reduce size of .mp3 file in raw folder to reduce size of .apk file in Android?
You have different options. E.g. you can change the quality and kb/s. I agree to WarrenFaith that you should tell us what you mean by "huge". It might also make no sense to reduce the fileize. You might try this tool with low quality: http://www.formatoz.com/

Categories : Android

Python: How to package all necessary modules/Libs into one singleton executable file?
Just combine your files to one file. But it bad way. Select from better solutions: create deb-package with all depends. In next times system will automatically install all libraries, will check correct state and will remove your files. using rsync get actually version from your version control system. I have wrote script for generating deb-package after commit to our version control system.

Categories : Python

Python: modules and packaging - why isn't __init__.py file executed before __main__.py?
Do I have to import these functions into __main__ somehow? Yes. Only items in builtins are available without an import. Something like: from myprog import func1, func2 should do the trick. If you don't have myprog installed in the normal python path then you can work around it with something like: import sys import os path = os.path.dirname(sys.modules[__name__].__file__) path = os.path.join(path, '..') sys.path.insert(0, path) from myprog import function_you_referenced_from_init_file Which, quite frankly, is horrid. I would suggest going with MartijnPieters suggestion and put the -m on the command line, in which case __main__.py can look like: from myprog import function_you_referenced_from_init_file

Categories : Python

Troubleshooting 'File specified in the modules section of this template already exists.' error in Sharepoint
It sounds like you need to set to True the IgnoreIfAlreadyExists attribute in the elements.xml of your feature. <File Path="Style Librarywhatever.png" Type="GhostableInLibrary" IgnoreIfAlreadyExists="true" /> I hope it helps.

Categories : C#

Upgrading to .9, aliasing modules no longer works to the right of = sign when in declaration file
This was fixed in the latest TypeScript release 0.9.1 http://blogs.msdn.com/b/typescript/archive/2013/06/28/announcing-typescript-0-9-0-1.aspx

Categories : Visual Studio 2012

What does it mean to have modules inside other modules in Ruby?
It is essentially namespacing. You could do the same thing with just module Fabrication::Syntax::Make. For whatever reason, nesting them is what most well-known gems/projects do, and for that unknown reason I do too. I would love to get some insight as to why people generally prefer nesting over the more direct method.

Categories : Ruby

How to get the path of this file in nodejs?
var Logger = require('./logger'); Requires the module you have written, in a file called logger.js stored in the same directory your code was launched from.(not necessarily the same directory your code is stored in). var someOtherModule = require('../../someOtherModule'); Requires someOtherModule.js file two directories back from where the node process is launched. var someOtherModule = require('./subDir/someOtherModule'); Requires someOtherModule.js file, sotred in subDir. subDir is a directory located at the level of where the node process was launched. var awssum = require('awssum'); Requires a module installed via NPM, in the node_modules directory from which the process was launched, or any globally installed node modules. For versioning, the node_modules directory takes

Categories : Node Js

Nodejs if file exists from different url
The fs functions look for files on your local filesystem. If you want to see if a remote file exists, you'll have to make an HTTP request using the http module, request module or the like.

Categories : Node Js

How to extract two folder path C: (same Type File: e.g Text Document) and name of the file into text file with the file size in kb
The error you observe is caused by the signature of your procedure ListFiles. In VBScript all variables/parameters are of type Variant, so you must not explicitly specify a type. Change this: Sub ListFiles(f, folderPath As String, fileType As String) into this: Sub ListFiles(f, folderPath, fileType)

Categories : Vbscript

Mocha + Nodejs + Heroku .env file
I'm not entirely sure, but I don't think you can make mocha read your .env file. That appears to be specific to foreman. If your environment variable definitions are plain KEY=VALUE, then I believe something as simple as env $(cat .env) mocha would do. Otherwise, you may have to do some preprocessing first using sed/perl/etc.

Categories : Node Js

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