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: