Where store Tests (project structure - best practice)? - go

We have many different ways to implement project structure in GO.
My question is where the best way to store tests implementation:
separately (as Java Maven/Gradle standard)
├── pkg
│ ├── colocator
│ │ ├── some_impl.go
│ │ └── ...
│ ├── common
│ │ └── ...
│ └── dashboard
│ └── ...
├── test
│ │ └── internal
│ │ └── some_test_utils.go
│ ├── pkg
│ │ ├── colocator
│ │ │ ├── mocks
│ │ │ │ └── some_mock.go
│ │ │ └── some_impl_test.go
│ │ ├── ...
in place
├── pkg
│ ├── colocator
│ │ ├── mocks
│ │ │ └── some_mock.go
│ │ ├── some_impl.go
│ │ └── some_impl_test.go
etc...
?

Your second implementation is the 'correct' go way. Also you dont have to worry about those tests taking up space or something. The compiler ignores when you build the package.

Related

Is there a way to generate static html pages with Microsoft.AspNet.WebApi.HelpPage?

Currently, thanks to Microsoft.AspNet.WebApi.HelpPage, I'm able to see API help page.
But I need to run (or publish and deploy to IIS) that ASP.NET Web application.
Does Microsoft.AspNet.WebApi.HelpPage provide any functionality to generate static API help html pages?
Not perfect solution, but using wget I was able to go through all help pages and save them all.
Example:
$ wget -r -k -E http://<ip_address>/Help/
$ tree
.
└── <ip_address>
├── Areas
│ └── HelpPage
│ └── HelpPage.css
├── Help
│ ├── Api
│ │ ├── DELETE-api-delivery-Data0-is
│ │ ├── DELETE-api-master-Data1-id
│ │ ├── DELETE-api-master-Data2-id
│ │ ├── DELETE-api-master-Data3-id
│ │ ├── DELETE-api-master-Data4-id
│ │ ├── DELETE-api-master-Data5-id
│ │ ├── GET-api-OtherApi1
│ │ ├── GET-api-OtherApi2
│ │ ├── GET-api-OtherApi3
│ │ └── GET-api-OtherApi4
│ ├── index.html
│ ├── ResourceModel#modelName=Data1
│ ├── ResourceModel#modelName=Data2
│ ├── ResourceModel#modelName=Data3
│ ├── ResourceModel#modelName=Data4
│ └── ResourceModel#modelName=Data5
└── Help.1

xpdf (pdftotext) with language pack call from different directory

I am experimenting with xpdf (pdftotext) on a macOS Terminal. I use one language package (Japanese). Everything works fine if I call the executable like this (from the lib directory):
lib kelly$ ./p2t -enc UTF-8 jp.pdf
and my data structure
files/lib/pdftotext
files/lib/xpdfrc
files/lib/jp.pdf #file to convert
files/options/Enc/jp/ # Here I have the language package files
and the following edited xpdfrc configuration file:
#----- begin Japanese support package (2011-sep-02)
cidToUnicode Adobe-Japan1 ../options/Enc/jp/Adobe-Japan1.cidToUnicode
unicodeMap ISO-2022-JP ../options/Enc/jp/ISO-2022-JP.unicodeMap
unicodeMap EUC-JP ../options/Enc/jp/EUC-JP.unicodeMap
unicodeMap Shift-JIS ../options/Enc/jp/Shift-JIS.unicodeMap
cMapDir Adobe-Japan1 ../options/Enc/jp/CMap
toUnicodeDir ../options/Enc/jp/CMap
#----- end Japanese support package
the problem I have is to call 'pdftoext' from a different directory, for example from 'files'. In this case, the files that the configuration files is pointing to are not seen.
files kelly$ ./lib/p2t -enc UTF-8 ./lib/jp.pdf
I get the following error:
Syntax Error: Unknown character collection 'Adobe-Japan1'
And the generated file is garbage.
Any idea on how the configuration file needs to be changed?
I was able to solve a similar problem.
I installed pdftotext with a brew cask.
The installation was done with the following command
$ brew cask install pdftotext
$ pdftotext -v
pdftotext version 3.03
Copyright 1996-2011 Glyph & Cog, LLC
and place the xpdfrc/language support packages in the following directory I did.
ls /usr/local/etc/xpdfrc
/usr/local/etc/xpdfrc
I downloaded the Japanese Language Pack from here.
https://www.xpdfreader.com/download.html
$ tree /usr/local/share/xpdf
/usr/local/share/xpdf
└── japanese
├── Adobe-Japan1.cidToUnicode
├── CMap
│ ├── 78-EUC-H
│ ├── 78-EUC-V
│ ├── 78-H
│ ├── 78-RKSJ-H
│ ├── 78-RKSJ-V
│ ├── 78-V
│ ├── 78ms-RKSJ-H
│ ├── 78ms-RKSJ-V
│ ├── 83pv-RKSJ-H
│ ├── 90ms-RKSJ-H
│ ├── 90ms-RKSJ-UCS2
│ ├── 90ms-RKSJ-V
│ ├── 90msp-RKSJ-H
│ ├── 90msp-RKSJ-V
│ ├── 90pv-RKSJ-H
│ ├── 90pv-RKSJ-UCS2
│ ├── 90pv-RKSJ-UCS2C
│ ├── 90pv-RKSJ-V
│ ├── Add-H
│ ├── Add-RKSJ-H
│ ├── Add-RKSJ-V
│ ├── Add-V
│ ├── Adobe-Japan1-0
│ ├── Adobe-Japan1-1
│ ├── Adobe-Japan1-2
│ ├── Adobe-Japan1-3
│ ├── Adobe-Japan1-4
│ ├── Adobe-Japan1-5
│ ├── Adobe-Japan1-6
│ ├── Adobe-Japan1-UCS2
│ ├── EUC-H
│ ├── EUC-V
│ ├── Ext-H
│ ├── Ext-RKSJ-H
│ ├── Ext-RKSJ-V
│ ├── Ext-V
│ ├── H
│ ├── Hankaku
│ ├── Hiragana
│ ├── Katakana
│ ├── NWP-H
│ ├── NWP-V
│ ├── RKSJ-H
│ ├── RKSJ-V
│ ├── Roman
│ ├── UniJIS-UCS2-H
│ ├── UniJIS-UCS2-HW-H
│ ├── UniJIS-UCS2-HW-V
│ ├── UniJIS-UCS2-V
│ ├── UniJIS-UTF16-H
│ ├── UniJIS-UTF16-V
│ ├── UniJIS-UTF32-H
│ ├── UniJIS-UTF32-V
│ ├── UniJIS-UTF8-H
│ ├── UniJIS-UTF8-V
│ ├── UniJIS2004-UTF16-H
│ ├── UniJIS2004-UTF16-V
│ ├── UniJIS2004-UTF32-H
│ ├── UniJIS2004-UTF32-V
│ ├── UniJIS2004-UTF8-H
│ ├── UniJIS2004-UTF8-V
│ ├── UniJISPro-UCS2-HW-V
│ ├── UniJISPro-UCS2-V
│ ├── UniJISPro-UTF8-V
│ ├── UniJISX0213-UTF32-H
│ ├── UniJISX0213-UTF32-V
│ ├── UniJISX02132004-UTF32-H
│ ├── UniJISX02132004-UTF32-V
│ ├── V
│ └── WP-Symbol
├── EUC-JP.unicodeMap
├── ISO-2022-JP.unicodeMap
├── README
├── Shift-JIS.unicodeMap
└── add-to-xpdfrc
2 directories, 76 files
The contents of xpdfrc are as follows
$ cat /usr/local/etc/xpdfrc
cidToUnicode Adobe-Japan1 /usr/local/share/xpdf/japanese/Adobe-Japan1.cidToUnicode
unicodeMap ISO-2022-JP /usr/local/share/xpdf/japanese/ISO-2022-JP.unicodeMap
unicodeMap EUC-JP /usr/local/share/xpdf/japanese/EUC-JP.unicodeMap
unicodeMap Shift-JIS /usr/local/share/xpdf/japanese/Shift-JIS.unicodeMap
cMapDir Adobe-Japan1 /usr/local/share/xpdf/japanese/CMap
toUnicodeDir /usr/local/share/xpdf/japanese/CMap

Using environment specific group/host_vars and mapping to var subdirectories in Ansible

I'm having issues finding good documentation for how to use environment specific (i.e. dev & test) group_vars and host_vars, then map down to subdirectories that are specific to large chunks of infrastructure (the wso2 directories).
Ideally, I should be able to say somewhere in my inventory or playbook dev or test and it should just route to dev or test then specify wso2 and have it look there.
.
├── group_vars
│ ├── dev
│ │ └── wso2
│ │ ├── apim-analytics.yml
│ │ ├── apim-is-as-km.yml
│ │ └── apim.yml
│ └── test
│ └── wso2
│ ├── apim-analytics.yml
│ ├── apim-is-as-km.yml
│ └── apim.yml
├── host_vars
│ ├── dev
│ │ └── wso2
│ │ ├── apim-analytics-dashboard_1.yml
│ │ ├── apim-analytics-worker_1.yml
│ │ ├── apim-gateway_1.yml
│ │ ├── apim-is-as-km_1.yml
│ │ ├── apim-km_1.yml
│ │ ├── apim-publisher_1.yml
│ │ ├── apim-store_1.yml
│ │ ├── apim-tm_1.yml
│ │ ├── wso2-apim-01.yml
│ │ └── wso2-apim-02.yml
│ └── test
│ └── wso2
│ ├── apim-analytics-dashboard_1.yml
│ ├── apim-analytics-worker_1.yml
│ ├── apim-gateway_1.yml
│ ├── apim-is-as-km_1.yml
│ ├── apim-km_1.yml
│ ├── apim-publisher_1.yml
│ ├── apim-store_1.yml
│ ├── apim-tm_1.yml
│ ├── wso2-apim-01.yml
│ └── wso2-apim-02.yml
There is great documentation about all other subjects around ansible... just not this, so any help is appreciated.
Thanks all :)

JBoss + Maven: Error building POM

I am trying to launch JBoss application server - my goal is to launch it and deploy some very simple project (I'm trying to do this with "helloworld" from the original quickstarts). The problem is that I have no experience with JBoss or Maven, so I'm having terrible time for a few days and it still isn't working. I presume, that the mistake is in Maven configuration, but I don't know, what I'm supposed to rewrite / replace to repair it.
This is the exact error:
[INFO] Error building POM (may not be this project's POM).
Project ID: org.jboss.component.management:jboss-dependency-management-all
Reason: POM 'org.jboss.component.management:jboss-dependency-management-all' not found in repository: Unable to download the artifact from any repository
org.jboss.component.management:jboss-dependency-management-all:pom:6.0.1-redhat-1
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.jboss.component.management:jboss-dependency-management-all
I was trying to follow instructions given at http://www.jboss.org/quickstarts/eap/#build-and-deploy-th%20e-quickstarts , so my only configuration of Maven was, that I copied settings.xml from quickstart directory to .m2 directory.Finally I tried to build and deploy quickstart by command "mvn clean install jboss-as:deploy", but it caused the error :-(
How to repair this mistake?
P.s.: I use Ubuntu 14.04.
This is how the structure of my folder with JBoss looks like:
.
├── InstallationLog.txt
├── InstallSummary.html
├── jboss-eap-6.2
│ ├── appclient
│ ├── bin
│ ├── bundles
│ ├── docs
│ ├── domain
│ ├── icons
│ ├── JBossEULA.txt
│ ├── jboss-modules.jar
│ ├── LICENSE.txt
│ ├── modules
│ ├── standalone
│ ├── version.txt
│ └── welcome-content
├── jboss-eap-6.2.0.GA-quickstarts
│ ├── bean-validation
│ ├── bmt
│ ├── cdi-alternative
│ ├── cdi-decorator
│ ├── cdi-injection
│ ├── cdi-interceptors
│ ├── cdi-portable-extension
│ ├── cdi-stereotype
│ ├── cdi-veto
│ ├── cluster-ha-singleton
│ ├── cmt
│ ├── configure-postgresql.cli
│ ├── CONTRIBUTING.html
│ ├── CONTRIBUTING.md
│ ├── contributor-settings.xml
│ ├── dist
│ ├── ejb-asynchronous
│ ├── ejb-in-ear
│ ├── ejb-in-war
│ ├── ejb-multi-server
│ ├── ejb-remote
│ ├── ejb-security
│ ├── ejb-security-interceptors
│ ├── ejb-throws-exception
│ ├── ejb-timer
│ ├── forge-from-scratch
│ ├── greeter
│ ├── guide
│ ├── helloworld
│ ├── helloworld-jms
│ ├── helloworld-mbean
│ ├── helloworld-mdb
│ ├── helloworld-osgi
│ ├── helloworld-rs
│ ├── helloworld-singleton
│ ├── helloworld-ws
│ ├── hibernate3
│ ├── hibernate4
│ ├── hornetq-clustering
│ ├── h2-console
│ ├── inter-app
│ ├── jax-rs-client
│ ├── jta-crash-rec
│ ├── jts
│ ├── jts-distributed-crash-rec
│ ├── kitchensink
│ ├── kitchensink-ear
│ ├── kitchensink-jsp
│ ├── kitchensink-ml
│ ├── kitchensink-ml-ear
│ ├── LICENSE.txt
│ ├── logging
│ ├── logging-tools
│ ├── log4j
│ ├── mail
│ ├── numberguess
│ ├── payment-cdi-event
│ ├── picketlink-sts
│ ├── pom.xml
│ ├── README.html
│ ├── README.md
│ ├── RELEASE_PROCEDURE.html
│ ├── RELEASE_PROCEDURE.md
│ ├── remove-postgresql.cli
│ ├── servlet-async
│ ├── servlet-filterlistener
│ ├── servlet-security
│ ├── settings.xml
│ ├── shopping-cart
│ ├── tasks
│ ├── tasks-jsf
│ ├── tasks-rs
│ ├── temperature-converter
│ ├── template
│ ├── wicket-ear
│ ├── wicket-war
│ ├── wsat-simple
│ ├── wsba-coordinator-completion-simple
│ ├── wsba-participant-completion-simple
│ ├── xml-dom4j
│ └── xml-jaxp
└── Uninstaller
└── uninstaller.jar
settings.xml: http://hostcode.sourceforge.net/view/1926
pom.xml: http://hostcode.sourceforge.net/view/1927
Eventually I've solved this - thorough delete of all Maven files ( or files which held some deprecated info about Maven ) and installation of its newest version was the key :-)
This solution is written for Ubuntu 14.04 LTS (but it should work in other versions and even other Debian-based systems too).
STEP-BY-STEP SOLUTION:
1) Completely uninstall Maven
sudo apt-get purge maven
2) Uninstall libaether package
sudo apt-get purge libaether-java
3) Uninstall libplexus packages
sudo apt-get purge libplexus-*
4) Finally, install actual Maven version from the repository
sudo apt-get install maven

Where to find source code of Mozilla NoScript extension?

I read in wiki that NoScript is open source http://en.wikipedia.org/wiki/NoScript, but on official site http://noscript.net/, I can't find any sources. So my question is: where to find sources? Or, is there something I did not understand, and the source code is not available?
The Firefox XPI format does not prevent you from simply extracting the contents of the plugin to examine the source code.
While I cannot find a canonical public repository, it looks like someone has systematically downloaded and extracted all the available XPIs and created a GitHub repository out of them.
https://github.com/avian2/noscript
If you'd like to do it yourself, XPI files are just standard ZIP files, so if you want to extract one yourself you can simply point an extraction program at it.
Here's an example of doing that from the command line:
mkdir noscript_source
cd noscript_source
curl -LO https://addons.mozilla.org/firefox/downloads/file/219550/noscript_security_suite-2.6.6.8-fx+fn+sm.xpi
unzip noscript_security_suite-2.6.6.8-fx+fn+sm.xpi
That yields a directory structure that looks like this:
.
├── GPL.txt
├── META-INF
│ ├── manifest.mf
│ ├── zigbert.rsa
│ └── zigbert.sf
├── NoScript_License.txt
├── chrome
│ └── noscript.jar
├── chrome.manifest
├── components
│ └── noscriptService.js
├── defaults
│ └── preferences
│ └── noscript.js
├── install.rdf
├── mozilla.cfg
└── noscript_security_suite-2.6.6.8-fx+fn+sm.xpi
Then the main code is located inside chrome/noscript.jar. You can extract that to get at the JavaScript that makes up the bulk of the plugin:
cd chrome/
unzip noscript.jar
Which will yield the main source tree:
.
├── content
│ └── noscript
│ ├── ABE.g
│ ├── ABE.js
│ ├── ABELexer.js
│ ├── ABEParser.js
│ ├── ASPIdiocy.js
│ ├── ChannelReplacement.js
│ ├── ClearClickHandler.js
│ ├── ClearClickHandlerLegacy.js
│ ├── Cookie.js
│ ├── DNS.js
│ ├── DOM.js
│ ├── ExternalFilters.js
│ ├── FlashIdiocy.js
│ ├── HTTPS.js
│ ├── Lang.js
│ ├── NoScript_License.txt
│ ├── PlacesPrefs.js
│ ├── Plugins.js
│ ├── Policy.js
│ ├── Profiler.js
│ ├── Removal.js
│ ├── RequestWatchdog.js
│ ├── STS.js
│ ├── ScriptSurrogate.js
│ ├── Strings.js
│ ├── URIValidator.js
│ ├── about.xul
│ ├── antlr.js
│ ├── clearClick.js
│ ├── clearClick.xul
│ ├── frameOptErr.xhtml
│ ├── iaUI.js
│ ├── noscript.js
│ ├── noscript.xbl
│ ├── noscriptBM.js
│ ├── noscriptBMOverlay.xul
│ ├── noscriptOptions.js
│ ├── noscriptOptions.xul
│ ├── noscriptOverlay.js
│ ├── noscriptOverlay.xul
│ ├── options-mobile.xul
│ └── overlay-mobile.xul
├── locale
└── skin
The extension contains the source code - you just need to unzip it. See Giorgio's response here.
The whole source code is publicly available in every each XPI.
You've got it on your hard disk right now, if you're a NoScript user, otheriwise you can download it here.
You can examine and/or modify it by unzipping the XPI and the JAR inside, and "building" it back by rezipping both.
It's been like that for ever, since the very first version.

Resources