úterý 3. října 2017

Jak naformátovat usb flash na FAT32

Potřeboval jsem kamarádovi naformátovat 64GB flasku na FAT32. Překvapilo mě, že to není zas tak jednodnoduché spousta způsobů nezabere. A protože se mi kamarád vždycky jednou za rok ozve a já už nevím jak jsem to dělal, tak si to tu napíšu:

Zabralo mi tohle:
Odsud http://www.ridgecrop.demon.co.uk/ stáhnout"FAT 32 Formatter".
Odkaz přímo na download: http://www.ridgecrop.demon.co.uk/download/fat32format.zip
a pak staci spustit:

fat32format.exe -c64 X:

X - je pismeno svazku
Příště to snad už najdu snáz.

středa 30. srpna 2017

Hg - Mercurial how to remove unwanted merge - using backout of backout

Issue
We have branches: "default" and "myB"
Into branch "default" was by mistake merged branch "myB".

Solution
One possible solution to solve this is:
Simple description: We will backout merge in "default" branch. Then we merge this backout into "myB" and then we will do "backout of this backout" in "myB" branch.

Exact way how to do it:

${merge} - revision with unwanted merge
${default_parent} - revision of parent changeset of ${merge} changeset in "default" branch
${myB_parent} - revision of parent changeset of ${merge} changeset in "myB" branch

commands:

hg update ${merge}
hg revert --all -r ${default_parent}
hg commit -m "backout of unwanted merge"   


hg update ${myB_parent}

hg merge tip
hg ci -m "merge backout into branch"

hg revert --all -r ${myB_parent}
hg commit -m "backout of backout"  



This is inspired by: https://www.mercurial-scm.org/pipermail/mercurial/2017-January/050172.html

sobota 25. února 2017

Maven - Jak spustit testy na všech modulech i když některé testy padají.

Maven buildi jednotlive moduly. A ihned jak v některém spadne test, tak build skončí, protože všechny ostatní moduly přeskočí.

  • mvn test
    - Build běží jen k modulu s prvním padajícím testem. A zbytek modulů přeskočí.
  • mvn test --fail-at-end
    - Pokud modul spadne, tak přeskočí jen moduly, které na tomto modulu zavísí.
  • mvn test --fail-never
    - Spouští všechny moduly - žádné nepřeskočí. I když některé popadají.

mvn test

Příklad:

[INFO] Reactor Summary:
[INFO] 
[INFO] smpl ................................................ SUCCESS [  1.166 s]
[INFO] smpl-test ........................................... SUCCESS [  4.077 s]
[INFO] smpl-common ......................................... SUCCESS [ 29.367 s]
[INFO] smpl-data ........................................... SUCCESS [  9.442 s]
[INFO] smpl-persistence .................................... SUCCESS [ 27.131 s]
[INFO] smpl-core ........................................... FAILURE [01:24 min]
[INFO] smpl-icm-persistence ................................ SKIPPED
[INFO] smpl-ips ............................................ SKIPPED
[INFO] smpl-sys-info ....................................... SKIPPED
[INFO] smpl-gmc-cloud ...................................... SKIPPED
[INFO] smpl-workflow ....................................... SKIPPED
[INFO] smpl-cluster ........................................ SKIPPED
[INFO] smpl-engine ......................................... SKIPPED
[INFO] smpl-definitions .................................... SKIPPED
[INFO] smpl-statistics-report-creator ...................... SKIPPED
[INFO] smpl-upgrade ........................................ SKIPPED
[INFO] smpl-monitoring ..................................... SKIPPED
[INFO] smpl-webserver ...................................... SKIPPED
[INFO] smpl-webserver-core ................................. SKIPPED
[INFO] smpl-node ........................................... SKIPPED
[INFO] smpl-icm-package-creator ............................ SKIPPED
[INFO] smpl-doc-exporter ................................... SKIPPED
[INFO] smpl-i18n-converter ................................. SKIPPED
[INFO] smpl-stopper ........................................ SKIPPED
[INFO] smpl-bobril ......................................... SKIPPED
[INFO] smpl-frontend ....................................... SKIPPED
[INFO] smpl-webserver-app .................................. SKIPPED
[INFO] smpl-sample-app ..................................... SKIPPED
[INFO] smpl-installer ...................................... SKIPPED
[INFO] smpl-incubator ...................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:35 min
[INFO] Finished at: 2017-01-19T09:38:42+01:00
[INFO] Final Memory: 54M/1044M
[INFO] ------------------------------------------------------------------------

mvn test --fail-at-end

Příklad:

[INFO] Reactor Summary:
[INFO] 
[INFO] smpl ................................................ SUCCESS [  1.443 s]
[INFO] smpl-test ........................................... SUCCESS [  5.906 s]
[INFO] smpl-common ......................................... SUCCESS [ 32.095 s]
[INFO] smpl-data ........................................... SUCCESS [ 13.179 s]
[INFO] smpl-persistence .................................... SUCCESS [ 28.213 s]
[INFO] smpl-core ........................................... FAILURE [01:27 min]
[INFO] smpl-icm-persistence ................................ SKIPPED
[INFO] smpl-ips ............................................ SKIPPED
[INFO] smpl-sys-info ....................................... SKIPPED
[INFO] smpl-gmc-cloud ...................................... SUCCESS [  1.289 s]
[INFO] smpl-workflow ....................................... SKIPPED
[INFO] smpl-cluster ........................................ SKIPPED
[INFO] smpl-engine ......................................... SKIPPED
[INFO] smpl-definitions .................................... SUCCESS [  0.693 s]
[INFO] smpl-statistics-report-creator ...................... SUCCESS [  1.108 s]
[INFO] smpl-upgrade ........................................ FAILURE [ 18.500 s]
[INFO] smpl-monitoring ..................................... SKIPPED
[INFO] smpl-webserver ...................................... SUCCESS [  0.630 s]
[INFO] smpl-webserver-core ................................. SKIPPED
[INFO] smpl-node ........................................... SKIPPED
[INFO] smpl-icm-package-creator ............................ SUCCESS [  1.222 s]
[INFO] smpl-doc-exporter ................................... SUCCESS [  1.074 s]
[INFO] smpl-i18n-converter ................................. SUCCESS [  1.342 s]
[INFO] smpl-stopper ........................................ SUCCESS [  0.833 s]
[INFO] smpl-bobril ......................................... SUCCESS [ 30.465 s]
[INFO] smpl-frontend ....................................... SUCCESS [01:42 min]
[INFO] smpl-webserver-app .................................. SKIPPED
[INFO] smpl-sample-app ..................................... SUCCESS [ 14.232 s]
[INFO] smpl-installer ...................................... SKIPPED
[INFO] smpl-incubator ...................................... SUCCESS [  0.620 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:42 min
[INFO] Finished at: 2017-01-19T09:27:37+01:00
[INFO] Final Memory: 65M/1149M

mvn test --fail-never

Příklad:

[INFO] Reactor Summary:
[INFO] 
[INFO] smpl ................................................ SUCCESS [  1.272 s]
[INFO] smpl-test ........................................... SUCCESS [  5.089 s]
[INFO] smpl-common ......................................... SUCCESS [ 32.105 s]
[INFO] smpl-data ........................................... SUCCESS [  9.521 s]
[INFO] smpl-persistence .................................... SUCCESS [ 27.626 s]
[INFO] smpl-core ........................................... FAILURE [01:25 min]
[INFO] smpl-icm-persistence ................................ FAILURE [ 10.546 s]
[INFO] smpl-ips ............................................ SUCCESS [ 13.612 s]
[INFO] smpl-sys-info ....................................... SUCCESS [  5.811 s]
[INFO] smpl-gmc-cloud ...................................... SUCCESS [  1.094 s]
[INFO] smpl-workflow ....................................... SUCCESS [ 31.439 s]
[INFO] smpl-cluster ........................................ SUCCESS [ 13.137 s]
[INFO] smpl-engine ......................................... FAILURE [01:31 min]
[INFO] smpl-definitions .................................... SUCCESS [  0.560 s]
[INFO] smpl-statistics-report-creator ...................... SUCCESS [  1.038 s]
[INFO] smpl-upgrade ........................................ FAILURE [ 16.010 s]
[INFO] smpl-monitoring ..................................... FAILURE [ 30.710 s]
[INFO] smpl-webserver ...................................... SUCCESS [  0.580 s]
[INFO] smpl-webserver-core ................................. SUCCESS [ 46.682 s]
[INFO] smpl-node ........................................... FAILURE [  6.602 s]
[INFO] smpl-icm-package-creator ............................ SUCCESS [  1.033 s]
[INFO] smpl-doc-exporter ................................... SUCCESS [  1.010 s]
[INFO] smpl-i18n-converter ................................. SUCCESS [  1.097 s]
[INFO] smpl-stopper ........................................ SUCCESS [  0.570 s]
[INFO] smpl-bobril ......................................... SUCCESS [ 14.878 s]
[INFO] smpl-frontend ....................................... SUCCESS [01:38 min]
[INFO] smpl-webserver-app .................................. SUCCESS [  2.341 s]
[INFO] smpl-sample-app ..................................... SUCCESS [ 13.023 s]
[INFO] smpl-installer ...................................... SUCCESS [ 17.248 s]
[INFO] smpl-incubator ...................................... SUCCESS [  0.557 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:41 min
[INFO] Finished at: 2017-01-19T09:50:06+01:00
[INFO] Final Memory: 77M/1483M
[INFO] ------------------------------------------------------------------------

pondělí 20. února 2017

Jak nadefinovat vlastní MBean ve Springu

Do svého aplikačního contextu přidat

    
    <context:mbean-export/>
(context je tento namespace xmlns:context="http://www.springframework.org/schema/context")

Pak již lze nadefinovat vlastní Mbean. (Příklad je v Kotlinu)

import org.springframework.jmx.export.annotation.ManagedOperation
import org.springframework.jmx.export.annotation.ManagedResource
import org.springframework.stereotype.Component

@Component
@ManagedResource(objectName = "MyApplicationName" + ":name=HelloMBeanWorld")
class HelloMBeanWorld {

    //Its component - you can simply autowire anything
    //@Autowired
    //private MyBean myBean

    @ManagedOperation(description = "My hello world MBean")
    fun getHelloMBeanWorld(): String {
        return "Hello MBean world!!!"
    }

}

A pak stačí spustit aplikaci a přistupovat ke své MBean třeba pomocí JConsole. Spring už pořeší, registrovaní a hlavně taky odregistrování bean a vše. Díky Springu!

Další možnosti jsou krásně popsané v dokumentaci springu: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/jmx.html

pondělí 12. září 2016

Run Groovy Project Without Compilation Using Gradle

Run Groovy Project Without Compilation Using Gradle

To be honest it is automatically compiled by Gradle. All changes made into "buildSrc/src/main/groovy" are automatically compiled during startup.

Key feature of Gradle is how nicely it manages "buildSrc" directory.

Here is sample project https://bitbucket.org/bugs_/samples/src/default/RunGroovyProjectWithoutCompilationUsingGradle/

sobota 30. července 2016

čtvrtek 28. července 2016

Count number bytes in UTF-8 for Java String

https://bitbucket.org/bugs_/utils/src/default/CoreUtils/src/main/java/cz/vondr/coreutils/utf/Utf8LengthUtil.java

  • Problem 1: You have Java String variable. And you need get number of bytes in UTF-8
  • Problem 2: You need split String into multiple Strings, in the way that each of them have exact number of bytes. (expect last part of course :) )

Thanks to stackoverflow.com