I have to say that hardest part with react was to figure out testing. (testing components is easy with thousands examples). But how to test props, state vlaues, clicking events, helping functions,… There are many projects in github and almost all of them are without any tests.
I have put together small app, where you can find code with tests.
I have tested:
* props values
* state values
* events on components like clicking,…
Frankly I haven’t seen any project where they would cover all of the above.
I am not gonna write step by step, just small info I am using Jest & Enzyme testing framework.
For details better check my code. Check for package.json for packages I am using and __tests__ folders for tests.
When programming I like to keep my code as clean and automated as possible.
I like sonar (does analysis on your code and provide you output how many duplicate, code smells, unused variables,..)
I like node.js / react.js for its quick prototyping and agile and others advantages. So lastly I was looking if I can have setup where I could automate my infrastructure code -> push to VCS (github) -> CI (travis) -> code analysis (Sonar).
Here are steps what you need to do:
- github.com -> on project settings turn on “travis-ci” integration
- github.com -> project -> settings -> Integration & services -> Add Service -> Travis CI
- travis-ci.com -> make sure after code push code build is triggered
- sonarcloud.io – get started
Make sure you define sonacloud.io organization and token and use it in travis.
Update: I am using git flow and find out that branches “develop” were not sent to sonar. Make sure you add them in .travis.yml as well as in sonar-project.properties files (marked them in bold)
Update2: there is another option using sonarqube-scanner-node project . (I am assuming your project is made by create-react-app by facebook)
yarn add sonarqube-scanner-node --dev
yarn test -- --coverage
- package.json -> add in script section:
- from command line:
yarn sonarqube -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=chowanioksource -Dsonar.sources=src -Dsonar.projectKey=chowanioksource:reactBlog -Dsonar.login=<sonarcloud.io token>
I am getting lots of questions regarding my travel, living, working in central America so here are few answers.
About my trip
I left Europe somewhere in November and head to Florida where I joined sail boat and sailed down to Guatemala. I am traveling on land for couple month around central America (Guatemala, Belize, Mexico, Cuba,..) and slowly returning back to boat to sail more. Right now I am in the middle trip and I need to extend my return tickets to extra 2-3 months (it is still cold in Europe 🙂
Spanish is the language you want to know here 🙂 I didn’t know anything and starting getting into it 🙂 Google translator, your hands are your best friends 🙂
Many people are afraid of security here (I mean those in EU or USA) but I didn’t had or feel of any security issues. Nothing get stolen, I am not being afraid of walking in the night. I have few rules:
- Be nice to local people, they will be nice to you
- Keep general safety rules like:
- don’t walk in the night where is not light
- separate your money and keep them in separate places
- learn by observing – accept their habits and don’t expect your EU or USA standards
- water only from bottle, but don’t be too much paranoid about it
- Be positive ! even if something bad happens 🙂
- Be friendly !
- Be thankful !
- meditate / talk with God as much as you can – there is reason for what is going on in your life 🙂
I like to eat local food. It is part of the culture you are currently in and it taste so good and most of the time it is cheaper. Some people don’t do it and want theirs restaurant’s food. So it depends on your preferences. You can get local food from $1-$2 USD (Mexico – tacos – something like “Doner Kebab” in EU for 0.5$) up to $30USD in restaurants. It is only up to you, your preferences and your budget.
Internet is everywhere but the stability is “shaky”. Best internet so far is in Mexico
- Mexico – wifi 15Mb down / 4Mb up
- Cuba – only wifi 2-3Mb down / 0.5Mb up
- Belize – wifi 5Mb down / 0.5Mb up
- Guatemala – LTE – 15Mb down / 5Mb up, but in peak hours (like evening) it drops to 2Mb / 0.5Mb
This is hard question. I need internet to my work so some places would not be as suitable as others. My current project doesn’t require reliable internet – so I am set well 🙂 Bigger problem is to find discipline and actually work 🙂 Sometimes I take few days off and work from hotel or bar next to beach or sometimes when I travel in bus I use this time to do my work. I take it easy 🙂
People – tourists
Generally there are 2 types of tourists you meet:
- Tourists who come here for few days
- BackPackers who are traveling for few months – (I don’t like much word “backpacker” – it sounds to me like you are something less which is not true but I wanted to distinguish those 2 types of tourists somehow)
ad 1) Tourists – usually throw lots of money around them. They are here for few hours/days and they want the best before they have to return back to work. I understand them – sometimes I want luxury as well 🙂 But for some unknown reason they behave like snobs 🙂 couple examples:
- If you say “Ola” and greet them, usually they don’t even responds
- They treat locals kind of like a slaves – locals are here for them just to clean their rooms, to fulfil their needs (maybe word “slave” is too extreme but you get the idea) ,….
ad 2) BackPackers – Usually travel longer (several weeks, months, years). Very open for discussion and share their experiences and tips they have. Maybe just word “Sharing” describes them very well. They are very open. They don’t have to be cheap and going on low budget even though if you are traveling for few month every dollar you save means you can extend your trip 🙂 For few days you become very good friends.
You are already getting the idea how it works. You can live expensive way or you can live quite low. Really depends on your preferences and your budget. Many people thinks traveling for few months is extremely expensive. If you find place you like you can always try to search for job for month or two and extend your stay 🙂 Anyway here are few numbers to get ideas:
Cuba – seems like most expensive country on my trip:
- bed – 20-35$
- food – breakfast 5$, dinner 15$ – average I was spending 25$
- transport – depends where you go, but in average 30$ if you travel (havana -> vinales -> playa larga -> cienfuegos -> trinidad -> havana)
- diving – (in Playa Larga) – 2 dives 70$
Mexico – bigger variety of prices – are you where tourists go or where locals go
- bed – 20$ hotel, airbnb has similar prices
- food – from 2$ (street food) up to 30$ in restaurants (lobster cca 24$)
- transport – 30$ (Playa de Carmen to Palenque)
- diving – cca 85$ (2 dive tank) + 20$ rental
Belize – I stayed in Caye Caulker island
- bed – from 15$ and up
- food – from 2 $ (street food) up to 20$ (lobster cca 14$ restaurant)
- transport – 25$ ferry, 50$ bus to get to Flores / Guatemala
- diving – 8 dives for cca 500$ (including rentals) – one of the best dives ever
- bed – from 10$ up
- food – from 3$ (street food) and up (15$ chicken in restaurant)
- transport – 18$ (bus Rio Dulce -> Guatemala City)
- no diving 🙂
Picture of “street food” – breakfast for $2.5 USD in Cozumel/Mexico
If you need to run your app on jboss5 and using jdk8 you will get error
3:53:10,693 ERROR [AbstractKernelController] Error installing to Instantiated: name=AttachmentStore state=Described java.lang.IllegalArgumentException: Wrong arguments. new for target java.lang.reflect.Constructor expected=[java.net.URI] actual=[java.io.File] at org.jboss.reflect.plugins.introspection.ReflectionUtils.handleErrors(ReflectionUtils.java:395) at org.jboss.reflect.plugins.introspection.ReflectionUtils.newInstance(ReflectionUtils.java:153) at org.jboss.reflect.plugins.introspection.ReflectConstructorInfoImpl.newInstance(ReflectConstructorInfoImpl.java:106) .....
You need to modify “profile.xml” and add class=”java.io.File” into paramater element
<bean name="AttachmentStore" class="org.jboss.system.server.profileservice.repository.AbstractAttachmentStore"> <constructor> <parameter class="java.io.File"> <inject bean="BootstrapProfileFactory" property="attachmentStoreRoot" /> </parameter> </constructor>
I use *Git* for several years and there are tons of articles out there about how to create new branch, pull, fetch, merge, conflict resolve, etc…
I looked at how we are doing with branches on current project – holds over 1M of code lines and +10 years of its history – I was surprised that we had almost 2 000 branches (features, patches,….). We don’t follow the standard git flow (yeah I know we should, but some in our team thinks that for current project it is better how we do it now). So as you can see there are many branches which needs to be cleaned up and GIT helps a lot with that.
Some Git commands which are useful for cleanup:
Clean of local branches which has been deleted on remote server:
git fetch --prune
list of all branches (local & remote )
git branch --all
List branches which are merged to remote master:
git branch --all --merged origin/master
Result of above command can be deleted
Delete local branch:
git branch -d branch_name
Delete branch from remote “origin” :
git push origin --delete branch_name
Show list of branches which are not merged into remote master branch:
git branch --all --no-merged origin/master
Results from above command are not merged into master. You need to check whether those branches are new feature/patch branches (still in work in progress) or they were not merged because you feature/patch is not needed any more (absolete and can be deleted) or you simply forget to merged them into your master (which should not happen by using tools like “git flow”)
You can scripts to combine of commands together. Let’s say we want to see last commit day and author to find out whether branch is still under development or not.
for branch in `git branch -r --merged origin/master | egrep -v 'HEAD|master'`; do echo -e `git show --format="%ci %cr %an" $branch | head -n 1` \\t$branch; done | sort -r
Similarly you can create scripts, which deletes not used merged branches and many other things you need.
I had opportunity to spend month on Galaxy. Galaxy is 40 foot catamaran. And during my period Galaxy was operating in Bahamas waters – Great Exumas Islands waters. Not many people realize that boats have to be like small cities, providing fresh water as well as generating enough electricity not only to make water, but to power all our toys (gps, noteboks, satelite phone, several iPads, our small cinema and few more ) as well as engines and many other things.
So how is living on Galaxy ? I had my own small cabin where I slept. Literally I was only sleeping there. It was much much nicer to be outside and enjoy water and sun 🙂 In the middle of the boat there is “kitchen, dining room, living room” in one place together 🙂 Boat holds 2 another cabins (for kids and their parents) with 2 bathrooms. Don’t think of big luxury yacht with its own pool 🙂 Galaxy is just perfect size, small enough so you can get everywhere and big enough to cross oceans. Just perfect !!!
In the morning you usually wake up at 6:30am (that’s time when is weather forecast transmitted over radio and you don’t want to miss it ) and usually you go to bed after sunset. It’s said that sailor midnight is at 9pm 🙂 I was so surprised how quickly I have get use to is (of course I had jet lag which works very well with this setup).
There is one thing I have to note. Stars at night. It is so nice, so bright, so perfect, so amazing. Just sitting on deck and watching stars and enjoying your drink. Thinking about your past day, your future plans, your being, meditating with God, just enjoying that moment.
Things to do
Galaxy is perfect, everywhere from sun rise to sunset we had “our own swimming pool” around called ocean. I haven’t seen sea with so great visibility anywhere else. Bahamas has one of nicest waters I have seen. We spent lots of time in water (swimming, fishing, lobstering – diving & catching lobsters or spear fishes) but also lots of fun on the water (we participated in yacht race, snorkelling, explore several lone islands, including one closed research center). Visited several places so nice that several movies have been filmed there (Thunderbolt – James Bond, and others ) When you come from frozen country to almost summer weather you can imagine that I have enjoyed every minute on sun as well in water 🙂 Many people asks me whether I was bored, honestly I didn’t finish things I wanted to go through. I was working preparing few meals, learned and helped to clean boat bottom with hookah and of course diving, work with sails, when we were moving get everything ready (gps, maps, routes,…) get anchor ready for departure and many more things.
I like to travel and work in same time. It is kind of Nomad Lifestyle. But being in Bahamas on the boat, I thought that spending time closed in cabin with computer would be insane. I have pushed myself to go through few tutorials and read few books. So this trip was rather full time vacations.
I mentioned above that usually we would wake early at 6:30pm. Because of jet lag I used to wake up earlier and usually started with doing my own things, reading, meditating and let the rest of crew to sleep. I hate waking up early, but I know how powerful it is specially if you want to be productive that day. So If I would be working that “sailors schedule” would work very much for me.
Internet – we had internet fro time to time. Galaxy is well prepared to receive and transmit internet from long distances, but still you have to have way to “steal” it from somewhere. (by stealing I mean getting closer to some yacht club, laundry office where is internet for free). Internet in marinas is not fast, but good enough. Not for meetings as we moved a lot, but rather tasked where you can work on them alone.
World is so nice and specially Caribbean islands. If you can, visit them ! It was an incredible time spent with family, relaxing, having lots of fun, learning new things and enjoying beautiful weather and nature.
By default your docker can’t reach to internet only to get centOS.
running this command solves the problem:
I had to play little bit with code coverage to fill data to sonar.
Here is simple settings
- download this generated maven repo
- fill sonar properties in pom.xml file
mvn clean compile install sonar:sonar
This creates jacoco.exe file with results in html.
It is always preferred to use https instead of http (specially when using passwords and so on…)
We have switched our SonarQube (tool for Continuous Inspection of code quality) to use https for security reasons. Anyway I have noticed that Jenkins stop sending new quality codes to our sonar. When I have checked the logs I have seen this stacktrace:
Exception in thread "main" java.lang.IllegalStateException: Fail to request server version at org.sonar.runner.Bootstrapper.getServerVersion(Bootstrapper.java:73) at org.sonar.runner.Runner.checkSonarVersion(Runner.java:220) at org.sonar.runner.Runner.execute(Runner.java:150) at org.sonar.runner.Main.execute(Main.java:84) at org.sonar.runner.Main.main(Main.java:56) Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:150) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1584) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:174) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:168) at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:848) at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:106) at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:495) at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:433) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:877) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1089) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1116) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1100) at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:402) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:951) at java.net.URLConnection.getContent(URLConnection.java:682) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getContent(HttpsURLConnectionImpl.java:406) at org.sonar.runner.Bootstrapper.remoteContent(Bootstrapper.java:125) at org.sonar.runner.Bootstrapper.getServerVersion(Bootstrapper.java:71) ... 4 more
So here you can see that Jenkins has problem to “handshake” ssl certificate.
follow these steps:
Add Trusted Keystore
Run “InstallCert.java” on server (where you run your https service). something like java InstallCert localhost:443 -> press “1” when asked. It will add your “localhost” as a trusted keystore, and generate a file named “jssecacerts“.
[user@sonar ~]$ java InstallCert localhost:443 Loading KeyStore /usr/java/jdk1.6.0_37/jre/lib/security/cacerts... Opening connection to localhost:443... Starting SSL handshake.. Server sent 1 certificate(s): 1 Subject CN=Unknown, OU=Unknown, O=Vendavo, L=Unknown, ST=Czech republic, C=CZ Enter certificate to add to trusted keystore or 'q' to quit:  1 Added certificate to keystore 'jssecacerts' using alias 'localhost-1'
I have removed most of the parts but the main parts are here:
a) press 1 when assked – you agree to add certificate for this domain into keystore
b) it created jssecacerts file
Verify Trusted Keystore
Run same command again 🙂 (this is full export – removed hashed data)
[mchowaniok@sonar ~]$ java InstallCert sonar.vmcz.vendavo.com:443 Loading KeyStore jssecacerts... Opening connection to sonar.vmcz.vendavo.com:443... Starting SSL handshake... No errors, certificate is already trusted Server sent 1 certificate(s): 1 Subject CN=Unknown, OU=Unknown, O=Vendavo, L=Unknown, ST=Czech republic, C=CZ Issuer CN=Unknown, OU=Unknown, O=Vendavo, L=Unknown, ST=Czech republic, C=CZ sha1 md5 Enter certificate to add to trusted keystore or 'q' to quit:  q KeyStore not changed
copy jssecacerts file into java/jre/lib/security folder (I had to done it under sudo )
[user@sonar ~]$ sudo cp jssecacerts /usr/java/default/jre/lib/security/
verify it 🙂 in my case, run Jenkins job and verify data are uploaded to Sonar.
After I have lost several years of my pictures I started to use Google Picasa – to get unlimited space you have to agree that your pictures have to have specific pixel size.
Few month back – yahoo, specifically Flickr – changed few “key” settings – specifically size for your pictures – now you get 1TB.
So I was thinking to use Flickr as second backup place and pictures can keep their original size – they don’t need to be shrinked.
What needs to be done:
- have account on Flickr
- change default privacy settings for your account
- change privacy settings for search engines (I want to hide them from search engines)
- now upload your pictures 🙂
- If you got your pictures in Picasa, use picasa2flickr addon and sent your pictures to Flickr directly from Picasa