How to make protobufjs generated code smaller - protobufjs

protobufjs generated code is too large for front end cases in mobile cases. There is about 300kb while using 3 short proto files.
Bash for generating es6:
pbjs -t static-module -w es6 -o proto.js titan.proto --no-convert --no-delimited --no-comments

Finally I found a tool based on protobufjs Expansion mechanism:https://github.com/mustime/minipbjs

Related

How do I set up configuration variables in Tesseract to better recognize code?

I want to use Tesseract to recognize code. It is said on their website that I can disable dictionaries by setting both of the configuration variables load_system_dawg and load_freq_dawg to false.
However I haven't been able to do it correctly.
$ tesseract img.jpg output.txt --oem 0 -c load_system_dawg=0 load_freq_dawg=0
read_params_file: Can't open load_freq_dawg=0
Error: Tesseract (legacy) engine requested, but components are not present in /usr/share/tesseract-ocr/4.00/tessdata/eng.traineddata!!
Failed loading language 'eng'
Tesseract couldn't load any languages!
Could not initialize tesseract.
Any ideas on best ways to handle it?
First of all, get eng.traineddata with the legacy engine or other OCR engine value (OEM).
Next, read the output of tesseract --help-extra carefully:
-c VAR=VALUE Set value for config variables.
Multiple -c arguments are allowed.

Trying to pass too many includes to QA-C fail

I have a problem to add a source file to my QAC configuration. After many tries, I found out that the problem is with too many includes defined as an argument while calling QAC. If I will reduce the number of includes the QAC configuration will pass.
I tried this over the makefile:
#for f in $(filter-out $(QAC_EXCLUDE_FILES),$(QAC_SRC)); do \
echo " - $$f" 1>&2; \
$(QAC) admin -P $(QAC_DIR) -a -- $(QAC_DEF) $(QAC_D_PROJ) $(QAC_INC) $$f >/dev/null; \
done
I also tried to run a single command to add just one file in Command Prompt:
D:/Tools/PRQA_Framework_2.4.0/common/bin/qacli.exe admin -P D:/Output/qac -a -- -Itoo -Imany -Iincludes D:/Src/import.c
I'm pretty sure that the whole command line is not exceeding the limit 8191 characters (it is something about 5500 characters).
I'm using our common company QAC configuration like many of my colleagues without any problem. In the last few days I just add some new includes.
The result is always the same:
Calling from makefile: /usr/bin/sh: -c: line 3: syntax error:
unexpected end of file
Calling from CMD: CreateProcess error=3, the system cannot find
the path specified
But again, if I will just reduce the includes, everything goes nice and smooth.
Also, I would not say it is a problem of CMD because I'm using the same list of includes for my build process without any problem! It is only a problem for QAC.
My setup is Windows 10, MSYS2 tools.
At the and I contact the QAC support and better way how to provide all information to QAC is to generate list file (one line = line source file) with all defines and includes. This way is also much quicker than passing source files one by one.
So the file list qac_sources.txt (generated by makefile) may look like this:
D:/Project/a1.c -D__far_func= -IToo -Imany -Iincludes
D:/Project/a2.c -D__far_func= -IToo -Imany -Iincludes
D:/Project/a3.c -D__far_func= -IToo -Imany -Iincludes
D:/Project/a4.c -D__far_func= -IToo -Imany -Iincludes
And:
D:/Tools/qacli.exe admin -P D:/Project/Output/qac -F D:/Project/Output/qac/qac_sources.txt
Hope this will help somebody.

How to split frontend and backend translations?

I have a web project (php+js) translated by gettext. Later it was only translated at server side, pushing translations to JS by varying weird ways. Now i converted it to all gettext, convert my .po files by po2json and load them into Jed library. But this way I load all translations, even never used on client !
What i want to do now:
xgettext -js-options *.js > js-empty.po
xgettext -php-options *.php > php-empty.po
magic both-translated.po js-empty.po > js-translated.po
magic both-translated.po php-empty.po > php-translated.po
What should i use as 'magic' ?
P.S. I will be doing actual translation in one file and then split just for optimization, on every build.
I have found the solution:
msgcomm both-translated.po js-empty.po -o js-translated.po
Visual inspection confirms what lines are translated, and the following command confirms what number of 'msgid' is equal in empty and translated files:
grep msgid $1 | wc -l
Adding more value to answer: where's well recommended Python library https://pypi.python.org/pypi/polib, or in main Linux distributions, packages 'python3-polib' or 'python-polib'. I was considering using it to perform the task and maybe will use in future for other gettext-related tasks.

How to use Devel::Cover with prove?

I see there are some similar questions here and on http://www.perlmonks.org but I still do not get it.
Imagine I have a project with a 'lib/' and a 't' directories. I run my tests with 'prove':
$ cd $PROJECT_ROOT
$ prove ./*.t
I want to get a report in html for one or more files in the 'lib/' directory. I do not want reports for the files in the 't' directory.
A simple example should be enough. Thanks
perl Makefile.PL or perl Build.PL
cover -test
The proper way is to always start out with Makefile.PL/Build.PL, just as selected answer suggests. However, sometimes you are not the one who started out, so...
I used to make a fake makefile:
% cat Makefile
test:
prove -Ilib -r t
The following also seems to work (w/o touching ANY files on disk):
cover -t -make 'prove -Ilib -r t; exit $?'
This only works because of how perl's system/exec handle an argument with shell metacharacters in it (; in this case) and may break in the future if cover decides to quote it more rigirously. Also it shouldn't work under windows. I wish cover had a -prove option instead.
This one still generates coverage for *.t as well as CPAN modules at nonstandard locations. This behaviour can be fixed using +select/+ignore options (see the Devel::Cover's manpage):
cover -t +select ^lib +ignore ^
So the tl;dr "magic" command is
cover -t +select ^lib +ignore ^ -make 'prove -Ilib -r t; exit $?'
EDIT The following didn't work for me - it only prints short summary:
PERL5OPT="$PERL5OPT -MDevel::Cover" prove -Ilib -r t
cover -t +select ^lib +ignore ^
Note that prove -MSomething applies Something to prove itself and doesn't pass it on (unlike with -I).
Make prove run every test file with Devel::Cover activated:
$ prove --exec 'perl -MDevel::Cover=-silent,1 -Ilib' t/*.t
By default this will print the statistics after each test file. That’s why I added -silent => 1.
To print the complete statistics at the end add:
$ cover -summary

PVR texturetool build phase

I'm currently completing an iphone 3d programming book
The book says to add following python code into a build phase in xcode, to run the provided texturetool.
Book Quote
a. Leave the shell as /bin/sh.
b. Enter this directly into the script box:
BIN=${PLATFORM_DIR}/../iPhoneOS.platform/Developer/usr/bin
INFILE=${SRCROOT}/Textures/Grid16.png
OUTFILE=${SRCROOT}/Textures/Grid16.pvr
${BIN}/texturetool -m -f PVR -e PVRTC $INFILE -o $OUTFILE
c. Add this to Input Files:
$(SRCROOT)/Textures/Grid16.png
Add this to Output Files:
$(SRCROOT)/Textures/Grid16.pvr
However when doing this I receive the following message.
Failed to load image
Failed to perform Encode
Command /bin/sh failed with exit code 1
Could anyone shed a light on this?
You have spaces in your directories!
Replace $(SRCROOT) with ${SRCROOT}

Categories