w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
MinGW binary 3x as big as MSVC binary
First off, who cares? Have you seen this larger size to impact performance? Second: are you sure you're linking statically with MSVC? Check with Dependency Walker to be sure. Third: yes MinGW GCC compiled binaries are generally larger. This is because MinGW provides a part of the C library to make up for how ridiculously broken msvcr* is compliance-wise. This has never shown as a large difference for me though. Fourth: template and inline handling can differ between the two compilers. Fifth: have you tried to compile the GCC version with -fno-keep-inline-dllexport and/or -Os?

Categories : Visual C++

Compile 64-bit binary with MinGW (Dev-C++)
To build a 64-bit binary on windows you need the 64-bit version of the mingw compiler. Mingw-W64 is one possible distribution you can use. You can find a list of downloads here. Additionally, you can also find Dev-C++ setup bundled with mingw 64-bit compiler under Orwell Dev-C++'s download section. Make sure you choose "TDM-GCC x64 4.7.1" either setup or portable.

Categories : C++

Eclipse MinGW Binary Not Found
Normally you just have to install mingw to c:mingw, then add c:mingwin to Windows´s PATH variable. that´s all. no msys or fiddeling around in eclipse needed In Eclipse just go to File->new->C Project, select Executable->Hello World ANSI C Project, and select MinGw GCC toolchain in right window. That project should build and run from within eclipse without problems If "MinGw GCC" toolchain is not shown in the toolchain selection, just uncheck the checkbox "Show project types and toolchains only if they are supported on the plattform" to make it show up

Categories : C

QtCreator using MinGW cannot find std::shared_pointer
well the right inclusion is #include <memory> and you are supposed to add QMAKE_CXXFLAGS += -std=c++11 in your .pro file to make c++11 work. edit: with compilers older than gcc 4.7 you should use the c++0x value for that flag.

Categories : C++

mingw -- cl is not recognized as an internal or external command -- my mingw in new and environment is true
As I mentioned in the comment to your question, its looking for the Windows compiler, which you probably dont have installed. According to the SCons man page, you can fix this as follows: MinGW The MinGW bin directory must be in your PATH environment variable or the PATH variable under the ENV construction variable for SCons to detect and use the MinGW tools. When running under the native Windows Python interpreter, SCons will prefer the MinGW tools over the Cygwin tools, if they are both installed, regardless of the order of the bin directories in the PATH variable. If you have both MSVC and MinGW installed and you want to use MinGW instead of MSVC, then you must explictly tell SCons to use MinGW by passing tools=['mingw'] to the Environment() function, be

Categories : Python

How to find the closest element to a given binary key value using binary search algorithm?
In case you define the closest as the distance between two vectors. here is the pesudo code to to find the vector that is closest. Vector closestVector = null; Vector findClosestVector(L,q) { int i= L.lenght/2; if(i ==1 ) { Vector v = L.get(0); int distance = distance(v,q); if(closestVector == null) { closestVector = v; } else { int d1 = distance(closestVector,q); if(d1 > distance) { closestVector = v; return v; } } } else { Vector left = findClosestVector(L(0,L/2),q); Vector right = findClosestVector(L(L/2,L),q); if(distance(left,q) >

Categories : Java

Cannot get Cython to find the MinGW gcc compiler even after editing PATH, making a file in distutils, removing all instances of -mno-cygwin
You are using exactly the same operational system and versions than me. Try to cal gcc using: SET input=intput.c SET output=output.pyd gcc -shared -IC:Python27include -LC:Python27libs -O2 -o %output% %input% -lpython27 Usually I put this call in a cythongcc.bat file, in a directory recognized by the PATH environment variable as: gcc -shared -IC:Python27include -LC:Python27libs -O3 -mtune=native -o %1.pyd %2.c -lpython27 So that I can , from where my cython .pyx files are, just do: cython input.pyx cythongcc input input To get the compiled .pyd working!

Categories : Python

PHP Simple HTML DOM Parser find top LI elements
In Jquery you can simply use this selector : ul > li Update:- Using Simple DOM:- <ul class="listitems"> <li><a></a> <ul> <li></li> <li></li> </ul> </li> <li> ... </li> </ul> Simple HTML Dom code to get just the first level li items: $html = file_get_html( $url ); $first_level_items = $html->find( '.listitems', 0)->children(); foreach ( $first_level_items as $item ) { ... do stuff ... }

Categories : PHP

ANTLR4: Error when I try to find which parser subrule matched
The context object for d1 (parse tree node of type DateContext) can be referenced with $d1.ctx. This is equivalent to what you were assuming $d1 alone would do.

Categories : Ant

Use simple dom parser to find an element by a specific attribute?
Are you lazy enough to read the Manual Look that Magic attributes section // Example $html = str_get_html("<div>foo <b>bar</b></div>"); $e = $html->find("div", 0); echo $e->tag; // Returns: " div" echo $e->outertext; // Returns: " <div>foo <b>bar</b></div>" echo $e->innertext; // Returns: " foo <b>bar</b>" echo $e->plaintext; // Returns: " foo bar" So in your code, you can use echo $element->outertext; Change your code to <?php if ( $table = $html->find( "table" ) ) { foreach( $table as $element ) { echo $element->outertext.PHP_EOL; } } ?>

Categories : PHP

NodeJS gives Cannot find module './parser' error while running Handlebars
For simplicity reasons: Just download all the necessary packages on a PC with internet access (so actually just run npm install in the handlebars folder) and then just copy the folder with all the modules

Categories : Javascript

Java source code parser: Need to find access modifiers of declared field variables
With the help of the following code, the modifier can be retrieved: public boolean visit(VariableDeclarationFragment node) { SimpleName name = node.getName(); System.out.println("Declaration of '"+name+"' at line"+cu.getLineNumber(name.getStartPosition())); int modifiers = 0; if (node.getParent() instanceof FieldDeclaration){ modifiers = ((FieldDeclaration)node.getParent()).getModifiers(); } else if (node.getParent() instanceof VariableDeclarationStatement){ modifiers = ((VariableDeclarationStatement)node.getParent()).getModifiers(); } return false; }

Categories : Java

my xml parser(SAX parser) parses only URI source. How can I parse a file which exists in my project with SAXparser?
the json code which is going to be parsed must be in the layout/res/Raw folder. and this is the code to open the resource. db = parse(getResources().openRawResource(R.raw.database));

Categories : Android

difference between Source code parser and Grammar parser
The phrase "source code parser" by itself is clear enough: this is a mechanism that parses source text, using either a parser-generator engine based off of a formal grammar or some kind of hand-coded (typically recursive descent) parser derived from the grammar informally. It is unclear what the result of a "source code parser" is from just the phrase; it might just be "yes, that's valid syntax", more usually "produces a parse or abstract syntax tree", or it might be (sloppily) "full abstract syntax tree plus symbol table plus control and dataflow analyses". The phrase "grammar parser" is not one I encounter much (and I work a lot in this field). It is likely something garbled from some other source. In the absence of a widely known definition, one would guess that this means a) a "

Categories : Misc

How to find the length of the binary file
Use x <- scan("a.bin", raw()) to read the entire file into a raw vector, then use y <- readBin(x, integer(), n=length(x), size=2) to convert the raw vector. Each element in a raw vector is 4 bytes, so you may need to do some conversion to calculate the correct value for n.

Categories : R

SQL - Find the binary representation from the place of '1's
You can use binary and and string concatenation: select (case when test&4 > 0 then '1' else '0' end) + (case when test&2 > 0 then '1' else '0' end) + (case when test&1 > 0 then '1' else '0' end) from (select 6 as test) t; If you are allergic to case statements, you could do this: select CHAR(ascii(0) + (test&4)/4) + CHAR(ascii(0) + (test&2)/2) + CHAR(ascii(0) + (test&1)/1) from (select 6 as test) t

Categories : SQL

Could not find default Chrome binary
The WebDriver part is fine, but I found that the problem is that the code can't find Chrome.exe itself. It should be installed in this folder: C:Users\%USERNAME%AppDataLocalGoogleChromeApplicationchrome.exe Please check this on Requirements: http://code.google.com/p/selenium/wiki/ChromeDriver P.s: I tested myself and it works now. :)

Categories : C#

Find out (in C++) if binary number is prefix of another
You can use your favorite "fast" method to find the highest set bit. Let's call the function msb(). bool is_prefix (int a, int b, int *c) { if (a == 0 || b == 0 || c == 0) return false; int d = msb(b) - msb(a); if (d < 0) return false; if ((b >> d) == a) { *c = b ^ (a << d); return true; } return false; } Shift b so its high order bit aligns with a, and compare that with a. If they are equal, then a is a "prefix" of b. This algorithm's performance depends on the performance of msb(). If it is constant, then this algorithm is constant. If msb() is expensive, then the "easy approach" may be the fastest approach.

Categories : C++

Find out HDD usage of binary data in a field
You can not avoid loading all the data into memory. MongoDB treats a document as its atomic unit, and by querying all documents, it will pull in all documents into memory. As an alternative, what might possibly help you is just to see how many bytes a collection takes up, but that of course only works if the only thing you have stored in your collection are images. On the shell, you can do this with: db.files.stats() Which has the field storageSize that shows you how much storage is needed for your images approximately. This is not nearly as accurate as going through all your images though.

Categories : Mongodb

to find out if a binary tree is balanced or not efficiently
You are traversing the left and right subtrees twice: once to get their height and again to test whether they are balanced. You can eliminate half the work by using a structure that contains both the height and a balanced flag, passing one structure down to be filled in by the left subtree and another by the right. You can then improve on this even more by using the information from the left subtree when scanning the right (or vice versa). The left subtree information can be used (with appropriate bookkeeping1) to cut off the right subtree search early in many cases where the overall tree is unbalanced but each subtree is balanced. 1 bookkeeping details are left as an exercise for the reader

Categories : Performance

How to find all possible subtrees of a binary tree in Haskell?
You can use recursion pretty easily to solve this problem. Probably easier than you could using loops. allSubTrees :: BinaryT a -> [BinaryT a] allSubTrees Empty = [] allSubTrees (Node Empty n Empty) = [] allSubTrees (Node Empty n right) = right : allSubTrees right allSubTrees (Node left n Empty) = left : allSubTrees left allSubTrees (Node left n right) = left : right : leftSubs ++ rightSubs where leftSubs = allSubTrees left rightSubs = allSubTrees right

Categories : Haskell

Can't find binary after compile of Ada (GNATBench 2013) within Eclipse 3.7
You can specify the location of your executable in the project file hello1.gpr, like this: project Hello1 is -- ... for Exec_Dir use "bin"; -- ... end Hello1; Relative paths get resolved from the directory that contains the project file. The directory has to exist! If Exec_Dir isn't set, it defaults to Object_Dir, which can be set in the same way. Object_Dir defaults to the directory where the project file is located, so if none of these two directories is specified, you should find your binary in C:Eclipse32workspace-adahello1 As GNATBench just calls gnatmake for compilation, this problem isn't GNATBench-specific. You can read about the project file format in detail here. It might be that GNATBench provides a visual editor for the project file like the GNAT Programming Stu

Categories : Eclipse

C++ Binary Search to find the index of fixed point
I think you just have your comparison operator around the wrong way: size_t find_fixed_point(const vector<int>& list) { auto lower = list.begin(); auto upper = list.end() - 1; while (lower < upper) { auto mid = lower + (upper-lower)/2; if ( *mid >= (mid - list.begin()) ) { // keep searching on left side upper = mid; } else { // keep searching on right side lower = mid + 1; } } return lower - list.begin(); }

Categories : C++

How to find vertical sum of binary tree using doubly linklist?
This begs the question, "homework?" node { sum = 0; node *next=NULL; node *prev=NULL; } allocate node root_node dfs(root,root_node){ root_node.sum++ if (leftchild) // check whether the child exists in tree if (!left_node) // check for left child in linked list allocate node left_node dfs(leftchild,left_node) if (rightchild) // check whether the child exists in tree if (!right_node) // check for right child in linked list allocate node right_node dfs(rightchild,right_node) } PS: I refrain from answering the problem in full(i.e. with example) because I think with high possibility this is a homework problem.

Categories : List

Generating Spirit parser expressions dynamically ( at runtime ) from a list of permutated parser expressions
Protecting the answer-worthy comment by @cv_and_he from future over-zealous mods (as a community-wiki, because this is beyond my understanding): #define BOOST_SPIRIT_USE_PHOENIX_V3 #include <iostream> #include <iomanip> #include <memory> #include <boost/spirit/include/qi_core.hpp> #include <boost/spirit/include/qi_nonterminal.hpp> #include <boost/spirit/include/phoenix_operator.hpp> namespace qi = boost::spirit::qi; namespace ph = boost::phoenix; namespace ascii = boost::spirit::ascii; typedef qi::rule<std::string::const_iterator,ascii::space_type> mrule_t; typedef qi::rule<std::string::const_iterator,std::string() > wrule_t; struct TStruct { mrule_t rule_; template<typename T, typename R> TStruct( T& rVar,co

Categories : C++

How to find height of binary tree if i have total number of nodes
If you have a balanced tree, then the height (number of levels) is ceiling(lg (n+1)) where ceiling always rounds up to the next highest integer, and lg is base-2 logarithm. If you have certain types of self-balancing trees (which are not always completely balanced, but highly balanced) then it is also possible to give informative bounds on the height of the tree. If you just assume an arbitrary binary tree (say, where every internal node has two children) then the height could be as much as (n-1)/2, for example if you have a tree that looks like a comb.

Categories : Algorithm

OpenCV how to find a list of connected components in a binary image
You need to cv::floodFill the contours returned by cv::findCountours. See this example for findContours, and this one for floodFill

Categories : C++

efficiently find bit positions in binary strings in a numpy array
One good solution would be to split the input into smallish chunks and use that in a memoized lookup table (where you compute the first time through). E.g., if each number/array is 128 bits; break it into eight 16-bits parts that are looked up in a table. At worst, the lookup table needs 216 ~ 65536 entries - but if zeros are very sparse (e.g., at most two zeros in any group of 8 bits only need about ~64). Depending on how sparse you can beef up the size of the chunk.

Categories : Python

How to find aspect ratio of all the characters in a binary word using MATLAB?
Use bwlabel and regionprops to get the 'BoundingBox' property for each connected component. Then you can get the aspect ratio by dividing the width and the height of the bounding-box (last 2 entries of the 4-vector describing each bounding box). Best of luck...

Categories : Matlab

Python - Find K max values in each row of one matrix and compare to binary matrix
When you take the argsort you get it from minimum 0 to maximum 3, so you can reverse it doing [::-1] to get for maximum 0 and for the minimum 3: s = np.argsort(a, axis=1)[:,::-1] #array([[0, 2, 3, 1], # [0, 2, 3, 1], # [2, 1, 3, 0], # [3, 1, 0, 2]]) Now you can use np.take to get the 0s where the maximums are and 1s where the second-maximums are: s2 = s + (np.arange(s.shape[0])*s.shape[1])[:,None] s = np.take(s.flatten(),s2) #array([[0, 3, 1, 2], # [0, 3, 1, 2], # [3, 1, 0, 2], # [2, 1, 3, 0]]) In b, the 0 values should be replaced by a np.nan so that 0==np.nan gives False: b = np.float_(b) b[b==0] = np.nan #array([[ 1., nan, nan, 1.], # [ 1., nan, 1., 1.], # [ 1., 1., 1., nan], # [ 1., nan, nan, 1.]])

Categories : Python

When making binary masks for working and isolating bits and bytes, what's the fastest way to convert from Binary to Hex?
Each set of four bits corresponds to one hex 'digit'. Learn those, then just start converting blocks of four from right to left. (If you're converting a bit string that's not a multiple of four bits, then just add zeros to the left end until it is for the last conversion.) 0000 : 0x0 0001 : 0x1 0010 : 0x2 0011 : 0x3 0100 : 0x4 0101 : 0x5 0110 : 0x6 0111 : 0x7 1000 : 0x8 1001 : 0x9 1010 : 0xA 1011 : 0xB 1100 : 0xC 1101 : 0xD 1110 : 0xE 1111 : 0xF

Categories : C

Implementing a binary insertion sort using binary search in Java
How an insertion sort works is, it creates a new empty array B and, for each element in the unsorted array A, it binary searches into the section of B that has been built so far (From left to right), shifts all elements to the right of the location in B it choose one right and inserts the element in. So you are building up an at-all-times sorted array in B until it is the full size of B and contains everything in A. Two things: One, the binary search should be able to take an int startOfArray and an int endOfArray, and it will only binary search between those two points. This allows you to make it consider only the part of array B that is actually the sorted array. Two, before inserting, you must move all elements one to the right before inserting into the gap you've made.

Categories : Java

How to find sub string of a binary string in java
Iterate over the characters and count the number of one's. If the counter reaches the desired number, stop iterating and take the substring from index zero to where you got. String str = "010101001010"; int count = 0; int k = 2; int i = 0; for (; i < str.length() && count < k; ++i) { if (str.charAt(i) == '1') count++; }

Categories : Java

To find if a tree is a binary search tree or not
No this method is wrong because it would return a true answer for this tree: 6 / 4 9 / 2 10 Although it is not a binary search tree! I would suggest a better approach would be to take the inorder traversal and verify if it is actually sorted.

Categories : C

xor 2 binary strings and give result in binary using java
It sounds to me like homework or an assignment, so I'll offer guidance rather than code: Create an empty StringBuilder Iterate through these strings using a for loop with an index i Use charAt(i) to grab the character at position i If both characters are the equivalent at that position, append 0 to the string builder, otherwise append 1 to it When you're done iterating, return that string builder

Categories : Java

Qt5, cmake and MinGW
This CMakeLists.txt file works properly: project(Qt5_cmake_test) cmake_minimum_required(VERSION 2.8.11) set(CMAKE_PREFIX_PATH "C:/Qt/Qt5.1.1/5.1.1/mingw48_32") # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) # Find the Qt libraries find_package(Qt5Core REQUIRED) find_package(Qt5Widgets REQUIRED) # Add the source files from the current directory aux_source_directory(. SRC_LIST) # Tell CMake to create the executable add_executable(${PROJECT_NAME} WIN32 ${SRC_LIST}) # Use Qt5 modules target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::WinMain) The changes are: Added find_package(Qt5Core REQUIRED). Added Qt5::WinMain to target_link_libraries.

Categories : Qt

How to use __uuidof in MINGW?
__uuidof is an MS specific extension, but you should be able to replace __uuidof(IMyInterface) with IID_IMyInterface for the same behavior in a portable way.

Categories : C++

GMP with MinGW on Windows
The -l options are used to add libraries to your program. Note that order is important! You should always list libraries after all your objects. Try gcc -m32 main.c -lgmp

Categories : C

QtCreator and MinGW GCC 4.8.1
Qt Creator can be installed without any other Qt components. Just download from here. Just use CMake to handle your build and you've got yourself an IDE. Make sure to point you Qt Creator to your toolchain.

Categories : C++

Qt4 or Qt5 (mingw) and openCV 2.4.6
I managed to configure a Qt Creator project with OpenCV to run a simple OpenCV application I wrote recently, named cvDisplacementMapFilter. I tested it with OpenCV 2.4.7 on Mac OS X 10.7.5 and OpenCV 2.4.2 on Windows 7. I believe the following .pro file can help you: SOURCES += main.cpp # On my system I have to specify g++ as compiler else it will use clang++ by default QMAKE_CXX=g++ QMAKE_CC=gcc ## OpenCV settings for Unix/Linux unix:!mac { message("* Using settings for Unix/Linux.") INCLUDEPATH += /usr/local/include/opencv LIBS += -L/usr/local/lib/ -lopencv_core -lopencv_highgui -lopencv_imgproc } ## OpenCV settings for Mac OS X macx { message("* Using settings for Mac OS X.") INCLUDEPATH += /usr/local/include/opencv LIBS +=

Categories : Qt



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