středa 23. července 2014

How to overcome tiredness which blocks your training

Hello again :)

I was thinking about publishing short post highlighting one life-hack and I can't come up with anything else than my very recent experience around physical training activities connected to regular working day.

(Before you start reading this post, note that the key point is at the very end.)

Things were easier when I was student and/or working part time. You can adjust your schedule pretty dynamically with respect to your body needs and except examination period there is (generally) pretty much "free time" -- so you can sleep well = regenerate well and you also don't perform too much psychical work at once so you don't feel such "drained".

Almost every single day is the same. After more than 9 hours at work (lunch, commuting included) you feel like used sponge thrown in a thrash can. Literally. Exhausted -- that's the right word.

And there is a training ahead of you. It's always better when you already "signed" your training attendance. It usually happens when you play team sport and you said -- yes I will attend. So you will attend, case closed.

But! What if you have planned just individual training session? Swimming or running. Who will force you to really do it? No one. That's true, no one.

Now you will have to fight yourself. Brace yourself -- excuses are coming!

The problem is that you are tired from work and the best thing you want to do is fall on your bed and sleep.

And this is how it usually ends. You arrive at home, take a snack (or dinner) and you feel tired and go sleep. There are SO MANY BAD things here!! Let me elaborate.

1) It is around 5 or 6 PM now and that's your body's performance peak time. Ideal time for training and you are wasting it.

2) You cook and eat food (maybe not very healthy food) and now you have a food coma, again. This will kill you together with work tiredness.

3) As you fall asleep, without setting up your alarm clock for 20 minutes nap, you will probably woke up in your deep sleeping phase (hello Murphy's law). There will be some kind of interruption, trust me... and now, you feel even worse than before it. 

4) Any training is not possible now and you will waste your time in front of a computer, again.

So, as a conclusion -- I will not go for a training session. Damn!

How to do it better? 

1) If it is possible eat light snack in your work 1 hour before you are leaving. You will be ready for training in sense of food consumption and stomach fullness/emptiness.

2) If you are really tired, take a nap before your training. It works like a charm somewhere around 5 PM. Make sure you set up your alarm clock properly for 20 minutes.

And now THE BIGGEST AND THE MOST IMPORTANT POINT EVER!!!

Visualize and imagine your feeling after your last training when you were exhausted before it. 

How did you feel after that? YES! Full of energy, satisfied, strong again, full of endorphins, positive, unstoppable... now you know this is worth and rewarding enough to take it. Now you have very strong logical argument which should help you fight your laziness/tiredness.

And that's it. When everything seems to play against you, just recall that brilliant feeling you have after training which shouldn't be done, but it was. Fortunately.

Cheers,
Tomas :) 

úterý 22. července 2014

It looks like a ruined day, what now?

Hi readers,
after a while I am finally back and want to quickly share some of my very recent thoughts.

Let's imagine -- it's 2 AM "yesterday" and you are falling asleep, thinking about ruined "tomorrow". You know that you need something around 8 hours of uninterrupted sleep, you know that you will have problems to get up soon, you somehow know that your "tomorrow" will be completely sucks, because you will be late at work, you will spend the whole day there and you will be sleepy as hell.

You are maybe a little bit drunk, you maybe lost a few League of Legends games, it's maybe too hot in your room so you can't sleep, whatever...

Now, you are lying on your bed and thinking about ruined "tomorrow", full of negative emotions, anger, dissatisfaction -- you know that feel, bro ;)

Here is my medicine! It tastes awfully but it works.

1) Set up your alarm clock around 6:30 AM

Am I mad? Maybe. But you will most probably hit end of your REM sleeping phase and this is 100 times better than be "interrupted" somewhere in the middle of your deep sleeping phase. Note that I suppose you lying in a bed at 2 AM (and you add 4,5 hours).

2) Exercise -- NOW!

Am I totally mad? How can you exercise after 4,5 hours of sleep and at 6:30 AM morning? You are asking: "WTF dude?" Shut up, do it... swim, run, joga, whatever works for you.

3) Breakfast

You think you can omit it? Poor you. Eat some rich and complex carbohydrates. You will need it more than anything else today.

4) Do the most unpleasant work immediately

Actually this shouldn't be a big problem now because you are warmed up after your exercise and you had delicious breakfast. What a beautiful day. Sure, you don't want to make it less awesome and that's exactly why you need to complete your work instead of reading emails, handling your calendar etc. This is the most rewarding part of your day and you need to make sure you will do it ASAP.

5) Take a nap 

I fully understand that this is not possible for everyone to take a nap after lunch. If you are lucky and you can take it, do it. Don't be sleepy, go nap. Alarm clock for 20 minutes and that's it. It is always better to have 20-minutes long nap instead of 3 hours of mindless staring at your PC display and doing nothing productive.

Substitution: Take a coffee, 2 cups of green tea, matte...

Extra-powerful-unstoppable man version: drink your green tea just before your nap. Caffeine needs about 20 - 30 minutes in order to start working for your body. That's a time you will be napping. Can you see that trick? :P

6) Enjoy rest of your brilliant day

Let's sum it up. You got up pretty early. You did your exercise. You had a brilliant breakfast. You did a very great portion of your work and you are proud of yourself. You took a nap (coffee) in order to be able to work even more! Now you are enjoying your day.

This time, you will go sleep around 10 PM to help your body catch up again. No more party, no more PC gaming, no more movies. Sleep, sleep, sleep as much as you can. It will pay in the end.

Seeya!

(I wrote this post using DO-IT-NOW-AND-DON'T-BE-PERFECT method)

úterý 18. února 2014

Introducing Infinispan OData server: Remote JSON documents querying

Dear Infinispan community,
We are proud to announce the very first available version of Infinispan OData server.

This brand new standalone HTTP server is based on odata4j framework (its core is running on OData Jersey) and using Infinispan as an underlying JSON document store.

Clients are allowed to use OData standard query language and OData service operations for communication with the server, storing and obtaining requested JSON documents.

Infinispan OData server understands an internal structure of JSON document, and therefore, clients can query the cache and ask for a collection of results in dependence on specified expression operators.



What's Open Data Protocol (OData)?

 

OData frees stored information from current data silos and exposes the data for variety of possible consumers. To achieve that, OData utilizes common web technologies: HTTP, REST, JSON and Atom Publishing Protocol.

From clients' point of view, databases offer usually diverse APIs. OData focuses its effort on a creation of an uniform access pattern for various sources of data, to unlock them and prepare for broad consummation.


The picture is used from OData introduction video on http://www.odata.org/.

Any HTTP client can access the data or there is also plenty of consumers present in OData ecosystem. And we just added another producer into that ecosystem -- Infinispan OData server which exposes JSON documents stored in caches to various number of clients using industrial standard and platform independent way.

More information about OData: http://www.odata.org/


Our challenge: 

 

Generally, NoSQL solutions lack overall portability as they are different one from each other and almost each database of this kind provide an unique interface for accessing stored data.

Infinispan is not an exception and its library mode usage is mainly focused on Java clients. However, Infinispan did a step further to solve this problem by introducing its server modules. A few implementations of an Infinispan Hot Rod client were developed to support a few different programming languages. There is also an Infinispan REST server which provides an HTTP access to key-value store capabilities. The problem is that users are not able to effectively use Infinispan for operating with documents in commonly adopted JSON format.



Sure thing that Infinispan REST server allows users to store data in JSON format. The only problem is that our REST server supports only key-value access approach as it does not understand internal structure of JSON documents. Therefore, when you have for example cars in your cache, you can access them through their unique keys only. One key -- one value, classic.
But in some cases it could be beneficial to be able to access your data using specific filters and possibly obtain even a collection of results meeting specified criteria.


This is the main advantage which Infinispan OData server offers. As you can see in the picture, OData server understands internal structure of JSON documents and (let's talk in pseudo language for a while) you can obtain "all red cars" without any problems.

And that's it!


Interface

 

You might be interested how you can interact with the server. Recently, it is enough to use any HTTP client, REST methodology and follow OData service operations exposed in server metadata document which describes server interface capabilities and is accessible at:

http://localhost:8887/ODataInfinispanEndpoint.svc/$metadata

Putting data into the cache:


HTTP POST request at:
http://localhost:8887/ODataInfinispanEndpoint.svc/odataCache_put?key='person1' 

with JSON document in the body will do the trick. For obtaining the data, you have two options:

Key-value approach:


HTTP GET request at:
http://localhost:8887/ODataInfinispanEndpoint.svc/odataCache_get?key='person1'

Query approach:


HTTP GET request at:
http://localhost:8887/ODataInfinispanEndpoint.svc/odataCache_get?$filter=
name eq 'Morpheus' and lastname eq 'Matrix'

Full interface is introduced in project README file.


Solution

 

We were able to achieve desired functionality using the @FieldBridge from Hibernate search which helps us to add fields from JSON objects into the Apache Lucene Document and get it indexed. All with help of odata4j framework (http://odata4j.org/).

For now, code is located at: https://github.com/tsykora/infinispan-odata-server/ -- please follow README where you can find information about building, dependencies, server interface and practical usage examples.

Infinispan OData server is the main deliverable of the tsykora's diploma thesis -- for further details accessible at: https://is.muni.cz/auth/th/325144/fi_m/ diploma_thesis.pdf file with the text part and tsykora_attachment.zip archive which contains essential libraries and already built server itself (version 1.0). We also benchmarked this new server against already existing Infinispan servers (Hot Rod, Memcached, and mainly REST in 4-node clustered environment) using Infinispan cakery tool which is based on PerfCake framework.

We managed to significantly improve performance of odata4j framework libraries for our needs but there is still much to investigate there. Infinispan OData server project is very young (started in June 2013) and was developed under respective time constraints.

As we have mentioned, this small Infinispan sub-project is in the early stage and we are gathering feedback and feature requests. Feel free to open new issue in GitHub project repository. Now we plan to focus on more performance improvements, code polishing and addition of more cool features, support for more OData operators and embedded JSON documents, lists, number fields etc. 

Stay tuned!

neděle 26. ledna 2014

Happy blogging with do-it-now-and-don't-be-perfect method

Hi all! :)
You are reading this stuff probably because one of my posts was pointing right here. I promise I will keep an introduction of do-it-now-and-don't-be-perfect method very short.

    The method incorporates 2 approaches. Do it now -- when you have an idea just open a Blogger and jot it down very quickly, and immediately. Of course I wanted to do this every time. So why didn't I do it? Because I was striving for a perfection in my former blog posts.

    Perfect grammar (as I'm not a native English speaker), perfect citations, perfect ideas, perfect agenda of the post, perfect structure, perfect conclusion, perfect, perfect, perfect everything.

    My brain started to think about what else do I need to make a perfect post instead of writing it right now. What I need to add, do, solve? I need to re-read it 3-4 times once the post is written to be sure there are no unnecessary mistakes there. I need someone to read it before publishing to make sure there are no completely wrong ideas stated in the post... etc., etc.

    I wanted to have it PERFECT.

    And all those tasks take simply too much time and it's too much effort to deal with them. 

    It works literally like a KILLER of my fresh ideas, fresh experience, or fresh mind stream which MIGHT be worth to share. With a perfectionism I had even no chance to find out whether it was worth or not because I didn't publish almost anything. 

    Now I declare: "FU*K you PERFECTIONISM" -- you will no longer stop my willingness to share any of my ideas.  


úterý 21. ledna 2014

Adjust your sleep: two years of polyphasic experience

Hi all! :)
Today's agenda: to share some of my experience with polyphasic sleep (http://en.wikipedia.org/wiki/Polyphasic_sleep).
     Why? Simply because I can... and I can because of 2 main reasons. 1) I did it. It's finally working for me exactly as I wanted to in its very beginning. 2) I have found a time for posting it, together with a lot of enthusiasm using DO-IT-NOW-AND-DON'T-BE-PERFECT method.

     You've probably heard about strange people who divide their sleep into more segments. Just look at ^ wiki page to find out more about particular patterns. If I understand it correctly (a lot of material, sources, blog posts) the main idea or the principal reason why people do this -- is to spare some time. For example "Everyman pattern with 2 naps" where one spends 4,5 hours in core and 2x20 minutes in 2 power naps. 4:30 + 0:40 = 5:10, 5 hours and 10 minutes of sleep which basically adds 3 extra hours when comparing to someone who slept full 8 hours. That's it. Once you adapt to it and learn to work with those patterns, you should be able to by productive at the same rate (even more) as someone who sleeps 8 hours, and additionally, you should have some extra time for yourself, your work, your family, hobbies... for writing posts like this.

     For writing post like this... really? Actually, this is not my case right now and I will tell you why. After some diploma-thesis burst and caffeine experiments where I totally ruined my regular sleep cycles, here it comes a period of a time when I need to "just and only" study for my final examination. First thing what I did was to completely get rid of a caffeine and focus on jumping back into my polyphasic sleep train.

     In my case, I don't care about a sparing of a time now but rather focus on sleep pattern effectiveness with regards to studying and learning.

     How do I sleep now? The first 4,5 hours core, 2-3 hours of work (studying things, this blog post, anything), the second core (varying) 1,5h to 3h following my body needs and one power nap during the day. So I can basically end up with 4,5+3 = 7:30 + 0:20... approx 7 h 50 min of a sleep per day, let's say 8. So I sleep 8 hours in total which is the same amount as a decent one-phaser.

     So why am I doing this? It's beneficial even only for those 2-3 hours of work phase between 2 core sleeps. This is my super-power-hyper-mega effective working time. This 2to3-very-productive-hours-chunk is usually placed somewhere between 4 and 9 AM, depending on the exact time when I have felt asleep. 

     Today's observation: It helps me to be hungry. Basically "the hunger" feeling is able to wake me naturally after 4,5 hours of a sleep. For me, hungry in the early morning hours means one yoghurt or cottage just before sleep. Sooooo NO a half of a fried duck with dumplings and red cabbage at 10 PM!! (I did that two days ago and it was awesome anyway.)

     Of course, I have slightly opened window jalousie to allow the sun/day light come inside and wake me up naturally. There exists even some special alarm clocks in the market... those are able to simulate sunrise via lightening up a lamp gradually and even add some bird singing. Awesome! :))) Hmmm, formerly, I meant this one as a joke, but such an alarm clock can be very beneficial in a case when a street light is distracting you from core sleep, when you need the most darkest place as possible and you simply need to completely close your jalousie and you need to simulate natural daylight using some technological solution. Ok.

     Next, caffeine-free way -- I just stopped using caffeine. By stopped I mean stopped after one month experience when I was fully working on my diploma thesis and caffeine helped me to broke my sleep pattern in order to be able to program more code, write more technical text, stay focused during late hours, improve my coding performance together with epic music, etc. (Experience during this phase deserve standalone blog post as well -- later)

     I don't want to have literally NONE of above-mentioned things right now. I need to study, my brain has to be in "sleepy" phase to be able to absorb, process and store a bunch of information. Division into 3 phases will help to stay in REM-like phase which, I am strongly convinced about it, is beneficial for learning. (<< source needed here -- later)

    So, now I've spent some around 1 hour writing this post, eating a breakfast, thinking and I will probably be able to study for a next oncoming hour period. After that I will sleep again for next 1,5 or 3 hours. Yeah, every time you need to make sure that you sleep in 1,5 h intervals as REM phases are ending there. I.e. 1,5 h, 3 h, 4,5 h, 6 h, 7,5 h. If you go sleep at 1 AM and have to get up at 6 AM, set your alarm clock at 1+4,5 = 5:30 AM rather than 6 AM. At 6 AM you will probably meet your deep sleep phase and your day will sucks. I am pretty sure you know that feeling ;)

     That's it. Just wanted to share some thoughts, finally. Anyway, that was very nice procrastination as I didn't need to study and my brain is internally satisfied by writing a blog post :D
__________________________
I wrote this post using DO-IT-NOW-AND-DON'T-BE-PERFECT method (I will probably elaborate in next post) which was developed internally by my creative mind to control my perfectionism (fu*k you!) and finally made me able to share my thoughts with others more effectively. Which means that you can find more grammar mistakes, not entirely the best citation norms, you can find just a raw record of my mind stream -- probably nothing for your diploma thesis to base on :D