I'm fairly new to webpack and I'm trying to understand what's the proper way to include my assets folder into the dist folder using webpack (or one of its plugins).
This is the structure of my project:
├── package.json
├── webpack.config.js
├── src
│ ├── index.html
│ ├── app.js
│ ├── components
│ │ ├── ...
│ ├── assets
│ │ ├── factory.png
│ │ ├── factory_white.png
I managed to solve my own issue by reading around about copy-webpack-plugin
Related
I'm trying to use the PocketSphinx speech to text library in my project as a Git submodule. So, I added the submodule to my dependency folder and I added the following code to my MakeFile:
add_subdirectory(dependencies/pocketsphinx)
But, when I'm building the project, I'm getting an error saying that:
[build] /home/aniket/code/restapi/dependencies/pocketsphinx/src/allphone_search.c:43:10: fatal error: pocketsphinx.h: No such file or directory
[build] 43 | #include <pocketsphinx.h>
[build] | ^~~~~~~~~~~~~~~~
[build] compilation terminated.
My guess is that CMAKE cannot find the header files; but, when I build PocketSphinx alone it works fine.
I'm also using the JsonCpp library, which compiles without any problem.
My CMAKE file is:
cmake_minimum_required(VERSION 3.2.0)
project(assistant)
add_executable(${PROJECT_NAME} src/main.cpp)
add_subdirectory(dependencies/jsonpp)
add_subdirectory(dependencies/pocketsphinx)
target_include_directories(${PROJECT_NAME} PUBLIC include PUBLIC
dependencies/jsonpp/include)
target_include_directories(${PROJECT_NAME} PRIVATE include
PRIVATE dependencies/jsonpp/include)
target_link_directories(${PROJECT_NAME} PRIVATE build/lib)
target_link_libraries(${PROJECT_NAME} PRIVATE jsoncpp curl)
Here's my directory structure:
.
├── build
├── dependencies
│ ├── jsonpp
│ │ ├── cmake
│ │ ├── devtools
│ │ ├── doc
│ │ ├── example
│ │ ├── include
│ │ ├── pkg-config
│ │ ├── src
│ │ └── test
│ └── pocketsphinx
│ ├── cython
│ ├── docs
│ ├── doxygen
│ ├── examples
│ ├── gst
│ ├── include
│ ├── model
│ ├── programs
│ ├── src
│ └── test
├── include
└── src
I have a project that has multiple subdirectories and I have a unit testing framework (UnitTest++) in the following folder structure:
root_dir
├── sub_dir1
│ ├── main.cpp
│ ├── some_class.hpp
│ └── test.cpp
├── sub_dir2
│ ├── another_class.hpp
│ ├── main.cpp
│ └── test.cpp
├── UnitTest++
│ ├── libUnitTest++.a
└── makefile
I plan to have more sub_dir# in the future.
How do I use make in the root directory so that it would compile all the subdirectories?
Running go test -v ./... from the root directory misses some tests in the folders of my project.
My file structure is as follows
.
├── cmd
│ └── Myapp
│ ├── config_test.go
│ └── main.go
├── config.yml
├── Myapp
├── go.mod
├── go.sum
├── images
│ └── Dockerfile.dev
├── kubernetes
│ └── deployment.yml
├── LICENSE.md
├── pkg
│ └── AFolder
│ ├── Bookmark.go
│ ├── Bookmark_test.go
│ ├── go.mod
│ ├── go.sum
│ ├── end.go
│ ├── end.go
│ ├── Handler.go
│ ├── Handler_test.go
│ ├── UpdateHandler.go
│ └── UpdateHandler_test.go
├── README.md
├── renovate.json
└── skaffold.yaml
The location is ../go/src/Myapp and the go path is ../go
I can build from the root fine with go build ./... and creates a binary.
But running go test -v ./... will only run the tests in the config_test.go and miss out on the tests in the pkg subfolders.
A problem with the file structure would be my first suspicion. But I am not sure how to go about fixing it. Any advice would be appreciated.
The problem is caused by go.mod file in AFolder folder.
The ./... pattern matches all the packages within the current module. AFolder is not the current module as it has its own go.mod file. In other words, unit test exclude all the subfolders with a go.mod file.
go test all will test all the dependencies. However, this is time consuming and might be unnecessary .
In my project, I just create go.mod file in root folder. For example:
In root folder run go mod init github.com/cyrilzh/myproject
Create sub folder "sub" and create code with package named sub
In the project, reference the sub package like this:
import "github.com/cyrilzh/myproject/sub"
For more information, please refer to
golang wiki: how to define a module
I use conda install OpenCV use:
conda install -c conda-forge opencv
I can use OpenCV with python with no error.
Since conda is a convenience tool to build OpenCV, I am wondering whether I can use OpenCV installed by conda with C++.
And how to use it?
I have opencv.hpp in /home/kandy/miniconda3/include/boost/compute/interop, and here it's what the folder contains:
.
├── eigen
│ └── core.hpp
├── eigen.hpp
├── opencv
│ ├── core.hpp
│ ├── highgui.hpp
│ └── ocl.hpp
├── opencv.hpp
├── opengl
│ ├── acquire.hpp
│ ├── cl_gl_ext.hpp
│ ├── cl_gl.hpp
│ ├── context.hpp
│ ├── gl.hpp
│ ├── opengl_buffer.hpp
│ ├── opengl_renderbuffer.hpp
│ └── opengl_texture.hpp
├── opengl.hpp
├── qt
│ ├── qimage.hpp
│ ├── qpointf.hpp
│ ├── qpoint.hpp
│ ├── qtcore.hpp
│ ├── qtgui.hpp
│ └── qvector.hpp
├── qt.hpp
├── vtk
│ ├── bounds.hpp
│ ├── data_array.hpp
│ ├── matrix4x4.hpp
│ └── points.hpp
└── vtk.hpp
I usually have plain python objects in my Django project that have specific responsabilities like observers, strategy objects, factories, etc. Where should I place those for a more organized file structure? There is a pattern in the industry for that?
There's nothing like an "industry standard" here. Django does have some expectations about django-specific stuff (models, custom template tags and filters, management commands etc) and a couple conventions (the views and urls modules for example - you can technically name them however you want, but everyone expects them to be named "views" and "urls"), but everything else is just plain python code and can be organized however it makes sense to you. The only recommandations here are the obvious ones - high cohesion, low coupling, etc...
I can't comment on how widely this is adopted or if it is the right way, personally I follow the project structure outlined in the Two Scoops of Django book. A similar setup is outlined here https://django-project-skeleton.readthedocs.io/en/latest/structure.html as such:
[projectname]/ <- project root
├── [projectname]/ <- Django root
│ ├── __init__.py
│ ├── settings/
│ │ ├── common.py
│ │ ├── development.py
│ │ ├── i18n.py
│ │ ├── __init__.py
│ │ └── production.py
│ ├── urls.py
│ └── wsgi.py
├── apps/
│ └── __init__.py
├── configs/
│ ├── apache2_vhost.sample
│ └── README
├── doc/
│ ├── Makefile
│ └── source/
│ └── *snap*
├── manage.py
├── README.rst
├── run/
│ ├── media/
│ │ └── README
│ ├── README
│ └── static/
│ └── README
├── static/
│ └── README
└── templates/
├── base.html
├── core
│ └── login.html
└── README
If I want to create objects and functions accessible to all apps I create a utils module at the app level. If I am creating utility functions and objects specific to an app I place the utils module in the app directory. Just personal preference really.
Hope it helps.