<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1611368930203661681</id><updated>2026-10-19T09:25:13.558+02:00</updated><category term="google app engine"/><category term="android"/><category term="git"/><category term="tomcat"/><category term="eclipse"/><category term="github"/><category term="java"/><category term="jenkins"/><category term="maven"/><category term="raspberry pi"/><category term="hudson"/><category term="lambda expressions"/><category term="linux"/><category term="othello legends"/><category term="profiling"/><category term="rankington"/><category term="rest"/><category term="security"/><category term="weather station"/><category term="DS18B20"/><category term="adb"/><category term="algorithms"/><category term="android outofmemory"/><category term="apache"/><category term="backups"/><category term="blender"/><category term="camera tracking"/><category term="checkstyle"/><category term="closures"/><category term="cobertura"/><category term="couchdb"/><category term="distortion pedal"/><category term="diy"/><category term="dns"/><category term="dropbox"/><category term="dynamic programming"/><category term="eclipse memory analyzer"/><category term="electronics"/><category term="fiddler"/><category term="findbugs"/><category term="functional programming"/><category term="fuzz pedal"/><category term="gitbash"/><category term="google apps"/><category term="ios"/><category term="iphone"/><category term="java 8"/><category term="knockout.js"/><category term="linux mint"/><category term="netflix"/><category term="oauth"/><category term="odersky"/><category term="photo collage"/><category term="pom"/><category term="proxy"/><category term="reverse proxy"/><category term="rsync"/><category term="scala"/><category term="spring"/><category term="sql injection"/><category term="ssh"/><category term="temperature"/><category term="twitter"/><category term="twitter4j"/><category term="uva online judge"/><category term="virtual host"/><category term="windows"/><title type='text'>MacGyver Development</title><subtitle type='html'>This is my tech diary. I try to write about my hobby projects to remember what I&#39;ve done for reference and for fun. Hopefully techy people with similar interests can benefit as well.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>38</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-885805778397596234</id><published>2015-01-07T10:48:00.000+01:00</published><updated>2015-01-07T10:48:12.597+01:00</updated><title type='text'>Solve the party planning problem and earn $1 000 000 USD</title><content type='html'>The party planning problem deals with a village of 200 people where two villagers either are friends or dislike each other. A big party is to be planned and your task is to find the largest set of people in the village to be invited to the party fulfilling the condition that all the invited people must be friends with each other.&lt;br /&gt;
&lt;br /&gt;
This seems like an ordinary puzzle that could take some hours to figure out. However, after giving it some thought, it turns out to be a quite hard problem. In fact it is a version of a well known problem called the “Clique problem”. It is the mother of hard problems and is intricately connected to other hard problems such as prime factorization, the knapsack problem and the travelling salesman. This problem is so hard that the &lt;a href=&quot;http://www.claymath.org/millennium-problems/millennium-prize-problems&quot;&gt;Clay Mathematics Institute &lt;/a&gt;has offered a prize of $1 000 000 to anyone who can show that this or similar problems in the same class of problems can be solved in a practical way. Likewise, you win the money for showing that it is impossible to solve these problems without spending an amount of time in comparison to the age of the universe.&lt;br /&gt;
&lt;br /&gt;
Before going into the fascinating details of this problem we should start with discussing what easy and hard problem really are from a computational standpoint. Consider the problem of solving the multiplication of 17 x 13. If you can’t solve this directly in your head you know a method from school on how to multiplicate the digits individually to come to the conclusion that the product is 221. If feels like an easy problem. Consider the reverse, what numbers should you multiply to get 221? This is harder, we probably have to test a lot of numbers to see if they divide 221 without a remainder to finally find that 17 and 13 are the factors of 221.&lt;br /&gt;
&lt;br /&gt;
Now consider the same problem but with the numbers 37975227936943673922808872755445627854565536638199 × 40094690950920881030683735292761468389214899724061. If you’re not Rainman you will probably not do the multiplication in your head but you could do it with a pen and paper and some spare time. A computer would calculate the product in a split second. What about the reverse? Finding what two numbers to multiply to receive the product 1522605027922533360535618378132637429718068114961380688657908494580122963258952897654000350692006139 turns out to be extremely hard even with the help of a computer. It is so hard that this is the cornerstone of communication security on the Internet (RSA cryptography).&lt;br /&gt;
&lt;br /&gt;
What is the actual difference? For these kind of problems we have methods also known as algorithms which acts as recipes on how to produce a solution to a specific kind of problem. In the case of multiplication we know from school that we should write the numbers above each other and multiply each digit with all the digits in the other number. The total number of simple operations will in this case be n&lt;sup&gt;2&lt;/sup&gt; if the numbers have n digits. This is a common way to denote how hard a problem is to solve. If the problem has an input of size n, in this case the number of digits in the numbers to multiply, the solution will require us to perform a number of simple operations proportional to some function of n, in this case n&lt;sup&gt;2&lt;/sup&gt;. If you remember from school, a polynomial is a function where the variable is raised to different powers such as n&lt;sup&gt;1&lt;/sup&gt; + n&lt;sup&gt;2&lt;/sup&gt; + n&lt;sup&gt;3&lt;/sup&gt; + … n&lt;sup&gt;x&lt;/sup&gt;. So the complexity of the multiplication problem which is n&lt;sup&gt;2&lt;/sup&gt; is a polynomial.&lt;br /&gt;
&lt;br /&gt;
A problem which can be solved with an algorithm that performs something proportional to a polynomial number of operations in relation to the size of the input is considered an easy problem. There is in fact a name for these kind of problems. They belong to the class P of problems where P means that they can be solved in polynomial time.&lt;br /&gt;
&lt;br /&gt;
Now let’s consider the reverse of our math problem where we tried to find the factors of the product. In this case, since we must test numbers smaller than the product for divisibility, the number of simple operations needed in this naive algorithm will grow exponentially with the number of digits in the product. For example, to find the factors of 221 we have to try whether it is divisible by 2, 3, 4, 5 … and so on. A number of one more digit like 5671 would require 10 times as many tries.&lt;br /&gt;
&lt;br /&gt;
Problems like this where the number of operations needed to find the solution grows exponentially with the size of the input are considered hard. An interesting thing about this hard problem is that if you in some way find a solution (the factors of the number), it is an easy thing to verify that the solution is correct. You would simply multiply the factors and see whether they really produce the product. More formally, the task to verify the solution is in the class P of problems.&lt;br /&gt;
&lt;br /&gt;
Now we’re closing in on the $1 000 000 problem. All these problems, which seems very hard to solve, but once you have a solution it is straight forward to verify that the solution is correct, are called NP problems (nondeterministic polynomial time). This means that we don’t really know the complexity to solve them, but a solution can be verified with an algorithm that belongs to class P (an easy task). To win the money you must show that either P = NP or P ≠ NP. That means, either you must prove that you can solve an NP problem in a fast way or show that this is impossible and there can’t exist any algorithm however smart it is that can solve these problems in a fast way.&lt;br /&gt;
&lt;br /&gt;
Do you see the connection with the party planner problem? It is hard to find a group of people which all are friends among all the presumably invited persons. But once you have found this group, it is easy to verify that all these persons really are friends.&lt;br /&gt;
&lt;br /&gt;
Another way to state this is that all these problems are some sort of search problems. You try to search for factors of number, a subset of party people or for all the other NP problems there are similar searches needed. The thing you win the money for is to determine whether you can solve these type of search problems without actually need to search out all the possibilities in a brute force manner which often means an exponential number of operations to test all combinations.&lt;br /&gt;
&lt;br /&gt;
Let’s take a closer look at the party planning problem, or as we will call it from now, the Clique problem. We simplify our example and assume that there are seven people in the village and they can be represented as a graph. Each villager is a node in the graph and paths between two nodes indicates that the corresponding villagers are friends with eachother. The problem now is to find the largest subgraph where each node is connected to all other nodes in the subgraph. Such a subgraph is called a clique.&lt;br /&gt;
&lt;br /&gt;
The naive algorithm would try all combinations to verify whether there is a clique of size 1, 2, 3 and so on until no such clique can be found. In the example below an exhaustive search is made to find a valid clique of size 4.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlv4vhHQrii2G1CxNq8JzkvFXniNwakkY3IfqAfP3_jY1kn2oSrgGRRtuSc5zFvq1kxl83p6Ehyphenhyphenl5-5GT6p4ZFqQ1iCxPVIlNcUz55jFg1Hs6fCGLo-LjEK9CEQSKgo9hGeg_MnXuNNWW1/s1600/clique.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlv4vhHQrii2G1CxNq8JzkvFXniNwakkY3IfqAfP3_jY1kn2oSrgGRRtuSc5zFvq1kxl83p6Ehyphenhyphenl5-5GT6p4ZFqQ1iCxPVIlNcUz55jFg1Hs6fCGLo-LjEK9CEQSKgo9hGeg_MnXuNNWW1/s1600/clique.png&quot; height=&quot;388&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
See how the search complexity would explode in possible permutations when increasing the number of nodes to 8, 9, 10...?&lt;br /&gt;
&lt;br /&gt;
There are many NP problems which on the surface seems very different. Some famous examples include the travelling salesman problem (TSP) where you search for a tour between a set of cities shorter than a given length. The boolean satisfiability problem (SAT) where you try to find a configuration for a set of boolean variables that makes an expression true. For example the expression (a AND NOT b) can be evaluated to true if a = true and b = false. There are no known algorithms to solve these problems in polynomial time.&lt;br /&gt;
&lt;br /&gt;
Now for some mind boggling facts about these problems. The clique problem together with several other NP problems are part of a special subclass in NP called NP-complete problems. Such problems have the property that all other NP problems can be converted to them in polynomial time. This means that for example the problem of factorizing a large number can in a fast way be remade into a graph clique problem. Solve the clique problem and you have the answer for the factorization.&lt;br /&gt;
See what this implies? If you can find a fast way of solving the clique problem or any other NP complete problem you have as a side effect solved all other NP problems since they can trivially (in respect to computational time) be converted to that problem.&lt;br /&gt;
&lt;br /&gt;
If this algorithm was discovered, the digital landscape would be completely changed. Internet security would become obsolete over night and many other applications could be revolutionized with faster algorithms.&lt;br /&gt;
&lt;br /&gt;
The NP equals P problem is probably the most famous open question within the field of computational computer science. Solve it and your name will be engraved in various precious metals.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Footnote:&lt;/i&gt;&lt;br /&gt;
The numbers for the example of large prime factorization described in this article are in fact taken from another challenge given by the RSA company. They posted publically a set of large semi prime numbers in 1991. A semi prime number is the factor of two primes. Each number had a reward attached so that when someone managed to factor the number they could claim prizes from $1,000 up to $200,000 USD. The numbers ranged from 330 to 2048 binary digits. The reason for this was to survey the academic landscape and find the cutting edge algorithms for prime factorization which their cryptographic product is based on. To current date all challenges up to 768 digits ($50,000) are beaten by various teams around the world. The challenge was discontinued in 2007.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/885805778397596234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2015/01/solve-party-planning-problem-and-earn-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/885805778397596234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/885805778397596234'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2015/01/solve-party-planning-problem-and-earn-1.html' title='Solve the party planning problem and earn $1 000 000 USD'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlv4vhHQrii2G1CxNq8JzkvFXniNwakkY3IfqAfP3_jY1kn2oSrgGRRtuSc5zFvq1kxl83p6Ehyphenhyphenl5-5GT6p4ZFqQ1iCxPVIlNcUz55jFg1Hs6fCGLo-LjEK9CEQSKgo9hGeg_MnXuNNWW1/s72-c/clique.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-8992152297308229730</id><published>2015-01-06T13:41:00.000+01:00</published><updated>2015-01-06T13:41:22.593+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DS18B20"/><category scheme="http://www.blogger.com/atom/ns#" term="raspberry pi"/><category scheme="http://www.blogger.com/atom/ns#" term="weather station"/><title type='text'>Raspberry Pi Weather Station with multiple thermometers</title><content type='html'>Last Christmas I gave my father in law a weather station to monitor temperature inside their summer house to avoid the pipes to freeze during the winter. It has been working well but has only been measuring the temperature inside the house. During the holiday we added another sensor to be able to also read the temperature outside the house.&lt;br /&gt;
See this blog post for the original setup&lt;br /&gt;
&lt;a href=&quot;http://macgyverdev.blogspot.se/2014/01/weather-station-using-raspberry-pi.html&quot;&gt;http://macgyverdev.blogspot.se/2014/01/weather-station-using-raspberry-pi.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Adding more thermometers is straight forward since the sensor used, a digital DS18B20, uses the OneWire protocol which the Raspberry Pi has drivers for. Adding more sensors doesn&#39;t require more ports on the Pi but instead reuses the same three ports for power, ground and data as the first sensor. Each thermometer has a unique hard wired address which is used to communicate over the data wire with the Raspberry Pi driver.&lt;br /&gt;
&lt;br /&gt;
Programmatically, the new sensor is represented as a device folder in&amp;nbsp;&lt;span style=&quot;background-color: #fefdfa; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: 13px; line-height: 18.2000007629395px;&quot;&gt;/sys/bus/w1/devices&lt;/span&gt;. You can simply cat this new file and find the latest temperature reading.&lt;br /&gt;
&lt;br /&gt;
The Raspberry Pi posts the temperature readings to a CouchDB server and a small single page app presents the historical readings with graphs for the current day, week and month.&lt;br /&gt;
&lt;br /&gt;
The original code is available on GitHub at&amp;nbsp;&lt;a href=&quot;https://github.com/johannoren/WeatherStation&quot;&gt;https://github.com/johannoren/WeatherStation&lt;/a&gt;.&lt;br /&gt;
The adaptations for multiple sensors can be found on branch&amp;nbsp;&lt;a href=&quot;https://github.com/johannoren/WeatherStation/tree/multiplesensors&quot;&gt;https://github.com/johannoren/WeatherStation/tree/multiplesensors&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYQwar963nuFBVhIWD-mlWj1m3LD_LxjPpIGths-4yxJ1bk22Eefp7yIFN8LePE-eGszxYGRBaVChOVlWVouD_LRNTn_oNZO37hszcoFFRP0B2xJ8IaCpwyBMn8CMRugB_wAZ-CXxz6ZVa/s1600/sensor.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYQwar963nuFBVhIWD-mlWj1m3LD_LxjPpIGths-4yxJ1bk22Eefp7yIFN8LePE-eGszxYGRBaVChOVlWVouD_LRNTn_oNZO37hszcoFFRP0B2xJ8IaCpwyBMn8CMRugB_wAZ-CXxz6ZVa/s1600/sensor.png&quot; height=&quot;640&quot; width=&quot;580&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/8992152297308229730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2015/01/raspberry-pi-weather-station-with.html#comment-form' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/8992152297308229730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/8992152297308229730'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2015/01/raspberry-pi-weather-station-with.html' title='Raspberry Pi Weather Station with multiple thermometers'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYQwar963nuFBVhIWD-mlWj1m3LD_LxjPpIGths-4yxJ1bk22Eefp7yIFN8LePE-eGszxYGRBaVChOVlWVouD_LRNTn_oNZO37hszcoFFRP0B2xJ8IaCpwyBMn8CMRugB_wAZ-CXxz6ZVa/s72-c/sensor.png" height="72" width="72"/><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-875486225722506153</id><published>2014-04-28T20:26:00.000+02:00</published><updated>2014-05-01T22:35:37.573+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="dynamic programming"/><category scheme="http://www.blogger.com/atom/ns#" term="uva online judge"/><title type='text'>Become a better programmer with programming challenges</title><content type='html'>When I went to university me and some friends spent time on practising algorithm implementations for the national programming contests that were held each year. The concept was (and still is) to solve about ten problems in a couple of hours time using a programming language of choice. The source code is submitted to an automatic judge that compiles the code and feeds the executable with test data and verifies that the program delivers the correct output expected for the input.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
After being out in real work I have noticed that I have had good use of these earlier exercises. One of the most important lessons is to know by heart the complexity of different algorithms and when to use a simple brute force method and when a more advanced algorithm must be implemented.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I noticed that the old Online Judge system that we practised on in the early 2000s still is online and has grown to a large site with lots of users solving programming challenges. If you want to recapitulate your algorithm skills this is a fun and very hands on way to do small exercises and get feedback in realtime. Also there is an addictive gamification effect of trying to solve more problems.&lt;br /&gt;
&lt;br /&gt;
Browse the &lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=3&quot;&gt;catalogue of problems&lt;/a&gt; and find some challenge that feels interesting. The problems are color coded so you know which one you already solved and some stats that gives a hint on how difficult the problems have been for other users to solve.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhix_Slo1ZZyHCEYPQ0v6ZMZvFVnwP_rGmxNN3gsXOgHDj_NYZjcWMWEodEoGZFHBHYsZna_FcGBzDqjUviqvjJcwqCABIJW7020DNLshUH4sebjFUUlfRka9biYRskE1HHjil4QHXjvGM5/s1600/problemlist.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhix_Slo1ZZyHCEYPQ0v6ZMZvFVnwP_rGmxNN3gsXOgHDj_NYZjcWMWEodEoGZFHBHYsZna_FcGBzDqjUviqvjJcwqCABIJW7020DNLshUH4sebjFUUlfRka9biYRskE1HHjil4QHXjvGM5/s1600/problemlist.png&quot; height=&quot;267&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Once you have submitted your code you get instant feedback on how your code has performed on the judges test cases.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLHh73EoOIJe7QXu4SORTyfxtQ-hWchBP6jk6N6vhBggtiecx_4BwCsE03klkia_dErUKtr6WLf_COH6tsoaJgTwokJzVCoeug_j3IicF7asGfK0FoMihu4ehvh7VNuBkZ_IJwB9TbL6Os/s1600/submissionlist.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLHh73EoOIJe7QXu4SORTyfxtQ-hWchBP6jk6N6vhBggtiecx_4BwCsE03klkia_dErUKtr6WLf_COH6tsoaJgTwokJzVCoeug_j3IicF7asGfK0FoMihu4ehvh7VNuBkZ_IJwB9TbL6Os/s1600/submissionlist.png&quot; height=&quot;181&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
At the moment you may submit solutions in C/C++/C++11 and Java. Create an account at&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/&quot;&gt;http://uva.onlinejudge.org/&lt;/a&gt;. Once you&#39;ve done that you can follow your progress and your statistics in different ways. Here&#39;s my stats&amp;nbsp;&lt;a href=&quot;http://uhunt.felix-halim.net/id/426271&quot;&gt;http://uhunt.felix-halim.net/id/426271&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I&#39;ve recently done a couple of problems per night just for the fun of it. It feels exciting to program on a hard problem using just 20 lines of code instead of coding 1000 lines of boiler plate which I guess many of us do at our every day works.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Without trying to indicate that I&#39;m an expert on complex algorithms, here are some things I think are valuable when getting serious about algorithm design and solving harder programming challenges.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;
Complexity theory&lt;/h2&gt;
&lt;div&gt;
If you didn&#39;t take a course on complexity theory or don&#39;t remember the basics I think this is a must to have in the toolbox for every programmer. This implies knowing which problems are inherently hard. By hard we dont mean hard to implement a solution for, but hard in the sense that the resources (CPU time or memory) scales bad with larger and larger sets of input for the problem.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The standard way of measuring the complexity of an algorithm is to resolve the algorithms &lt;i&gt;Ordo&lt;/i&gt; or &lt;i&gt;Big-O function. &lt;/i&gt;The formal definition is that this Big-O function &lt;i&gt;O()&lt;/i&gt; satifies&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;f(x) = O(g(x)) when x&amp;nbsp;&lt;/i&gt;➝&amp;nbsp;∞&lt;i&gt;&amp;nbsp; &amp;nbsp;if and only if &amp;nbsp; |f(x)| &amp;lt; M |g(x)| for all x &amp;gt; x&lt;sub&gt;0&lt;/sub&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In English this means that there is a constant &lt;i&gt;M &lt;/i&gt;which when multiplied with&lt;i&gt; g(x)&lt;/i&gt; always will be larger (make an upper bound) on the function &lt;i&gt;f(x)&lt;/i&gt; which is the time or memory usage of the algorithm for the input size &lt;i&gt;x&lt;/i&gt; of the problem when x is sufficiently large (larger than some certain&amp;nbsp;&lt;i&gt;x&lt;sub&gt;0&lt;/sub&gt;&lt;/i&gt;). These values always considers the worst case input for the algorithm. This might need an example.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Consider the problem of sorting an array of &lt;i&gt;n&lt;/i&gt; values. The basic &lt;i&gt;bubble sort&lt;/i&gt;&amp;nbsp;algorithm is probably the easiest algorithm to implement and uses two nested for loops to swap the values into a sorted order. Since the arrays have the size &lt;i&gt;n,&lt;/i&gt; which is the size of the input of the problem, the Big-O function for this will be &lt;i&gt;O(n²)&lt;/i&gt;. Why? The number of operations needed to sort the array will be proportional to two nested sweeps over the array of size &lt;i&gt;n&lt;/i&gt;, which makes &lt;i&gt;M×n×n&lt;/i&gt; operations. So &lt;i&gt;g(n) = n²&lt;/i&gt;. Here the actual swap operation is the constant &lt;i&gt;M&lt;/i&gt; number of machine operations.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Another problem, consider finding a value in a sorted tree (or in a sorted array for that matter via binary search). In this algorithm, each inspection of a node in the tree is proportional to one operation. Each inspection will cut the size of the tree in half so only one of the halfs will be needed to be examined in the next operation. This means that the number of operations needed to find the value will be less than the number of values in the tree. So we have an algorithm that is faster than the linear&lt;i&gt; g(n) = n&lt;/i&gt;. In fact this class of problems are solved in logarithmic time proportional to the size of the input, or &lt;i&gt;O(log(n))&lt;/i&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So going back to programming challenges, by knowing a lot of algorithms you might figure out which one will suit the particular problem. First of all, always find the bounds of the input data for your problem. What are the most extreme inputs we might expect to handle? Then, assuming the worst case scenario, what is the most easily implemented algorithm we can get away with within the requirements on time and space utilization?&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
For example, to sort an array of at most 10 000 000 values, bubble sort would require something proportional to&amp;nbsp;&lt;i&gt;n×n = 100 000 000 000 000 &lt;/i&gt;operations. Even with multi cores, this will not be fast. So by knowing that for example the &lt;i&gt;heap sort&lt;/i&gt; algorithm is &lt;i&gt;O(n log n)&lt;/i&gt; we know that this algorithm will sort the array proportional to &lt;i&gt;10 000 000&amp;nbsp;× 7 = 70 000 000. &lt;/i&gt;Definitively something that can be accomplished within a fraction of a second.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
But assume that we know that the values in the array are all in the range of 1 to 1000 000. This extra clue can give us the hint to consider bucket sort which has larger memory requirements than heap sort but can perform the sort in linear time proportional to the input size, &lt;i&gt;O(n)&lt;/i&gt;.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;
Know your algorithms&lt;/h2&gt;
&lt;div&gt;
The above example of sorting shows that it is essential to know a lot of algorithms. By &quot;knowing&quot;, you don&#39;t need to know the implementation of them. You can always search the web for actual implementations, pseudo code or even find them implemented in some library. The important part is to know that they exist and for what particular problems they are useful and what requirements they put on input data, time and memory usage so you can make a decision on whether they are applicable for your problem.&lt;br /&gt;
&lt;br /&gt;
There are specific algorithms targeting very specific problems such as Dijkstra&#39;s algorithm that solves the single-source shortest path problem for a graph with non-negative edge path costs. This is a rather common problem within the class of graph problems so it can be handy to know by heart, but maybe more interesting is to analyze what makes Dijkstra&#39;s algorithm successful. It is a typical example of &lt;i&gt;Dynamic Programming (DP)&lt;/i&gt; which is a general approach of solving many hard problems by breaking them into smaller and simpler subproblems and solving the larger problem by combining solutions of smaller problems. Other general ideas that can be useful in many different contexts is &lt;i&gt;divide and conquer&lt;/i&gt; algorithms,&lt;i&gt; greedy&lt;/i&gt; algorithms and &lt;i&gt;backtracking&lt;/i&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
When considering the programming challenges in the Online Judge system, often the hard and most interesting part is to figure out what class the problem belongs to. Can the problem description be translated into a graph problem for example? In that case which graph algorithm will solve the problem?&lt;br /&gt;
&lt;br /&gt;
Without any intention to be complete, here&#39;s some algorithms that can be valueable to know about and put in your toolbox together with some suggestions on problems to apply them on.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;h3&gt;
Sorting&lt;/h3&gt;
When considering which algorithm to choose, think about what requirements you have and the expected input. For example, some algorithms are stable, where stable means that if two objects are considered equal (depending on the comparison function used when sorting), the relative order of them will be preserved. For example the &lt;i&gt;quick sort algorithm&lt;/i&gt; is much more complicated to implement if it must behave in a stable manner. Furthermore, some algorithms have very nice average Big-O requirements but may deteriorate to &lt;i&gt;O(n²)&lt;/i&gt; if the values to sort already are sorted. Ordo funtioncs are always given for worst case scenarios.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Merge sort &lt;/i&gt;is a popular&lt;i&gt; O(n log n)&lt;/i&gt; sorting algorithm implemented in Perls sorting library. &lt;i&gt;Timsort, O(n log n)&lt;/i&gt;&amp;nbsp;is based on merge sort but can run in linear time if the input is already sorted. Timsort is deployed in JDK 7 and Python libraries.&lt;i&gt; Heap sort&lt;/i&gt; has even less memory requirements than merge sort and runs in the same time asymptotically.&lt;br /&gt;
&lt;br /&gt;
If you have the possibility to sort in parallel there are implementations of for example merge sort than can give even better performance.&lt;br /&gt;
&lt;br /&gt;
UVA problems that could be relevant to practise on: &lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=4&amp;amp;page=show_problem&amp;amp;problem=235&quot;&gt;299 - Train Swapping&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=14&amp;amp;page=show_problem&amp;amp;problem=1193&quot;&gt;10252 - Common Permutation&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Graph problems&lt;/h3&gt;
The most important thing to consider when attacking graph problems is how to traverse the graph. Depth First Search (DFS) is easily implemented with recursion but can have problems with non termination if the graph&#39;s size is similar to the internet and if recursion is made in languages like Java or C, the stack will overflow in a certain amount of iterations (stackframes). Other languages like Scala can avoid new stack frames if the code is written tail recursively which internally is unwrapped as a while loop. In older languages, you must know how to convert your recursive solution to an imperative loop solution when search depths become substantial.&lt;br /&gt;
&lt;br /&gt;
Adaptations to DFS can be for example &lt;i&gt;iterative deepening&lt;/i&gt;, popular in implementations of &lt;i&gt;game trees&lt;/i&gt; in for example Chess engines. This means that the search is performed to deeper and deeper depths in iterations making it possible to abort if for example a certain time constraint is broken. Useful when the branching factor of the searched tree is large.&amp;nbsp;&lt;i&gt;Alpha-beta pruning&lt;/i&gt;&amp;nbsp;is a clever way to reduce the search space by limiting the branching factors in DFS in game trees.&lt;br /&gt;
&lt;br /&gt;
Typical uses of DFS are finding a solution out of a maze, planarity testing, finding connected components of a graph, deciding biconnectivity of a graph and topological sorting of a directed graph.&lt;br /&gt;
&lt;br /&gt;
Breadth First Search (BFS) is based on a queue data structure and is easily implemented without recursion. Some typical uses of BFS is to find all nodes within a connected component, finding the shortest path between two nodes of an unweighted graph and to find the maximum flow in a flow network.&lt;br /&gt;
&lt;br /&gt;
Some practise problems on general graph and tree traversals are &lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=3&amp;amp;page=show_problem&amp;amp;problem=103&quot;&gt;167 - The Sultan&#39;s Successors&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=3&amp;amp;page=show_problem&amp;amp;problem=51&quot;&gt;115 - Climbing Trees&lt;/a&gt;, &lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=4&amp;amp;page=show_problem&amp;amp;problem=233&quot;&gt;297 - Quadtrees&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Combining DFS or BFS with ideas like greedy selection and DP and you have some of the most famous algorithms below.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Dijsktra&#39;s algorithm - &lt;/i&gt;Find the shortest path from a specific node to all other nodes in a graph with non-negative edge costs. The original algorithm from 1959 runs in &lt;i&gt;O(|V|²)&lt;/i&gt; where |V| is the number of vertices in the graph. An improvement uses a Fibonacci heap as priority queue which runs in&lt;i&gt; O(|E| + |V| log |V|) &lt;/i&gt;where |E| is the number of edges. However, implementing a Fibonacci heap is work on its own so only use it if necessary.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Bellman–Ford algorithm&lt;/i&gt; - Similar to Dijkstra&#39;s algorithm, Bellman-Ford finds shortests paths in a graph but can also handle negative edge weights (as long as there are no negative cycles since that means there is no shortest path).&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Prim&#39;s and Kruskal&#39;s algorithms&lt;/i&gt; can be used to find a minimum spanning tree of a graph. That means, a tree that includes all vertices that are connected within the graph. These algorithms have similar time complexity as Dijkstra since the &lt;i&gt;O(|V|²)&lt;/i&gt; can be improved to &lt;i&gt;O(|E| + |V| log |V|) &lt;/i&gt;&amp;nbsp;with a Fibonacci heap. Prim&#39;s algorithm is a good example of a greedy algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Floyd-Warshall&#39;s algorithm&lt;/i&gt; finds all shortest paths costs between all nodes in a graph with positive or negative edge weights (no negative cycles though). The simplest implementation can be extended to also keep a backtracking table so it is possible to not only find the path costs but also reconstruct the actual shortest path between all nodes. FW is a typical example of Dynamic Programming. FW runs in &lt;i&gt;O(|V|³)&lt;/i&gt;.&lt;br /&gt;
A good practice problem is &lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=3&amp;amp;page=show_problem&amp;amp;problem=40&quot;&gt;104 - Arbitrage&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Sequence and string problems&lt;/h3&gt;
There are a lot of problems involving finding longest sequences or subsequences in different lists. These lists can be arrays of numbers or characters written as strings. Often a combination of sorting and some specific algorithm is best medicine.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;The Longest Increasing Subsequence algorithm (LIS)&lt;/i&gt; will in the list&amp;nbsp;0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 figure out that the longest sequence in ascending order must be&amp;nbsp;0, 2, 6, 9, 13, 15. Note there can of course be other equally long sequences. LIS runs in&amp;nbsp;&lt;i&gt;O(n log n) &lt;/i&gt;since its implementation is based on binary search.&lt;br /&gt;
&lt;br /&gt;
The &lt;i&gt;Longest common substring &lt;/i&gt;problem means to find out that &quot;XYZ&quot; is the longest common substring in the three strings &quot;XYXYZ&quot;, &quot;YXYZX&quot; and &quot;XYZYX&quot;. There are two types of algorithms for this, one builds a suffix tree and one is based on dynamic programming.&lt;br /&gt;
&lt;br /&gt;
The problem of finding the minimum number of edit operations needed to turn one string into another is addressed by the &lt;i&gt;String-to-string correction problem&lt;/i&gt;. A side effect of the algorithm for this is that by storing the deltas you can for example store many very large quite similar strings by only keeping one copy of the first string and then the small deltas of the edits needed to turn it into the other strings. An application would be to store for example DNA sequences or similar in this way. The&lt;i&gt; Levenshtein distance&lt;/i&gt; is the number of changes needed to turn a string into another and can solve the String-to-string problem via a DP approach.&lt;br /&gt;
&lt;br /&gt;
Practise problems:&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=3&amp;amp;page=show_problem&amp;amp;problem=47&quot;&gt;111 - History Grading&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Number theory&lt;/h3&gt;
&lt;div&gt;
Math problems can sometimes feel academical but there are important real life applications considering for example prime numbers and cryptography or how many ways something can be done using combinatorics.&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;text-align: center;&quot;&gt;Problems concerning prime numbers are common. To verify whether a certain number is prime (primality testing), different algorithms can be used. For moderate bounds on input, simply test for divisibility up to&lt;i&gt;&amp;nbsp;√&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana, arial, serif; text-align: center;&quot;&gt;&lt;span style=&quot;background-color: white; text-decoration: overline; white-space: nowrap;&quot;&gt;&lt;i&gt;n&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;. Once &lt;i&gt;n&lt;/i&gt; is large you might need faster ways to test for primality. One of the fastest algorithms which runs in polynomial time is the &lt;a href=&quot;http://en.wikipedia.org/wiki/AKS_primality_test&quot;&gt;AKS test &lt;/a&gt;which can be implemented in &lt;i&gt;O(log(n)&lt;sup&gt;6&lt;/sup&gt;).&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
A tougher problem is to factor a number into its prime factors. The most difficult numbers are &lt;i&gt;semiprimes &lt;/i&gt;which are the product of two primes. No polynomial algorithm is known to do this which is the base of RSA cryptography. If you know more about the properties of the composite number there can be shortcuts to factor the number. Numbers on the form &lt;i&gt;r&lt;sup&gt;e&lt;/sup&gt;±s&lt;/i&gt; can be efficiently factored using the &lt;i&gt;Special Number Field Sieve&lt;/i&gt; algorithm if &lt;i&gt;r&lt;/i&gt; and &lt;i&gt;s&lt;/i&gt; are relatively small. From this the &lt;i&gt;General Number Field Sieve&lt;/i&gt; is derived which is the most efficient classical algorithm known for factoring integers &amp;gt; 100 digits.&lt;br /&gt;
&lt;br /&gt;
There are problems where you need to find the &lt;i&gt;greatest common divisor&lt;/i&gt;&amp;nbsp;(&lt;i&gt;gcd)&lt;/i&gt;&amp;nbsp;of two numbers. This number can be found using the Euclidean algorithm which can be implemented as below where &lt;i&gt;%&lt;/i&gt; is Javas syntax for modulus.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;color: #333333; line-height: 16.25px;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;gcd&lt;/span&gt;(&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; a, &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; b) {
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (b != &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;) {
      &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;gcd&lt;/span&gt;(b, a % b);
   }
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; Math.&lt;span style=&quot;color: #0000cc;&quot;&gt;abs&lt;/span&gt;(a);
}&lt;/pre&gt;
&lt;br /&gt;
Once we have gcd, we can easily calculate the &lt;i&gt;least common multiple (lcm)&amp;nbsp;&lt;/i&gt;of two numbers as&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDc_j5yXI_QupQRa_-3YFhrnz6jv2MNNjT4PvqNhLiIEAQWXQldnYdXzuJMd3QxppWJN8H-2NkK87xs0DUZ3ZK6R9XrVRDDmqhptLtQUv2iwTHc6Fj8AP9xr9vLTxAdbg_IKnxzrO3bOE5/s1600/CodeCogsEqn+(1).gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDc_j5yXI_QupQRa_-3YFhrnz6jv2MNNjT4PvqNhLiIEAQWXQldnYdXzuJMd3QxppWJN8H-2NkK87xs0DUZ3ZK6R9XrVRDDmqhptLtQUv2iwTHc6Fj8AP9xr9vLTxAdbg_IKnxzrO3bOE5/s1600/CodeCogsEqn+(1).gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Another problem that you will find in some of the UVA challenges includes raising large powers. If you are to calculate &lt;i&gt;a&lt;sup&gt;b&lt;/sup&gt;&lt;/i&gt; and &lt;i&gt;b&lt;/i&gt; is large the naive solution would include&lt;i&gt; b &lt;/i&gt;number of multiplications of &lt;i&gt;a&lt;/i&gt;. A much faster way is to use repeated squaring which means that you square the results to make the number of multiplications logarithmic in relation to &lt;i&gt;b&lt;/i&gt;. Some pseudo code for this would be&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;color: #333333; line-height: 16.25px;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * Calculates n to the p power, where &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * p is a positive number.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;
LargeInt &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;power&lt;/span&gt;(LargeInt n, LargeInt p) {
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (p == &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;) &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (p == &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;) &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; n
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (isOdd(p)) {
      &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; n * power( n * n, (p - &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;) / &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt; )
   } &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;else&lt;/span&gt; {
      &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;power&lt;/span&gt;( n * n, p / &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt; )
   }
}&lt;/pre&gt;
&lt;br /&gt;
There are some problems on calculating Fibonacci sequences. If you wind up with &lt;i&gt;Time Limit Exceeded&lt;/i&gt; (TLE) from the judge on these and you think you have made a really fast algorithm avoiding recursion and no double calculations, remember that factorials can be expressed in a closed form as well where &lt;i&gt;F(n) &lt;/i&gt;is the n&#39;th number in the sequence.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1Hl03zAlsvxEIBeJOC2el_GWhAx7dcE5ocwB_U2iQZgA11FfukxiD8yAbRgXayJvRo8Es40gOEvESmoh3AEOZ0JsXg-cvIzHJM5SKQ9LMM5Cks7W7p7KIL5AEzN-3YCTBuZjQ8RWsWd63/s1600/CodeCogsEqn.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1Hl03zAlsvxEIBeJOC2el_GWhAx7dcE5ocwB_U2iQZgA11FfukxiD8yAbRgXayJvRo8Es40gOEvESmoh3AEOZ0JsXg-cvIzHJM5SKQ9LMM5Cks7W7p7KIL5AEzN-3YCTBuZjQ8RWsWd63/s1600/CodeCogsEqn.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
Problems:&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=3&amp;amp;page=show_problem&amp;amp;problem=72&quot;&gt;136 - Ugly Numbers&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/external/1/160.html&quot;&gt;160 - Factors and Factorials&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/external/5/583.html&quot;&gt;583 - Prime Factors&lt;/a&gt;,&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
Combinatorics&lt;/h3&gt;
Variations on combinatorics is a common theme. Assume you have a box of &lt;i&gt;n&lt;/i&gt; items, in how many unique ways can you pick &lt;i&gt;k&lt;/i&gt; items? &lt;i&gt;0 &amp;lt;= k &amp;lt;= n&lt;/i&gt;.&lt;br /&gt;
If you remember your discreet mathematics this is solved using binomial coefficients (Pascal&#39;s triangle). The academic version is often described as a divisions of factorials.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivCvBnO3-1FDVg4_u6obDZvohq3cL4ENL2EK47OQXBVQimqtxEbL8iJlJCcMXe22Fxpl-pCNE38WexDSWqe4DyibV2yoc6pug4CPUYC5v38Ky_L4GkhFoou4G1X7yJqv1x-YivfnHaY7nb/s1600/binomialcoefficients.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivCvBnO3-1FDVg4_u6obDZvohq3cL4ENL2EK47OQXBVQimqtxEbL8iJlJCcMXe22Fxpl-pCNE38WexDSWqe4DyibV2yoc6pug4CPUYC5v38Ky_L4GkhFoou4G1X7yJqv1x-YivfnHaY7nb/s1600/binomialcoefficients.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This is not a practical implementations however. The formula can be rewritten as a product of terms better suited for an engineering implemention.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkJ0pTEaDsxPGZzti0Ditvnt_yP15MamZOZ-zrw_ix3CVwZfFKgGlTOGXfzSMi8CGg91vyBHVw-ZqNGp28nZx8pbwaNGTfI5RRxvcUUJIRF3Sa4yQvyr-6hLh2cKwBoa3OrsWTNxXSf-uN/s1600/binomialsmultiplicative.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkJ0pTEaDsxPGZzti0Ditvnt_yP15MamZOZ-zrw_ix3CVwZfFKgGlTOGXfzSMi8CGg91vyBHVw-ZqNGp28nZx8pbwaNGTfI5RRxvcUUJIRF3Sa4yQvyr-6hLh2cKwBoa3OrsWTNxXSf-uN/s1600/binomialsmultiplicative.png&quot; height=&quot;52&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Example problems:&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=24&amp;amp;page=show_problem&amp;amp;problem=1160&quot;&gt;10219 - Find the ways !&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=24&amp;amp;page=show_problem&amp;amp;problem=2396&quot;&gt;11401 - Triangle Counting&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Probability theory&lt;/h3&gt;
Knowing some basic probability theory is not only good for programming challenges. Besides the basic definitions and axioms (Kolgomorov) there are lots of interesting topics such as stochastic processes and variables, probability distributions, Bayes theorem and more.&lt;br /&gt;
&lt;br /&gt;
Practise problem:&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=16&amp;amp;page=show_problem&amp;amp;problem=1432&quot;&gt;10491 - Cows and Cars&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Dynamic Programming&lt;/h2&gt;
Dynamic programming (DP) is a methodology for attacking complex problems by splitting the problem into simpler subproblems which solutions can be reused to solve the original problem. The problem must have the property of &lt;i&gt;overlapping subproblems&lt;/i&gt;. This means that the subproblems are occuring several times in the problem and can be reused in the DP approach. A simple example of this would be a function&lt;i&gt; f(n)&lt;/i&gt; to calculate Fibonacci numbers. Since &lt;i&gt;f(n) = f(n-1) + f(n-2),&amp;nbsp;&lt;/i&gt;a DP approach would store each &lt;i&gt;f(x)&lt;/i&gt; to reuse previously calculated valued. The stored values are called &quot;memo-ized&quot;.&lt;br /&gt;
&lt;br /&gt;
In general, DP is a technique to speed up solutions of problems where you make brute force searches and cache intermediate results.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s examine a more complex problem where DP actually makes great difference.&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&quot;Suppose you have x dollars and want to figure out in how many unique ways you get change for this in the coins 1c, 5c, 10c, 25c and 50c.&quot;&lt;/blockquote&gt;
The brute force approach would be to nest five for loops and iterate over the five different coins and count the number of valid combinations. A very simple algorithm but it would not scale well with larger amounts of dollars or if we had more types of coins increasing the number of nested for loops.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s start thinking from a dynamic programming perspective. Can we make the problem simpler? Let&#39;s assume we have solved the same problem (in some at this time unknown way) for 4 currencies. So we know how many combinations you could get x dollars in 1c, 5c, 10c and 25c. Could this help us? Yes, then we could deduce that the total number of combinations would be the sum of &lt;i&gt;0, 1, 2 ... n&lt;/i&gt; number of 50c coins where &lt;i&gt;n&lt;/i&gt; is the maximal number of 50c coins you could get out of x dollars. Each such number of combinations could be calculated by the already known function since it handles the other four coins.&lt;br /&gt;
&lt;br /&gt;
Naturally, we can use the same approach to solve the problem for 4, 3 and 2 coins. The case of 1 coin is so simple that we can implement it without relying on any other assumed function.&lt;br /&gt;
&lt;br /&gt;
Here&#39;s a recursive implementation of this idea.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;color: #333333; line-height: 16.25px;&quot;&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;combinations&lt;/span&gt;(&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt;[] change, &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; maxCoins,
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; amount) {

   &lt;span style=&quot;color: #888888;&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;    * Base case 1. If amount = 0, there is one combination -&amp;gt; no change.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;    */&lt;/span&gt;
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (amount == &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;) {
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;;
   }

   &lt;span style=&quot;color: #888888;&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;    * Base case 2. If negative amount, no solutions&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;    */&lt;/span&gt;
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (amount &amp;lt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;) {
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;;
   }

   &lt;span style=&quot;color: #888888;&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;    * Base case 3. No change to work with -&amp;gt; no solutions&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;    */&lt;/span&gt;
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (maxCoins &amp;lt;= &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;) {
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;;
   }

   &lt;span style=&quot;color: #888888;&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;    * Here goes the recursion, sum all combinations using one coin less&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;    * from the list of coins plus the number of combinations if we remove&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;    * one of the largest coins from the total amount.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;    */&lt;/span&gt;
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; c = combinations(change, maxCoins - &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;, amount) + combinations(change, maxCoins, amount - change[maxCoins - &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;]);

   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; c;
  }&lt;/pre&gt;
&lt;br /&gt;
Call it with the number of available coins and the number of coins in the array to use together with the total amount of dollars (times 100 to get int values for cents).&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;color: #333333; line-height: 16.25px;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; combs = combinations([&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;5&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;10&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;25&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;50&lt;/span&gt;], &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;5&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;500000&lt;/span&gt;);&lt;/pre&gt;
&lt;br /&gt;
This will work, but it will not be efficient. For each invocation that does not end in a base case, two recursive calls will be performed and the same subproblem will be recalculated over and over again.&lt;br /&gt;
&lt;br /&gt;
The good thing is that we have divided the problem into specific overlapping subproblems. Now we can add the idea of dynamic programming. Add a cache that stores previous calculations as a base case to make the recursive solution only calculate subproblems that not have been encountered before.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;color: #333333; line-height: 16.25px;&quot;&gt;    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;combinations&lt;/span&gt;(&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt;[] change, &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; maxCoins,
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; amount, &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; lookupTable[][]) {

        &lt;span style=&quot;color: #888888;&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;         * Base case 1. If amount = 0, there is one combination -&amp;gt; no change.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;         */&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (amount == &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;) {
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;;
        }

        &lt;span style=&quot;color: #888888;&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;         * Base case 2. If negative amount, no solutions&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;         */&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (amount &amp;lt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;) {
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;;
        }

        &lt;span style=&quot;color: #888888;&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;         * Base case 3. No change to work with -&amp;gt; no solutions&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;         */&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (maxCoins &amp;lt;= &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;) {
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;;
        }

        &lt;span style=&quot;color: #888888;&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;         * Base case 4. This is already calculated, so DP finds result in cache&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;         */&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (lookupTable[maxCoins][amount] != -&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;) {
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; lookupTable[maxCoins][amount];
        }

        &lt;span style=&quot;color: #888888;&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;         * Here goes the recursion, sum all combinations using one coin less&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;         * from the list of coins plus the number of combinations if we remove&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;         * one of the largest coins from the total amount.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;         */&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; c = combinations(change, maxCoins - &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;, amount,
                lookupTable)
                + combinations(change, maxCoins, amount
                        - change[maxCoins - &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;], lookupTable);

        lookupTable[maxCoins][amount] = c;

        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; c;
    }&lt;/pre&gt;
&lt;br /&gt;
This will perform efficiently and is it is easy to understand the logic. Unfortunately a problem with recursive solutions in imperative languages like Java is that deep recursions will run out of stack space. So to make this solution even more generic we should rewrite it using loops instead of in the more aestethic functional style.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;color: #333333; line-height: 16.25px;&quot;&gt;    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt;[][] &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;combinations&lt;/span&gt;(&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt;[] change, &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; maxCoins,
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; amount) {

        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt;[][] lookupTable = &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt;[amount + &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;][maxCoins + &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;];

        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; i = &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;; i &amp;lt;= amount; i++) {
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; j = &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;; j &amp;lt;= maxCoins; j++) {
                &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (i == &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;) {
                    lookupTable[i][j] = &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;;
                } &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (j == &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;) {
                    lookupTable[i][j] = &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;;
                } &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; (change[j - &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;] &amp;gt; i) {
                    lookupTable[i][j] = lookupTable[i][j - &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;];
                } &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;else&lt;/span&gt; {
                    lookupTable[i][j] = lookupTable[i - change[j - &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;]][j]
                            + lookupTable[i][j - &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;];
                }
            }
        }

        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; lookupTable;
    }&lt;/pre&gt;
&lt;br /&gt;
This function retrieves the all the memoized combinations and we find the solution to our problem as&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;line-height: 16.25px;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt;[] change = { &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;5&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;10&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;25&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;50&lt;/span&gt; };
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt;[][] combs = combinations(change, change.&lt;span style=&quot;color: #0000cc;&quot;&gt;length&lt;/span&gt;, maxDollars&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);
&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;       &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;   answer = &lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;combs[amountToChange][5&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
In the UVA problem set you will often need to think from a DP perspective to create solutions that are fast enough for the input data and the time constraints.&lt;br /&gt;
&lt;br /&gt;
Some good problems to practise on: &lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=3&amp;amp;page=show_problem&amp;amp;problem=39&quot;&gt;103 - Stacking Boxes&lt;/a&gt;, &lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=3&amp;amp;page=show_problem&amp;amp;problem=44&quot;&gt;108 - Maximum Sum&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The particular coin change problem described above is available in several versions on UVA. Have a try at problem&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=3&amp;amp;page=show_problem&amp;amp;problem=83&quot;&gt;147 - Dollars&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Divide and Conquer&lt;/h2&gt;
Divide and conquer algorithms are based on multi branched recursion. It breaks down a problem into several sub problems and recurse on them. These can thereby be divided into subproblems until they are small enough to be easily solved. Then the solutions are used to generate the answer to the complex problem. Quicksort, merge sort, discrete Fourier transform (FFT), top down parsers used in syntactic analysis are D&amp;amp;C algorithms.&lt;br /&gt;
&lt;br /&gt;
Another example that can be useful to know in the UVA problem challenges is that there is an algorithm called Karatsuba which multiplies two large integers (with thousand or millions of digits) fast. It runs in &lt;i&gt;O(3n&lt;sup&gt;log&lt;sub&gt;2&lt;/sub&gt;3&lt;/sup&gt;)&lt;/i&gt; which is notably faster than the &lt;i&gt;O(n&lt;sup&gt;2&lt;/sup&gt;)&lt;/i&gt; method we learned in school. Karatsuba is a D&amp;amp;C algorithm. Binary search could be called a simple form of D&amp;amp;C.&lt;br /&gt;
&lt;br /&gt;
Suitable practise problems:&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=24&amp;amp;page=show_problem&amp;amp;problem=1282&quot;&gt;10341 - Solve It&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Greedy algorithms&lt;/h2&gt;
A greedy algorithm makes local optimal choices at each stage during the algorithm in hope of producing a global optimum. Many problems will fail to do so with a greedy approach since the complete search space is not visited. But for certain problems greedy selection works well and can therefore create fast solutions. In other cases where the optimal solution is not possible to calculate in an efficient way, a greedy solution might come up with a decent approximation or bounded result.&lt;br /&gt;
&lt;br /&gt;
Examples of greedy algorithms are the construction of a Huffman tree during Huffman coding or Kruskal&#39;s algorithm for finding a minimum spanning tree of a graph.&lt;br /&gt;
&lt;br /&gt;
Practise problem:&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=24&amp;amp;page=show_problem&amp;amp;problem=2384&quot;&gt;11389 - The Bus Driver Problem&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Backtracking&lt;/h2&gt;
Backtracking is a technique that finds one or all solutions to a problem by trying different candidates and abandon those branches that breaks the constraints of the problem which means that the current path cannot lead to a valid solution of the problem.&lt;br /&gt;
&lt;br /&gt;
An example where backtracking would be suitable is a solver for a Sudoku puzzle. By doing a depth first search and inserting new numbers in empty positions and for each insertion checking whether the new number breaks any constraints of the rules of Sudoku, the board can be iteratively filled with valid numbers. As soon as a number violates the rules and all numbers have been tried in the current position, the algorithm must backtrack to the previous position and try another number.&lt;br /&gt;
&lt;br /&gt;
Examples where backtracking is suitable are puzzles and combinatorial optimization problems such as the knapsack problem.&lt;br /&gt;
&lt;br /&gt;
A good practise problem is the classic Eight Queens puzzle where you should position eight queens on a chessboard without any queen threatening another. Here&#39;s a few modifications on that theme on the UVA site &lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=24&amp;amp;page=show_problem&amp;amp;problem=2026&quot;&gt;11085 - Back to the 8-Queens&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=3&amp;amp;page=show_problem&amp;amp;problem=103&quot;&gt;167 - The Sultan&#39;s Successors&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
UVA Online Judge&lt;/h2&gt;
The online judge system at&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/&quot;&gt;http://uva.onlinejudge.org/&lt;/a&gt;&amp;nbsp;accepts code in C/C++/C++11/Java. Some hints for beginners might be to start with an easy problem to get to know the judge. Good choices might be problem&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=12&amp;amp;page=show_problem&amp;amp;problem=959&quot;&gt;10018 - Reverse and Add&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=23&amp;amp;page=show_problem&amp;amp;problem=2113&quot;&gt;11172 - Relational Operator&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Important, read the input and output constraints carefully. For example, if the input consists of integers and are between 0 and&amp;nbsp;4,294,967,295 remember that a signed 32 bit integer will overflow so you should use a 64-bit integer or an unsigned int depending on the language you code in.&lt;br /&gt;
&lt;br /&gt;
Output format matters, so be careful with trailing spaces and linefeeds. Sometimes you simply must try with or without an ending newline since the problem description won&#39;t tell which one is correct unfortunately.&lt;br /&gt;
&lt;br /&gt;
Create a good template which you can copy when starting on a new problem. If you code in Java you will probably have everything you need in the standard library such as BigIntegers and much more. If you code in C/C++ it can be good to add some routines for handling arbitrary large numbers to your template.&lt;br /&gt;
&lt;br /&gt;
If you get stuck on a problem try to create test cases for all the border cases allowed in the input. Try the worst possible input and also the smallest possible input to see that you get reasonable output.&lt;br /&gt;
&lt;br /&gt;
Many basic problems can be solved with simple ad hoc brute force solutions but the more interesting problems with greater time complexities will perform very badly with naive solutions. The problems are often devised so that brute force solutions will not be able to perform within the time limits. However, once you&#39;ve created a fancy solution based on DP or some other approach it is not always self evident that the algorithm is correct. In those cases it can still be valuable to run the outputs from your algorithm against a quickly coded brute force solution to verify that they produce the same output.&lt;br /&gt;
&lt;br /&gt;
If you still is stuck and can&#39;t figure out why the online judge gives your solution &quot;Wrong Answer&quot; you can check the forums where many helpful programmers gives hints or test data to test your code against.&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
Edit 2014-05-01:&lt;br /&gt;
I got feedback on whether I could recommend any books for those interested to dig deeper. I got two books which I bought ten years ago which I still think should be relevant.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/0387001638/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0387001638&amp;amp;linkCode=as2&amp;amp;tag=macgydevel-20&amp;amp;linkId=KOBVZ4HDYFNUKWL2&quot;&gt;Programming Challenges: The Programming Contest Training Manual&lt;/a&gt;&amp;nbsp;by Skiena and Revilla is exactly what it sounds like. A walktrough of different types of programming challenges and techniques for solving them.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/032157351X/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=032157351X&amp;amp;linkCode=as2&amp;amp;tag=macgydevel-20&amp;amp;linkId=UMFY4HEISJWRGE2J&quot;&gt;Algorithms&lt;/a&gt;&amp;nbsp;by Sedgewick and Wayne is more a general CS book and a good read.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/0387001638/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0387001638&amp;amp;linkCode=as2&amp;amp;tag=macgydevel-20&amp;amp;linkId=JNIEJO73ZZVBCE2S&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=0387001638&amp;amp;Format=_SL110_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=macgydevel-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=macgydevel-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0387001638&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/gp/product/032157351X/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=032157351X&amp;amp;linkCode=as2&amp;amp;tag=macgydevel-20&amp;amp;linkId=M36MR5XCN5BONPWN&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=032157351X&amp;amp;Format=_SL110_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=macgydevel-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=macgydevel-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=032157351X&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/875486225722506153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2014/04/become-better-programmer-with.html#comment-form' title='70 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/875486225722506153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/875486225722506153'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2014/04/become-better-programmer-with.html' title='Become a better programmer with programming challenges'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhix_Slo1ZZyHCEYPQ0v6ZMZvFVnwP_rGmxNN3gsXOgHDj_NYZjcWMWEodEoGZFHBHYsZna_FcGBzDqjUviqvjJcwqCABIJW7020DNLshUH4sebjFUUlfRka9biYRskE1HHjil4QHXjvGM5/s72-c/problemlist.png" height="72" width="72"/><thr:total>70</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-4213276522865994986</id><published>2014-03-17T10:32:00.003+01:00</published><updated>2014-03-21T11:24:47.594+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="git"/><title type='text'>New Eclipse project connected to Git repository</title><content type='html'>You have a new Eclipse project to work on and you want to version control it on a Git repository on another machine. Here&#39;s how you do it.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
1. On the server you wish to have your Git repository remotely stored, setup an empty repository. In our examples here the repository and project will be called UVaOnline&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@htpc ~/gitrepos $ pwd&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;/home/johan/gitrepos&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@htpc ~/gitrepos $&amp;nbsp;mkdir UVaOnline.git&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@htpc ~/gitrepos $&amp;nbsp;cd UVaOnline.git/&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@htpc ~/gitrepos/UVaOnline.git $&amp;nbsp;git --bare init --shared=all&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
2. Add a file to this empty project if you wish to make sure there is something to check out from Eclipse.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@htpc ~/gitrepos $ cd /tmp&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@htpc /tmp $&amp;nbsp;git clone /home/johan/gitrepos/UVaOnline.git/&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;johan@htpc /tmp $&lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;cd UVaOnline/&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;johan@htpc /tmp $&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;touch FOO&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;johan@htpc /tmp $&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git add FOO&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;johan@htpc /tmp $&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git commit&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;johan@htpc /tmp $&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git push origin master&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
3. In Eclipse, add the Git Repository Exploring perspective via the menu Window -&amp;gt; Open Perspective.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVq-N4dacoaQdWGJFl_LuVDITbKFUskVzWT5uMu4xdVZxB_qPF_U-4NNMehEgfYURKje7KXqmvK8XGJ5a4KVVFm6zqGRDPn6sFUvjeV1IFuy0pdeFUXFlYUtkWWnzHyu_qmgn9lANHoR1k/s1600/eclipse-git-server-config0.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVq-N4dacoaQdWGJFl_LuVDITbKFUskVzWT5uMu4xdVZxB_qPF_U-4NNMehEgfYURKje7KXqmvK8XGJ5a4KVVFm6zqGRDPn6sFUvjeV1IFuy0pdeFUXFlYUtkWWnzHyu_qmgn9lANHoR1k/s1600/eclipse-git-server-config0.png&quot; height=&quot;400&quot; width=&quot;328&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
4. Click the &quot;Clone a Git repository and add the clone to this view&quot; icon in the perspective.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOeTUTzzdmPnEh50tQZmNG0DLg0plAhA8N2YqFRpPWRlxipSBBSXpeh5aj-zFg-fas5irxFdRUt5g6zFGm7i-UIbyKy8zcX7Crrj9oeT1VfCuhYqkGb7FOv6zGTHf6m4V6Gim4xpVKtJyu/s1600/eclipse-git-server-config0.1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOeTUTzzdmPnEh50tQZmNG0DLg0plAhA8N2YqFRpPWRlxipSBBSXpeh5aj-zFg-fas5irxFdRUt5g6zFGm7i-UIbyKy8zcX7Crrj9oeT1VfCuhYqkGb7FOv6zGTHf6m4V6Gim4xpVKtJyu/s1600/eclipse-git-server-config0.1.png&quot; height=&quot;88&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
5. In the first step of this wizard, enter the connection details for the Git repository. In my case I use my SSH user to log on the server.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNhmVH7Uyn6jNODntWvC8tI2dxhBQjVAVueJXzoqu292dCdqNT-ptcVBQhGTIfSAttDZTTkm2R1GCChR-KRbCDxzc-yZyu3dLQzk5rw4Gwls7VAcdFfqnzzyGQNBqBmTEpqpENXUSxAkGS/s1600/eclipse-git-server-config.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNhmVH7Uyn6jNODntWvC8tI2dxhBQjVAVueJXzoqu292dCdqNT-ptcVBQhGTIfSAttDZTTkm2R1GCChR-KRbCDxzc-yZyu3dLQzk5rw4Gwls7VAcdFfqnzzyGQNBqBmTEpqpENXUSxAkGS/s1600/eclipse-git-server-config.png&quot; height=&quot;400&quot; width=&quot;393&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div&gt;
6. If your project was emtpy, you only have the master branch to work with. Click next.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVh3JniwPqHdvByPwOxI7T666qT2RoPIchPjG4DzEsHMHzvTtbXJfqMUC9tFkLG-ZSxxFJ5brRLx5GmxJQXtiKlwHbFMCJfQIaJ0z2kepzQH6dU2FknO1aiJ9f7NK9Ey97D02FJtGPbMW1/s1600/eclipse-git-server-config-step2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVh3JniwPqHdvByPwOxI7T666qT2RoPIchPjG4DzEsHMHzvTtbXJfqMUC9tFkLG-ZSxxFJ5brRLx5GmxJQXtiKlwHbFMCJfQIaJ0z2kepzQH6dU2FknO1aiJ9f7NK9Ey97D02FJtGPbMW1/s1600/eclipse-git-server-config-step2.png&quot; height=&quot;400&quot; width=&quot;393&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
7. Choose where you wish to have your local Git repository on the machine Eclipse is installed on. I selected the &quot;Import all existing projects after clone finishes&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiZle1c9IqJ5FG4aaQSf-dgOUXZRRaklcX_8Jy7ehBI31Z2OkmRgPk1eXaDCxZJKUtP64Muhh0dEw4sYBjSon5bfi8VEwMrWiLQ1uXmwO_1B67mMNaxl_OpgukqhhGwnJNJ-6dEfNA7Qhu/s1600/eclipse-git-server-config-step3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiZle1c9IqJ5FG4aaQSf-dgOUXZRRaklcX_8Jy7ehBI31Z2OkmRgPk1eXaDCxZJKUtP64Muhh0dEw4sYBjSon5bfi8VEwMrWiLQ1uXmwO_1B67mMNaxl_OpgukqhhGwnJNJ-6dEfNA7Qhu/s1600/eclipse-git-server-config-step3.png&quot; height=&quot;400&quot; width=&quot;393&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
8. Now a new repository should be available in the Git repository Explorer.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnHpwASTOJW0ll9vDDBRhR9G1LQwEVV6_7G8D6HmkY4rKebxfgm3uvSWAAb1sXeHNCVT-0xsBkXuOne5zVbeDyrn3rncSLUIRTrJS6eq4wMbbyraiulWVc2Ipq7h2ImHW5J5j2K0s-y2O3/s1600/eclipse-git-server-config-step4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnHpwASTOJW0ll9vDDBRhR9G1LQwEVV6_7G8D6HmkY4rKebxfgm3uvSWAAb1sXeHNCVT-0xsBkXuOne5zVbeDyrn3rncSLUIRTrJS6eq4wMbbyraiulWVc2Ipq7h2ImHW5J5j2K0s-y2O3/s1600/eclipse-git-server-config-step4.png&quot; height=&quot;196&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
9. Try to fetch the repository if you want to see the refs configurred.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqE91UDPsVRU8GG9eFkvoDZuabtcoYMnbBqlWZdqFFseT6dplIbC8oBLN3TwWmXZF_x_n2l-KRHzsLHw780P6332JipUQpPKyiGKOjMr9w2cTcDzvqHUjg1ijAIqoIuep8oP0r6-l1ZEC_/s1600/eclipse-git-server-config-step5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqE91UDPsVRU8GG9eFkvoDZuabtcoYMnbBqlWZdqFFseT6dplIbC8oBLN3TwWmXZF_x_n2l-KRHzsLHw780P6332JipUQpPKyiGKOjMr9w2cTcDzvqHUjg1ijAIqoIuep8oP0r6-l1ZEC_/s1600/eclipse-git-server-config-step5.png&quot; height=&quot;400&quot; width=&quot;326&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
10. You see the connection URL again, next.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPaWw9xxHXw7E4HBsP1gTykQw9qJzrjK5gbnfed6nUa9xgeZ3MKE6-5LP8flXSCCWb5EhrbqVCn3LkPJxSP-dGzSGqBdyrGetKdEtnbA2QFxBtIiPPIBTGlhovtE_Qn66NWRzoQsS9LJce/s1600/eclipse-git-server-config-step6.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPaWw9xxHXw7E4HBsP1gTykQw9qJzrjK5gbnfed6nUa9xgeZ3MKE6-5LP8flXSCCWb5EhrbqVCn3LkPJxSP-dGzSGqBdyrGetKdEtnbA2QFxBtIiPPIBTGlhovtE_Qn66NWRzoQsS9LJce/s1600/eclipse-git-server-config-step6.png&quot; height=&quot;400&quot; width=&quot;348&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
11. Here you could add or delete refs pointers. For our purposes, this looks alright.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvpzAb3gIdISyoKoEFJ54-mgeKz2jHJdx5_z8POZkxK3YctSZfQ6IESHoVjjAKhIuVhwByhMu2NXHBa9SXUVe0jk7w5SwydY5-nsL3uYu5W2HPeJJbdKifTgKSmiLZB6IjedlgaLyb0byG/s1600/eclipse-git-server-config-step7.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvpzAb3gIdISyoKoEFJ54-mgeKz2jHJdx5_z8POZkxK3YctSZfQ6IESHoVjjAKhIuVhwByhMu2NXHBa9SXUVe0jk7w5SwydY5-nsL3uYu5W2HPeJJbdKifTgKSmiLZB6IjedlgaLyb0byG/s1600/eclipse-git-server-config-step7.png&quot; height=&quot;400&quot; width=&quot;348&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
12. To import the project into the Java/Java EE perspectives, click the &quot;Import Projects&quot; option in the menu.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIbJGh8W2epqW9hWBveaO7i4FoKFbdUtP1rnRZxPqWqaGtIKqBWaN60Df83_vFwsPIgYOFlxfaZzUE1rhdN774XGIvHKaG_XE2vQ6PyQVCAdjKOPHUsLAoy_r6kQdwC8lBYE-3hemOjfcv/s1600/eclipse-git-server-config-step8.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIbJGh8W2epqW9hWBveaO7i4FoKFbdUtP1rnRZxPqWqaGtIKqBWaN60Df83_vFwsPIgYOFlxfaZzUE1rhdN774XGIvHKaG_XE2vQ6PyQVCAdjKOPHUsLAoy_r6kQdwC8lBYE-3hemOjfcv/s1600/eclipse-git-server-config-step8.png&quot; height=&quot;400&quot; width=&quot;356&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
13. Since this project is a bare bones project with no .project file with Java facets, we must select to import the project as a &quot;Import as general project&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgV1PwSQdUtLTCylXvALaUSM2ztylAdPwlWK13YSbhj1CfHCAYP96dkLGI9sN7o65Al0hzPj_k3p-kkkk-xtNUtr3x8virTuFHFyjt5M55jg2UjP5J-Mf7xcTbU7YLxlJ-ZDCHRtbSzxgK_/s1600/eclipse-git-server-config-step9.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgV1PwSQdUtLTCylXvALaUSM2ztylAdPwlWK13YSbhj1CfHCAYP96dkLGI9sN7o65Al0hzPj_k3p-kkkk-xtNUtr3x8virTuFHFyjt5M55jg2UjP5J-Mf7xcTbU7YLxlJ-ZDCHRtbSzxgK_/s1600/eclipse-git-server-config-step9.png&quot; height=&quot;388&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
14. Probably the default name is good enough.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR9AuWu7B9J5fL7xUi52esmJtmDmU8PApDXZeAmrrwXeZqoa0jCfA-sP-Y_KuzjN3xXmDCxTkNcT5HTuQ81dx-LJYkhbumi9STw_p6mkGGiW3GQoqY07-eChcaDLgbgsvOs-FvbNYipU8Q/s1600/eclipse-git-server-config-step10.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR9AuWu7B9J5fL7xUi52esmJtmDmU8PApDXZeAmrrwXeZqoa0jCfA-sP-Y_KuzjN3xXmDCxTkNcT5HTuQ81dx-LJYkhbumi9STw_p6mkGGiW3GQoqY07-eChcaDLgbgsvOs-FvbNYipU8Q/s1600/eclipse-git-server-config-step10.png&quot; height=&quot;388&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
15. Now you could start adding file to your project. I made my project a Maven project here and added some source code. Once you&#39;re ready to commit to the remote repository, right-click and choose Team -&amp;gt; Synchronise Workspace.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbkPgRByWSi9Q4ZDzD3xI-0XVdBlb2uhh1C4VC6XThyphenhyphen2j7iL35Y22whV3rq_aYBjWtJCs6Qe_w7-9G6NZHwp3q3Ee7lRXAQklu_v7Djao4pmvF-lPFdgfZp0zSRRKcD11sDt1hM6X3h8Mg/s1600/eclipse-git-server-config-step11.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbkPgRByWSi9Q4ZDzD3xI-0XVdBlb2uhh1C4VC6XThyphenhyphen2j7iL35Y22whV3rq_aYBjWtJCs6Qe_w7-9G6NZHwp3q3Ee7lRXAQklu_v7Djao4pmvF-lPFdgfZp0zSRRKcD11sDt1hM6X3h8Mg/s1600/eclipse-git-server-config-step11.png&quot; height=&quot;322&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
16. In the next view, select the files you wish to commit and add them to Git index first.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGhZ8MqmU2076TM77s8uyBIlDFAQgLoThOuLyPou2PVQphH-99OvA6ormzFyaV6yDHq4FNSnfWMuoA0BBej1JQVMCFAlYbxJYFUwjowUC5tWwrUu1hypcznbz8Nm5M-BJjF1m9rGAKot1H/s1600/eclipse-git-server-config-step-new.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGhZ8MqmU2076TM77s8uyBIlDFAQgLoThOuLyPou2PVQphH-99OvA6ormzFyaV6yDHq4FNSnfWMuoA0BBej1JQVMCFAlYbxJYFUwjowUC5tWwrUu1hypcznbz8Nm5M-BJjF1m9rGAKot1H/s1600/eclipse-git-server-config-step-new.png&quot; height=&quot;283&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
17. Then right click again and commit.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFzp6-YL9WWcEa95fuIVgpFcdiujkOx35JzDrle62DoKhmH3FmrzJnlKB8z6Il6ew_lEOl_7s1uWgTBp3fzuRg2psIYRkaKF8YtEcRpwMaICVsm-izgvqPlkDK_smchXcKpbr7AZRItL5x/s1600/eclipse-git-server-config-step-new2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFzp6-YL9WWcEa95fuIVgpFcdiujkOx35JzDrle62DoKhmH3FmrzJnlKB8z6Il6ew_lEOl_7s1uWgTBp3fzuRg2psIYRkaKF8YtEcRpwMaICVsm-izgvqPlkDK_smchXcKpbr7AZRItL5x/s1600/eclipse-git-server-config-step-new2.png&quot; height=&quot;390&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
18. If you do not click &quot;Commit and push&quot; the files are only added to your local git repository on the same machine. That can be good if you want to pile up a bunch of local commits before pushing to the remote repository. When you want to push all local commits, in the Java perspective right click and go via Remote to Push.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge0RsdoxL8eNwl6pEkk9efEJtvcyPZX3jOmaXgl3AAjVNfnoPImeZA-NiH_OfEWikouh5f4Yx6P2LR2Q8jrTfJsGarP7U04tzE1RhpHgQa0tGerL1mTqlHyco7BBIR-Ua5xVnYOX3lLe1A/s1600/eclipse-git-server-config-step13.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge0RsdoxL8eNwl6pEkk9efEJtvcyPZX3jOmaXgl3AAjVNfnoPImeZA-NiH_OfEWikouh5f4Yx6P2LR2Q8jrTfJsGarP7U04tzE1RhpHgQa0tGerL1mTqlHyco7BBIR-Ua5xVnYOX3lLe1A/s1600/eclipse-git-server-config-step13.png&quot; height=&quot;395&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
19. If it is the first time, you might need to add a spec for this. If you work on master which you do if you have followed the tutorial, simple add &quot;refs/heads/master&quot; as source and destination ref and click &quot;Add spec&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzi4M0-VeP4rxf52Zv09fYnqhhPCLvmsmmiEfuWsUC08R2uO52RuzxO_BSXot6FfvxIr4HBxhAPCmoGI9hsQeJKHLhCM7QQkAsXvq9gVLizIiyKmlS8yTEHrXoLf7hGCQU7ulmgDoFM66H/s1600/eclipse-git-server-config-step14.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzi4M0-VeP4rxf52Zv09fYnqhhPCLvmsmmiEfuWsUC08R2uO52RuzxO_BSXot6FfvxIr4HBxhAPCmoGI9hsQeJKHLhCM7QQkAsXvq9gVLizIiyKmlS8yTEHrXoLf7hGCQU7ulmgDoFM66H/s1600/eclipse-git-server-config-step14.png&quot; height=&quot;400&quot; width=&quot;366&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
20. New spec added.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsu7wzupZfezk3aT4PhkONaeMDDBydfKOO0WQ2S02lX58JRG_6nxEf2n7jaYH0ji3EX-h_HUc3-dvM7Y6uwziuxVnvBwb1wKt6NPsAQD7SLJ10TupkXsBwX76ItHLdX3O_ZKUFMvNG0SKz/s1600/eclipse-git-server-config-step15.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsu7wzupZfezk3aT4PhkONaeMDDBydfKOO0WQ2S02lX58JRG_6nxEf2n7jaYH0ji3EX-h_HUc3-dvM7Y6uwziuxVnvBwb1wKt6NPsAQD7SLJ10TupkXsBwX76ItHLdX3O_ZKUFMvNG0SKz/s1600/eclipse-git-server-config-step15.png&quot; height=&quot;400&quot; width=&quot;366&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
21. Once finished, the commits you had locally are pushed to the remote repo.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizQFS8B3hwec4DwgBUBwHcKN0SmVRCNAjjRUWtpS8kKMw75L-3rJ4WzciFJ7VfAeoyE_gJhGtS0cI4cal_GpIELGakuQQg2NY738vYVjKn83aX8YGtjWzhYtVW0yKkGJjO71CXeBSACsad/s1600/eclipse-git-server-config-step16.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizQFS8B3hwec4DwgBUBwHcKN0SmVRCNAjjRUWtpS8kKMw75L-3rJ4WzciFJ7VfAeoyE_gJhGtS0cI4cal_GpIELGakuQQg2NY738vYVjKn83aX8YGtjWzhYtVW0yKkGJjO71CXeBSACsad/s1600/eclipse-git-server-config-step16.png&quot; height=&quot;400&quot; width=&quot;366&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Thats it. I have some more stuff on working with Git in Eclipse in this&lt;a href=&quot;http://macgyverdev.blogspot.se/2013/12/clone-github-project-into-eclipse.html&quot;&gt; blogpost about Github cloning&lt;/a&gt;.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
For more advanced Git usage, you might need the console. That&#39;s no problem, simply make sure to refresh the Eclipse project after working in the console since Eclipse must refresh the .git folder etcetera. See this &lt;a href=&quot;http://macgyverdev.blogspot.se/2013/12/git-github-cheat-sheet.html&quot;&gt;Git cheat sheat&lt;/a&gt; for my favourites.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/4213276522865994986/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2014/03/new-eclipse-project-connected-to-git.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/4213276522865994986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/4213276522865994986'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2014/03/new-eclipse-project-connected-to-git.html' title='New Eclipse project connected to Git repository'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVq-N4dacoaQdWGJFl_LuVDITbKFUskVzWT5uMu4xdVZxB_qPF_U-4NNMehEgfYURKje7KXqmvK8XGJ5a4KVVFm6zqGRDPn6sFUvjeV1IFuy0pdeFUXFlYUtkWWnzHyu_qmgn9lANHoR1k/s72-c/eclipse-git-server-config0.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-115705362572801899</id><published>2014-02-18T17:25:00.003+01:00</published><updated>2014-02-18T17:25:43.343+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><title type='text'>Porthello Legends - Android Reversi Port</title><content type='html'>I wrote a clone of the game Reversi/Othello for Android three years ago and it actually made some progress on Google Play (Market as it was called then). It was downloaded nearly 1000 times and a lot of players seems to have enjoyed it because I could see in the highscore lists and the Analytics statistics that they spent quite some time on trying to beat the AI to gain access to even harder levels.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the name Othello Legends was a bad choice since it was trademarked. That meant that after 6 months the game was suspended from Google Play. Since I put quite a lot of effort into the game it is a shame that it disappeared and I have now done a refactoring to the new name &lt;b&gt;Porthello Legends&lt;/b&gt; :-).&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsOEQJdeU8mvB_edtKLhRLQ6hUIajKXjW38o1FhF4vWBfEiS_QEckSzJGJHRm8JkWdSZwTOGWjlyiKHYJhMi472j8g5yGg05b4XopJqvMjwOsK0Z1nvwdyGdTvt_yzKMXw74yZO4Dldpoc/s1600/promosquare.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsOEQJdeU8mvB_edtKLhRLQ6hUIajKXjW38o1FhF4vWBfEiS_QEckSzJGJHRm8JkWdSZwTOGWjlyiKHYJhMi472j8g5yGg05b4XopJqvMjwOsK0Z1nvwdyGdTvt_yzKMXw74yZO4Dldpoc/s1600/promosquare.png&quot; height=&quot;200&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
My Android tablet died last summer and all I got to test with is an pretty old HTC Desire which the game seems to work fine on. It would be interesting to get feedback on how the game performs on newer phones/tablets as well.&lt;br /&gt;
&lt;br /&gt;
Check out the game at Google Play, search for &quot;Porthello Legends&quot; or go to &lt;a href=&quot;https://play.google.com/store/apps/details?id=se.noren.android.porthello&amp;amp;hl=en&quot;&gt;https://play.google.com/store/apps/details?id=se.noren.android.porthello&amp;amp;hl=en&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioJg5-pTwUTfXg8DumAOVKHCc8io7ygP1At6coH7fX0sT4g-WWkPdxv2q75fo3-lAE7akEKUHLE_Ucgds0sGgyiK1A7U5e3WiJUEzKmozrsvP9q66YMkyvoVNgFy1CtGiLf_a74iskf6sd/s1600/P20111211004612.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioJg5-pTwUTfXg8DumAOVKHCc8io7ygP1At6coH7fX0sT4g-WWkPdxv2q75fo3-lAE7akEKUHLE_Ucgds0sGgyiK1A7U5e3WiJUEzKmozrsvP9q66YMkyvoVNgFy1CtGiLf_a74iskf6sd/s1600/P20111211004612.png&quot; height=&quot;320&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The old blogpost on the inital release can be found here &lt;a href=&quot;http://macgyverdev.blogspot.se/2011/12/othello-legends-10-in-android-market.html&quot;&gt;http://macgyverdev.blogspot.se/2011/12/othello-legends-10-in-android-market.html&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/115705362572801899/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2014/02/porthello-legends-android-reversi-port.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/115705362572801899'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/115705362572801899'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2014/02/porthello-legends-android-reversi-port.html' title='Porthello Legends - Android Reversi Port'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsOEQJdeU8mvB_edtKLhRLQ6hUIajKXjW38o1FhF4vWBfEiS_QEckSzJGJHRm8JkWdSZwTOGWjlyiKHYJhMi472j8g5yGg05b4XopJqvMjwOsK0Z1nvwdyGdTvt_yzKMXw74yZO4Dldpoc/s72-c/promosquare.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-8569319472126037202</id><published>2014-02-11T10:04:00.001+01:00</published><updated>2014-02-12T20:34:35.327+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="apache"/><category scheme="http://www.blogger.com/atom/ns#" term="reverse proxy"/><category scheme="http://www.blogger.com/atom/ns#" term="tomcat"/><category scheme="http://www.blogger.com/atom/ns#" term="virtual host"/><title type='text'>Apache web server as reverse proxy and virtual host for Tomcat 7</title><content type='html'>I&#39;m running a couple of sites on a Linux server on my local network. I only have one public ip address but I want to be able to host multiple sites on my servers. So this can be done by using a reverse proxy in front of the application servers which delegates traffic depending on which host name the end user was trying to request.&lt;br /&gt;
&lt;br /&gt;
I&#39;ve implemented this by using the reverse proxy feature with virtual hosts in the Apache HTTP web server.&lt;br /&gt;
The result this exercise is trying to achieve is that external traffic from internet requesting pages from the site &lt;a href=&quot;http://www.all-about-units.com/&quot;&gt;www.all-about-units.com&lt;/a&gt;&amp;nbsp;which is DNS mapped to my public ip address will be routed to the Apache web server on the local network via a port forwarding rule in the router on the local network. The Apache web server will look into its rules for virtual hosts and see that the user requested the domain&amp;nbsp;www.all-about-units.com and therefore delegate the traffic to a separate Apache Tomcat 7 servlet container running on the local network to serve the request. The traffic is then forwarded back through the web server to the end user.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Setup Apache HTTP server as reverse proxy&lt;/h4&gt;
First of all the Apache HTTP web server must be installed. I had mine installed since long ago but if I remember correctly there&#39;s not much than doing this is you have a Debian/Ubuntu/Mint like Linux server&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;screen&quot; style=&quot;background-color: #f0eee6; border: 1pt solid rgb(193, 180, 150); padding: 5px;&quot;&gt;&lt;span class=&quot;command&quot;&gt;&lt;strong&gt;sudo apt-get install apache2&lt;/strong&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Now, to enable the reverse proxy feature of the Apache server&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;screen&quot; style=&quot;background-color: #f0eee6; border: 1pt solid rgb(193, 180, 150); padding: 5px;&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;b&gt;/ $ sudo a2enmod proxy_http&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;
Next, we must create a configuration for our new site as a virtual host. Go to the directory of available sites&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;screen&quot; style=&quot;background-color: #f0eee6; border: 1pt solid rgb(193, 180, 150); padding: 5px;&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;b&gt;/etc/apache2/conf.d $ cd /etc/apache2/sites-available/&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Copy the default configuration to a setup for your site&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;screen&quot; style=&quot;background-color: #f0eee6; border: 1pt solid rgb(193, 180, 150); padding: 5px;&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;b&gt;/etc/apache2/sites-available $ sudo cp default all-about-units&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Lets edit the configuration file. The first line tells the Apache server to listen on port 80, the standard HTTP port. Next the names of the virtual host are given. So traffic requesting another domain name or the ip address directly will not be handled by this virtual host configuration.&lt;br /&gt;
&lt;br /&gt;
Next look att the ProxyPass and ProxyPassReverse, these tell Apache where to forward the request that has matched this virtual host rule. In this case to the Tomcat server on the same machine (127.0.0.1 is the loopback address of localhost) but on port 8080. The slash before the address means that all requests should be forwarded to the &amp;nbsp;Tomcat server. If for example you had &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;ProxyPass /foo/bar/ http://127.0.0.1:8080/&lt;/span&gt; then the request&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt; www.all-about-units.com/foo/bar/page.html&lt;/span&gt; would be redirected to &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;127.0.0.1:8080/page.html&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre class=&quot;screen&quot; style=&quot;background-color: #f0eee6; border: 1pt solid rgb(193, 180, 150); padding: 5px;&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;b&gt;/etc/apache2/sites-available $ sudo vim all-about-units&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;screen&quot; style=&quot;background-color: #f0eee6; border: 1pt solid rgb(193, 180, 150); padding: 5px;&quot;&gt;&lt;div style=&quot;white-space: normal;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;lt;VirtualHost *:80&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;nbsp; ServerName all-about-units.com&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;nbsp; ServerAlias www.all-about-units.com&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;nbsp; ProxyRequests Off&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;nbsp; ProxyPreserveHost On&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;lt;Proxy *&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; Order deny,allow&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; Allow from all&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;lt;/Proxy&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;nbsp; ProxyPass / http://127.0.0.1:8080/&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;nbsp; ProxyPassReverse / http://127.0.0.1:8080/&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;lt;/VirtualHost&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; white-space: normal;&quot;&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;h4&gt;
Enable and disable the site&lt;/h4&gt;
To tell the Apache HTTP web server to enable this configuration, run the a2ensite command on the name of the new configuration&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre class=&quot;screen&quot; style=&quot;background-color: #f0eee6; border: 1pt solid rgb(193, 180, 150); padding: 5px;&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;b&gt;/etc/apache2/sites-available $ sudo a2ensite all-about-units&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;screen&quot; style=&quot;background-color: #f0eee6; border: 1pt solid rgb(193, 180, 150); padding: 5px;&quot;&gt;&lt;div style=&quot;white-space: normal;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;Enabling site all-about-units.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;white-space: normal;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;To activate the new configuration, you need to run:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;white-space: normal;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;nbsp; service apache2 reload&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Reload Apache&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;screen&quot; style=&quot;background-color: #f0eee6; border: 1pt solid rgb(193, 180, 150); padding: 5px;&quot;&gt;&lt;div style=&quot;white-space: normal;&quot;&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;/etc/apache2/sites-available $ sudo service apache2 reload&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;* Reloading web server config &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; white-space: normal;&quot;&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
I had some issues so I restarted Apache the hard way also and then it works.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;screen&quot; style=&quot;background-color: #f0eee6; border: 1pt solid rgb(193, 180, 150); padding: 5px;&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;b&gt;/etc/apache2/sites-available $ &amp;nbsp;sudo /etc/init.d/apache2 restart&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;screen&quot; style=&quot;background-color: #f0eee6; border: 1pt solid rgb(193, 180, 150); padding: 5px;&quot;&gt;&lt;div style=&quot;white-space: normal;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;nbsp;* Restarting web server apache2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;apache2: Could not reliably determine the server&#39;s fully qualified domain name, using 127.0.1.1 for ServerName&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;nbsp;... waiting apache2: Could not reliably determine the server&#39;s fully qualified domain name, using 127.0.1.1 for ServerName&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; white-space: normal;&quot;&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
That&#39;s it!&lt;br /&gt;
&lt;br /&gt;
Verify in the logs of the application server that the request are directed correct and your home.&lt;br /&gt;
Next step might be to enable the mod cache feature of Apache to let the web server handle caching of all static material served by the application server like css, images and javascript. More on that in another post.&lt;br /&gt;
&lt;br /&gt;
If you for some reason want to take the site of the web for some time you can instead of stopping the application server disable the site in the web server virtual host forwarding by using the command&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;screen&quot; style=&quot;background-color: #f0eee6; border: 1pt solid rgb(193, 180, 150); padding: 5px;&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;b&gt;sudo a2dissite all-about-units&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/8569319472126037202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2014/02/apache-web-server-as-reverse-proxy-and.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/8569319472126037202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/8569319472126037202'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2014/02/apache-web-server-as-reverse-proxy-and.html' title='Apache web server as reverse proxy and virtual host for Tomcat 7'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-4809416386239997127</id><published>2014-02-04T22:17:00.002+01:00</published><updated>2014-02-17T09:41:23.413+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jenkins"/><category scheme="http://www.blogger.com/atom/ns#" term="tomcat"/><title type='text'>How to make Jenkins install the packaged war in a Tomcat 7</title><content type='html'>This is a sequel to&amp;nbsp;&lt;a href=&quot;http://macgyverdev.blogspot.se/2014/01/setup-jenkins-project-from-git.html&quot;&gt;http://macgyverdev.blogspot.se/2014/01/setup-jenkins-project-from-git.html&lt;/a&gt;&amp;nbsp;where I set up Jenkins to build my latest project. The next step is to install the war-file built by Jenkins on my Tomcat 7 server.&lt;br /&gt;
&lt;br /&gt;
First of all we must make sure Tomcat accepts installations by scripting instead of the human html GUI version. In the &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;tomcat-users.xml&lt;/span&gt; file, located in something similar to this:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;/var/lib/tomcat7/conf/tomcat-users.xml&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Make sure that the admin user, whatever his name is, has the role &lt;i&gt;manager-script&lt;/i&gt;. Here&#39;s the important part of my file:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;tomcat-users&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;role rolename=&quot;manager-gui&quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;role rolename=&quot;manager-script&quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;role rolename=&quot;manager&quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;role rolename=&quot;admin-gui&quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;role rolename=&quot;admin-script&quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;role rolename=&quot;admin&quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;user username=&quot;admin&quot; password=&quot;somethignsecret&quot; roles=&quot;manager-gui,admin-gui,manager,admin,manager-script,admin-script&quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;/tomcat-users&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Now, in Jenkins you must install the&lt;i&gt; Deploy Plugin&lt;/i&gt;. You find it in the plugins section.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhovbLI0z42XH2iTwe4CKCClwh4MfMACAj6d2hGRqg-XDUK72biWCBO1fN3S4a8YMix5PaQCq0_KFjgRP0J0ME7_1lTUY25hF0EJ3UP0nK9i2Q-3ItQafbcrDE8QuqssVG01WdVCRoReBkd/s1600/deploy-plugin.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhovbLI0z42XH2iTwe4CKCClwh4MfMACAj6d2hGRqg-XDUK72biWCBO1fN3S4a8YMix5PaQCq0_KFjgRP0J0ME7_1lTUY25hF0EJ3UP0nK9i2Q-3ItQafbcrDE8QuqssVG01WdVCRoReBkd/s1600/deploy-plugin.png&quot; height=&quot;460&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
Your Jenkins job is here assumed to be configured to package a war file. You can verify this by inspecting that a build generates a war file like this:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;~/.jenkins/jobs/UnitConversion/workspace/target/Unitconversion.war&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
For this Jenkins job, go to the settings page and add a new post-build action. Choose the &quot;Deploy war/ear to a container&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaLQ1S0GiLsVV01oF4Be02FesvfWxly2-yCj7ztDZMZOKnJLS9qw3zYbG3ELmaSBTA1r3G_fwN2YK9QFJ4jLLxFtLWRXOqhK2jD4CtydrlAsDLW7xiWoISx3Rd-1ywZNTn3T8GTDAA9knm/s1600/new-post-build-action.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaLQ1S0GiLsVV01oF4Be02FesvfWxly2-yCj7ztDZMZOKnJLS9qw3zYbG3ELmaSBTA1r3G_fwN2YK9QFJ4jLLxFtLWRXOqhK2jD4CtydrlAsDLW7xiWoISx3Rd-1ywZNTn3T8GTDAA9knm/s1600/new-post-build-action.png&quot; height=&quot;293&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
In this view make sure the path to the packaged war is relative to the workspace area of the job. Most probably it will be &quot;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;target/yourapp.war&lt;/span&gt;&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG6CinkpAfa18X59sLeCzOEbFAkN0DFUOig793jHEKwX5OUNm7W13CAn70cx5ouvjl3jdzDY5h1TyCvdar1YAyGJ1tWeKNdwnnkpQ5wjocYKhNVHIrQarHNBOs3OfvMTaagmy9493_Nyco/s1600/post-build-action.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG6CinkpAfa18X59sLeCzOEbFAkN0DFUOig793jHEKwX5OUNm7W13CAn70cx5ouvjl3jdzDY5h1TyCvdar1YAyGJ1tWeKNdwnnkpQ5wjocYKhNVHIrQarHNBOs3OfvMTaagmy9493_Nyco/s1600/post-build-action.png&quot; height=&quot;292&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now, rebuild your job and when inspecting the console logs you should see that the war/ear is installed!&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: white; font-size: 11px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;Deploying /home/johan/.jenkins/jobs/UnitConversion/workspace/target/Unitconversion.war to container Tomcat 7.x Remote
  Redeploying [/home/johan/.jenkins/jobs/UnitConversion/workspace/target/Unitconversion.war]
  Undeploying [/home/johan/.jenkins/jobs/UnitConversion/workspace/target/Unitconversion.war]
  Deploying [/home/johan/.jenkins/jobs/UnitConversion/workspace/target/Unitconversion.war]
Finished: SUCCESS&lt;/pre&gt;
&lt;br /&gt;
This way it takes two clicks from editing the code in Eclipse to update the site&lt;a href=&quot;http://www.all-about-units.com/&quot;&gt; All About Units&lt;/a&gt; in production, first commit and push to Git, second start the Jenkins job.&lt;br /&gt;
&lt;br /&gt;
One note, if you have deployed your application with context root &quot;/&quot; in Tomcat as I have done, see&amp;nbsp;&lt;a href=&quot;http://macgyverdev.blogspot.se/2014/02/how-to-change-context-root-to-in-tomcat.html&quot;&gt;http://macgyverdev.blogspot.se/2014/02/how-to-change-context-root-to-in-tomcat.html&lt;/a&gt;, you can not have Context path = &quot;/&quot; in the configuration above. Instead, keep multiple context roots in Tomcat, and as in my example add the context root with a longer name, otherwise the deploy plugin cannot undeploy the ROOT web application. If you according to my blog post on it has manipulated the server.xml a reinstallation of &quot;/webappname&quot; will also reinstall the ROOT application since they point to the same directory on disk.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/4809416386239997127/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2014/02/how-to-make-jenkins-install-packaged.html#comment-form' title='28 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/4809416386239997127'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/4809416386239997127'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2014/02/how-to-make-jenkins-install-packaged.html' title='How to make Jenkins install the packaged war in a Tomcat 7'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhovbLI0z42XH2iTwe4CKCClwh4MfMACAj6d2hGRqg-XDUK72biWCBO1fN3S4a8YMix5PaQCq0_KFjgRP0J0ME7_1lTUY25hF0EJ3UP0nK9i2Q-3ItQafbcrDE8QuqssVG01WdVCRoReBkd/s72-c/deploy-plugin.png" height="72" width="72"/><thr:total>28</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-7197233074462014193</id><published>2014-02-04T20:55:00.000+01:00</published><updated>2014-02-12T12:44:08.089+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="tomcat"/><title type='text'>How to change context root to / in Tomcat 7</title><content type='html'>Here&#39;s my problem, I have a new project going which will be deployed as &lt;a href=&quot;http://www.all-about-units.com/en&quot;&gt;http://www.all-about-units.com/en&lt;/a&gt;. It&#39;s a site for general facts and info about units. It&#39;s a&amp;nbsp;Java web application running on a Tomcat 7 servlet container. It is automatically deployed to the context root &quot;Unitconversion&quot; since that is the name of the WAR-file when it is uploaded via the admin ui.&lt;br /&gt;
That means I will access it as&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;http://myserver:port/Unitconversion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I want it to be deployed as context root &quot;/&quot; so that the URL becomes this in production&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;http://myserver:port/&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
My Tomcat 7 is running on a Linux Mint server but I guess these instructions are the same regardless of operating system. Here&#39;s how I managed to get it working.&lt;br /&gt;
&lt;br /&gt;
First I uploaded my new web application in the Tomcat manager admin GUI. We got something like this now.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs79Mp76urwGNytPEVmUKNpbNLP9vX1UPIEyhz30BQaxpWvJelnKb0CR6ScZOkWJpPRae0c-mMIPSq2kRqnnSFug_MDi3OuchFTBsPgGUbyl67_91wLNmwliaiWOQZQlOYgpGnNyuQmHr5/s1600/tomcat-7-manager-before.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs79Mp76urwGNytPEVmUKNpbNLP9vX1UPIEyhz30BQaxpWvJelnKb0CR6ScZOkWJpPRae0c-mMIPSq2kRqnnSFug_MDi3OuchFTBsPgGUbyl67_91wLNmwliaiWOQZQlOYgpGnNyuQmHr5/s1600/tomcat-7-manager-before.png&quot; height=&quot;468&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now, if you inspect the file system you should have your app deployed at &amp;nbsp;/var/lib/tomcat7/webapps.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@johanhtpc /var/lib/tomcat7/webapps $ ll&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;total 31040&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;drwxrwxr-x &amp;nbsp;5 tomcat7 tomcat7 &amp;nbsp; &amp;nbsp; 4096 feb &amp;nbsp;4 20:22 .&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;drwxr-xr-x &amp;nbsp;6 root &amp;nbsp; &amp;nbsp;root &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4096 dec 18 19:25 ..&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;drwxr-xr-x &amp;nbsp;3 root &amp;nbsp; &amp;nbsp;root &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4096 dec 18 19:25 ROOT&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;drwxr-xr-x 10 tomcat7 tomcat7 &amp;nbsp; &amp;nbsp; 4096 feb &amp;nbsp;4 20:22 Unitconversion&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;-rw-r--r-- &amp;nbsp;1 tomcat7 tomcat7 23617897 feb &amp;nbsp;4 20:22 Unitconversion.war&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;drwxr-xr-x &amp;nbsp;8 tomcat7 tomcat7 &amp;nbsp; &amp;nbsp; 4096 dec 28 12:44 WeatherStationServer&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;-rw-r--r-- &amp;nbsp;1 tomcat7 tomcat7 &amp;nbsp;8140647 dec 28 12:44 WeatherStationServer.war&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The hacky way now would be to change the ROOT application with my new code, a simple overwrite with my web app. But that doesn&#39;t smell so good...&lt;br /&gt;
&lt;br /&gt;
So what you do is that you edit&lt;br /&gt;
&lt;br /&gt;
/var/lib/tomcat7/conf/server.xml&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
and add these lines inside the &amp;lt;Host&amp;gt; element. Change &quot;Unitconversion&quot; to your application name.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;Context path=&quot;&quot; docBase=&quot;Unitconversion&quot;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;!-- Default set of monitored resources --&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;WatchedResource&amp;gt;WEB-INF/web.xml&amp;lt;/WatchedResource&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;/Context&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;Context path=&quot;ROOT&quot; docBase=&quot;ROOT&quot;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;!-- Default set of monitored resources --&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;WatchedResource&amp;gt;WEB-INF/web.xml&amp;lt;/WatchedResource&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;/Context&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This will make the default root application appear under context root &quot;/ROOT&quot;.&lt;/div&gt;
&lt;div&gt;
Restart Tomcat to make changes take place.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sudo /etc/init.d/tomcat7 restart&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
And now the app is accessible at &quot;/&quot; and at the old context root &quot;Unitconversion&quot; as well. This is also seen in the GUI if you refresh the manager.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLPgUXVk_oN-sMppq3ZrhnObWJkY5y5kzvK3jHTIOrxfFRnjfceSkOyAeexzVl6JAyKSEiFuuxgNnT1RoI6gsK5Pmwn9gRXoxuoa0kUp8Q62l1q5hvQMWtvtfcz7QjW9Pn950eGYjmjsNb/s1600/tomcat-7-manager-after.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLPgUXVk_oN-sMppq3ZrhnObWJkY5y5kzvK3jHTIOrxfFRnjfceSkOyAeexzVl6JAyKSEiFuuxgNnT1RoI6gsK5Pmwn9gRXoxuoa0kUp8Q62l1q5hvQMWtvtfcz7QjW9Pn950eGYjmjsNb/s1600/tomcat-7-manager-after.png&quot; height=&quot;502&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/7197233074462014193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2014/02/how-to-change-context-root-to-in-tomcat.html#comment-form' title='29 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/7197233074462014193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/7197233074462014193'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2014/02/how-to-change-context-root-to-in-tomcat.html' title='How to change context root to / in Tomcat 7'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs79Mp76urwGNytPEVmUKNpbNLP9vX1UPIEyhz30BQaxpWvJelnKb0CR6ScZOkWJpPRae0c-mMIPSq2kRqnnSFug_MDi3OuchFTBsPgGUbyl67_91wLNmwliaiWOQZQlOYgpGnNyuQmHr5/s72-c/tomcat-7-manager-before.png" height="72" width="72"/><thr:total>29</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-5420915271495714172</id><published>2014-01-28T09:13:00.000+01:00</published><updated>2014-02-28T09:15:50.996+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="java 8"/><category scheme="http://www.blogger.com/atom/ns#" term="lambda expressions"/><title type='text'>Java 8 in Eclipse</title><content type='html'>Have you tried out Java 8 yet? The official release is not until March 2014 but there have been a set of release candidates to play with. It is actually very easy to get up and running.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Download a JDK 8 snapshot from&amp;nbsp;&lt;a href=&quot;https://jdk8.java.net/&quot;&gt;https://jdk8.java.net/&lt;/a&gt;&amp;nbsp;and install it.&lt;/li&gt;
&lt;li&gt;Install a version of Eclipse that can handle Java 8 syntax. I downloaded Eclipse Luna 4.4 from &lt;a href=&quot;http://downloads.efxclipse.org/eclipse-java8/2013-05-19/&quot;&gt;http://downloads.efxclipse.org/eclipse-java8/2013-05-19/&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
To get started, create a new project in Eclipse and make sure you have chosen the Java 8 JRE.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikpl151cy6YxJjH5YVvBXA9P79ti0dG7TLSJhw0EJjTw2pjkjxEasEJYK1yEbYqG29_aTeqV3OpiWdNuivUwbgj62REwUO2lYKYLAcUit5LQS-a3vKJkxqTc9SRThyGctm3h78d_MB0ph9/s1600/newproj.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikpl151cy6YxJjH5YVvBXA9P79ti0dG7TLSJhw0EJjTw2pjkjxEasEJYK1yEbYqG29_aTeqV3OpiWdNuivUwbgj62REwUO2lYKYLAcUit5LQS-a3vKJkxqTc9SRThyGctm3h78d_MB0ph9/s1600/newproj.png&quot; height=&quot;320&quot; width=&quot;299&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Here&#39;s a class that uses a lambda expression to instantiate the functional interface PowerCalculator. A functional interface is an interface with only one abstract method.&lt;/div&gt;
&lt;div&gt;
&lt;table border=&quot;0&quot; style=&quot;font-family: sans-serif; width: 100%px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td valign=&quot;top&quot; width=&quot;45%&quot;&gt;&lt;br /&gt;
&lt;div style=&quot;overflow: auto;&quot;&gt;
&lt;pre style=&quot;background-color: white;&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;class&lt;/span&gt; TestClass &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;

    &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;interface&lt;/span&gt; PowerCalculator &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: #bb7977;&quot;&gt;int&lt;/span&gt; pow&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #bb7977;&quot;&gt;int&lt;/span&gt; n&lt;span style=&quot;color: #808030;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #bb7977;&quot;&gt;int&lt;/span&gt; exponent&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;

    &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #bb7977;&quot;&gt;void&lt;/span&gt; main&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #bb7977; font-weight: bold;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;]&lt;/span&gt; args&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;final&lt;/span&gt; PowerCalculator calc &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #bb7977;&quot;&gt;int&lt;/span&gt; n&lt;span style=&quot;color: #808030;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #bb7977;&quot;&gt;int&lt;/span&gt; exponent&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
            &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #bb7977;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #bb7977; font-weight: bold;&quot;&gt;Math&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;pow&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;n&lt;span style=&quot;color: #808030;&quot;&gt;,&lt;/span&gt; exponent&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
        
        &lt;span style=&quot;color: #bb7977;&quot;&gt;int&lt;/span&gt; product &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; calc&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;pow&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #008c00;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #008c00;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #bb7977; font-weight: bold;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;out&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;println&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;product&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div&gt;
This outputs the expected &quot;81&quot;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
That was maybe not very cool, but when looking into the more functional style of programming you can do with lambda expressions, this is the most interesting Java upgrade since Java 5 in my opinion.&lt;br /&gt;
I wrote an article in 2012 on FP in Java&amp;nbsp;&lt;a href=&quot;http://macgyverdev.blogspot.se/2012/10/functional-programming-in-java.html&quot;&gt;http://macgyverdev.blogspot.se/2012/10/functional-programming-in-java.html&lt;/a&gt;&amp;nbsp;and took a quick look now again to see whether the original spec still is valid.&lt;br /&gt;
&lt;br /&gt;
Here is a few examples I tried on the Collections framework. There has been changes since the 2012 draft. For example is the &lt;a href=&quot;http://download.java.net/jdk8/docs/api/java/util/stream/Stream.html&quot;&gt;stream() interface&lt;/a&gt; added, previously you could do a filter() directly on the collection. The stream interface allows for parallel execution and&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;class&lt;/span&gt; TestClass &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;

    &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #bb7977;&quot;&gt;void&lt;/span&gt; main&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #bb7977; font-weight: bold;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;]&lt;/span&gt; args&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
     &lt;span style=&quot;color: #bb7977; font-weight: bold;&quot;&gt;List&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;lt;&lt;/span&gt;Animal&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt; animals &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; Arrays&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;asList&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;new&lt;/span&gt; Animal&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #008c00;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;new&lt;/span&gt; Animal&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #008c00;&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;new&lt;/span&gt; Animal&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #008c00;&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;new&lt;/span&gt; Animal&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #008c00;&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
     
     &lt;span style=&quot;color: dimgrey;&quot;&gt;// Each animal eats another calorie&lt;/span&gt;
     animals&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;forEach&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;a &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt; a&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;eat&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #008c00;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
     
     &lt;span style=&quot;color: dimgrey;&quot;&gt;// Print animal&lt;/span&gt;
     animals&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;forEach&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;a &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt; a&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;print&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
     
     &lt;span style=&quot;color: dimgrey;&quot;&gt;// Print only the animals which have more than 30 calories&lt;/span&gt;
     animals&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;stream&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;
            &lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;filter&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;a &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt; a&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;nutrition&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #008c00;&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;
            &lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;forEach&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;a &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt; a&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;print&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
     
     &lt;span style=&quot;color: dimgrey;&quot;&gt;// Calculate total sum of all animals calories&lt;/span&gt;
     &lt;span style=&quot;color: #bb7977;&quot;&gt;int&lt;/span&gt; sum &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; animals&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;stream&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;
                      &lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;mapToInt&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;a &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt; a&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;nutrition&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;
                      &lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;sum&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;

&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;class&lt;/span&gt; Animal &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
 &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #bb7977;&quot;&gt;int&lt;/span&gt; calories &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008c00;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
 
 &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;public&lt;/span&gt; Animal&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #bb7977;&quot;&gt;int&lt;/span&gt; calories&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;calories &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; calories&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
 &lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;
 
 &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #bb7977;&quot;&gt;void&lt;/span&gt; eat&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #bb7977;&quot;&gt;int&lt;/span&gt; calories&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;calories &lt;span style=&quot;color: #808030;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; calories&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
 &lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt; 

 &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #bb7977;&quot;&gt;void&lt;/span&gt; print&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #bb7977; font-weight: bold;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;out&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;println&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;&quot;Calories: &quot;&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;+&lt;/span&gt; calories&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
 &lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt; 

 &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #bb7977;&quot;&gt;int&lt;/span&gt; nutrition&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;return&lt;/span&gt; calories&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
 &lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;
&lt;/pre&gt;
&lt;pre&gt;
&lt;/pre&gt;
&lt;pre&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; white-space: normal;&quot;&gt;The Eclipse support in Luna 4.4 is pretty good. But when using the command completition it is not obvious what the different lamda expression consumers expect. I guess once you have played around with it some more you get accustomed to the Predicate and Consumer APIs.&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/5420915271495714172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2014/01/java-8-in-eclipse.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/5420915271495714172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/5420915271495714172'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2014/01/java-8-in-eclipse.html' title='Java 8 in Eclipse'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikpl151cy6YxJjH5YVvBXA9P79ti0dG7TLSJhw0EJjTw2pjkjxEasEJYK1yEbYqG29_aTeqV3OpiWdNuivUwbgj62REwUO2lYKYLAcUit5LQS-a3vKJkxqTc9SRThyGctm3h78d_MB0ph9/s72-c/newproj.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-698981819985465844</id><published>2014-01-24T19:33:00.000+01:00</published><updated>2014-02-17T09:42:08.205+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="checkstyle"/><category scheme="http://www.blogger.com/atom/ns#" term="cobertura"/><category scheme="http://www.blogger.com/atom/ns#" term="findbugs"/><category scheme="http://www.blogger.com/atom/ns#" term="git"/><category scheme="http://www.blogger.com/atom/ns#" term="jenkins"/><category scheme="http://www.blogger.com/atom/ns#" term="maven"/><category scheme="http://www.blogger.com/atom/ns#" term="pom"/><title type='text'>Setup Jenkins project from Git repository with Findbugs, Cobertura and Checkstyle</title><content type='html'>&lt;div&gt;
I created a Jenkins setup for my current Java hobby project (a site on physical units intended to make ads money, check it out at &lt;a href=&quot;http://www.all-about-units.com/&quot;&gt;http://www.all-about-units.com&lt;/a&gt;) yesterday and noticed that my&amp;nbsp;&lt;a href=&quot;http://macgyverdev.blogspot.se/2011/04/hudson-continous-integration-for-google.html&quot;&gt;old note&lt;/a&gt;&amp;nbsp;on how to setup Jenkins (then it was written for Hudson) is a bit out of date. The Jenkins configuration menues for generating Findbugs static analysis, Cobertura code coverage and Checkstyle format control were completely new. In addition to that, I&#39;ve migrated to Git since then so there are a few steps also involved in getting Git running as code repository within Jenkins.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Here&#39;s a workflow for setting up Jenkins with these features.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;h3&gt;
Install Jenkins and plugins&lt;/h3&gt;
&lt;div&gt;
First of all, if you haven&#39;t installed Jenkins the easiest way is to download the war archive from&amp;nbsp;&lt;a href=&quot;http://jenkins-ci.org/&quot;&gt;http://jenkins-ci.org/&lt;/a&gt;. This article is based on Jenkins version 1.532.1. You can install in in a server container like Tomcat or Jetty, but the easiest way to get started is to run it from the command line like&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;java -jar jenkins.war&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I created a small bash script which also changes the port since I have another server using the default 8080 port.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;#!/bin/sh&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;nohup java -jar jenkins.war --httpPort=8081&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So now you can access Jenkins via &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;http://localhost:8081&lt;/span&gt; or similar.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now we must install some plugins which are not part of the core distribution. Go to the settings of Jenkins and find the Plugins section.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_-X-PsHTxqIknuMyfwhQVpCE3mJvNEN_qlwMvFBDGFTtj48sQfl190-D1PGa2LWa547KGMh8sFm7o2ZMHddOv6_yzGOVIvJxdgrZtN9zmgXD8nCPVJDHOegPGdjtgIDckZsMwekg1T5zQ/s1600/managejenkins.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_-X-PsHTxqIknuMyfwhQVpCE3mJvNEN_qlwMvFBDGFTtj48sQfl190-D1PGa2LWa547KGMh8sFm7o2ZMHddOv6_yzGOVIvJxdgrZtN9zmgXD8nCPVJDHOegPGdjtgIDckZsMwekg1T5zQ/s1600/managejenkins.png&quot; height=&quot;320&quot; width=&quot;264&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrh5swG0Qs9Vk16q6-2PZNCNG3j-pFIIzmghcVClcLNlqCkVLnVQBgu3oF8Pi3DfQ0z5XN_xM4zwQECT4hZQELnFQ3husloZzuMGycD3cBJDmd9gJM9Mzxwup8bguRaemuEMd5jTy6hYS9/s1600/manageplugins.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrh5swG0Qs9Vk16q6-2PZNCNG3j-pFIIzmghcVClcLNlqCkVLnVQBgu3oF8Pi3DfQ0z5XN_xM4zwQECT4hZQELnFQ3husloZzuMGycD3cBJDmd9gJM9Mzxwup8bguRaemuEMd5jTy6hYS9/s1600/manageplugins.png&quot; height=&quot;336&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Here you should at least find the following plugs and install them&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMZq0Q-dMUDAK6w4Kbu1Sup6zxPdXYKi0Lg3ZetkhOwNBzuyvKI_CGgj89DAzRj3-VJY4E23ZNXTJAPjMt4lL39FGDQBxOIaaJrsXkLBTPv_2m_FKLHIdpYlTV5gwYn1kVeS086nQ4-Daj/s1600/checkstyleplugin.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMZq0Q-dMUDAK6w4Kbu1Sup6zxPdXYKi0Lg3ZetkhOwNBzuyvKI_CGgj89DAzRj3-VJY4E23ZNXTJAPjMt4lL39FGDQBxOIaaJrsXkLBTPv_2m_FKLHIdpYlTV5gwYn1kVeS086nQ4-Daj/s1600/checkstyleplugin.png&quot; height=&quot;88&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2_Uw8kV48tIhgAFywuyjKRr_ribkBTBvknd6FHcozeNUVHfrgz8qXZ38omCy-aRXROg6f-9lZ9basanWpq44BLXm9obiQny86FLt8hlsFAoDfjrsb8MgdSgc1P8VsJ8ylk2t_4nTn2W4f/s1600/gitplugin.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2_Uw8kV48tIhgAFywuyjKRr_ribkBTBvknd6FHcozeNUVHfrgz8qXZ38omCy-aRXROg6f-9lZ9basanWpq44BLXm9obiQny86FLt8hlsFAoDfjrsb8MgdSgc1P8VsJ8ylk2t_4nTn2W4f/s1600/gitplugin.png&quot; height=&quot;233&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhw95HWqhBEjMt2GeiXZbr4H5k6Fj_HRNKJlqrxYofvinW4IDxREEFqmxNRoWWkdk0lIwoAGfeIVDmTvzPq32rL2fkn7NnIbvjO85jADuMwlAJf8XEAyMcWuxoI37_ayLBP1dfc044v5nxQ/s1600/staticcodeplugin.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhw95HWqhBEjMt2GeiXZbr4H5k6Fj_HRNKJlqrxYofvinW4IDxREEFqmxNRoWWkdk0lIwoAGfeIVDmTvzPq32rL2fkn7NnIbvjO85jADuMwlAJf8XEAyMcWuxoI37_ayLBP1dfc044v5nxQ/s1600/staticcodeplugin.png&quot; height=&quot;86&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Creating Jenkins job&lt;/span&gt;&lt;/h3&gt;
&lt;div&gt;
Create a new Jenkins job. My project handles its dependencies via Maven 3 which suits Jenkins very well. Choose the Maven 2/3 option.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgg7SgiD848cn49IBA3Udxhname7JWKkzzz4jdmTC69QOSzDHn_8LrYILqps_DNHjAtDEcfpKI4d6_GaHRrK5_j2OIQ8gsdx2jw_Wv9nV2zh7aSG4b1T9W3CBBaf3h1b-3qMPhm-GIQVTxq/s1600/newjobmaven.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgg7SgiD848cn49IBA3Udxhname7JWKkzzz4jdmTC69QOSzDHn_8LrYILqps_DNHjAtDEcfpKI4d6_GaHRrK5_j2OIQ8gsdx2jw_Wv9nV2zh7aSG4b1T9W3CBBaf3h1b-3qMPhm-GIQVTxq/s1600/newjobmaven.png&quot; height=&quot;219&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In the next step, choose Git as SCM. If you have your Git repository on the same server as Jenkins you can simply add the file path to the repository. Otherwise you setup the security credentials here as well. Also, choose if you want to build &lt;i&gt;master &lt;/i&gt;or some other branch.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh61QmHUJiI5R8kko8pOE5FzNvflc1G_IBF6rpPqWoSCTv7a8bH9q3PM9ABXNaLz1jliNEj90iKSseJIICiDKWfVuZ2XZT1oisdW88YQGDmuwhg9xDVtKS8eLSFyea1dhSpQgcfFQZzIJPY/s1600/setupgit.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh61QmHUJiI5R8kko8pOE5FzNvflc1G_IBF6rpPqWoSCTv7a8bH9q3PM9ABXNaLz1jliNEj90iKSseJIICiDKWfVuZ2XZT1oisdW88YQGDmuwhg9xDVtKS8eLSFyea1dhSpQgcfFQZzIJPY/s1600/setupgit.png&quot; height=&quot;529&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
We haven&#39;t talked about the pom.xml for the project yet, but it will be configured to use some Maven goals. So in the Maven goals section, add goals for &lt;i&gt;test package site&lt;/i&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKAoirZfM20HBHfV6tYDPXM3suvffKYDWqOvj1QlG_SkB_D7LgVabt5tqGVBHeLzzbJ994lOPhlzwAXYp0xGX7unMorZc0R0rWh_0qzWp2PotE8rc8ujmsrJqg7mtHQJZrrcCQJk17DG_D/s1600/goals.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKAoirZfM20HBHfV6tYDPXM3suvffKYDWqOvj1QlG_SkB_D7LgVabt5tqGVBHeLzzbJ994lOPhlzwAXYp0xGX7unMorZc0R0rWh_0qzWp2PotE8rc8ujmsrJqg7mtHQJZrrcCQJk17DG_D/s1600/goals.png&quot; height=&quot;51&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
Under Build settings, check the boxes for&amp;nbsp;&lt;i&gt;Publish Checkstyle analysis results&lt;/i&gt;,&amp;nbsp;&lt;i&gt;Publish FindBugs analysis results&lt;/i&gt; and&amp;nbsp;&lt;i&gt;Publish duplicate code analysis results&lt;/i&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZswONcDVJ4BmCnudSGjTIBqANHEUiwuTtZ3W_J3P6TV842WJMb4WnxLGqwoF7RwxG9LTfazovke6cUwpUdG42zxEkmhcdDpq4Y3a2eSHvvcCsoFRZufoIq30Y3bce7ZMDuLJHJdoyMnFh/s1600/buildsettings.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZswONcDVJ4BmCnudSGjTIBqANHEUiwuTtZ3W_J3P6TV842WJMb4WnxLGqwoF7RwxG9LTfazovke6cUwpUdG42zxEkmhcdDpq4Y3a2eSHvvcCsoFRZufoIq30Y3bce7ZMDuLJHJdoyMnFh/s1600/buildsettings.png&quot; height=&quot;231&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In the Post-build Actions add a step for Cobertura reporting.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVHiAfTcJD6z05S047ppVv3_TBOhnYZOZ_jelEM8xPekTkMx_QNCsIcg1Ls98P8ds_-KWwSk97V7l2K7WhlAYefI-zVQLbptk1A3prqbs0ZOqKEeTuJN8Vussn3Eg_IkztHRUPkTclPNR6/s1600/postbuildstep.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVHiAfTcJD6z05S047ppVv3_TBOhnYZOZ_jelEM8xPekTkMx_QNCsIcg1Ls98P8ds_-KWwSk97V7l2K7WhlAYefI-zVQLbptk1A3prqbs0ZOqKEeTuJN8Vussn3Eg_IkztHRUPkTclPNR6/s1600/postbuildstep.png&quot; height=&quot;127&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Maven will generate the Cobertura report to the Jenkins workspace under path&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;/target/site/cobertura/coverage.xml&lt;/span&gt; so add this in the configuration of the action.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHyQx5lO7nQb2I-a0-XuNBsGHufXhmFaZeh1zRJDV6XDZ9ao5GTCZQDVJbRmlGfVEJe9X7ripxKbQI9hPTnYLl69cA5ZKVJOgYLIV46v9gJujWmu6r_YxZRH7KYtyzrtx1Q5UcF5gOzDKh/s1600/postbuildconfig.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHyQx5lO7nQb2I-a0-XuNBsGHufXhmFaZeh1zRJDV6XDZ9ao5GTCZQDVJbRmlGfVEJe9X7ripxKbQI9hPTnYLl69cA5ZKVJOgYLIV46v9gJujWmu6r_YxZRH7KYtyzrtx1Q5UcF5gOzDKh/s1600/postbuildconfig.png&quot; height=&quot;148&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now you should have a Jenkins job setup ready for building.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwvFCHXslvvBj5idRdK0Vs-VUHFWm1hm4lGWrTyWWMA8iDVuwwbWEdBZVw4QGsGgcjXKcEKTrAbZ64pXn5Zfmi4UHSacWG0xT_hxufcBNaWPN7FIpOKNpK0PY68RNScPdwhgL8lYGITRFk/s1600/afterconfig.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwvFCHXslvvBj5idRdK0Vs-VUHFWm1hm4lGWrTyWWMA8iDVuwwbWEdBZVw4QGsGgcjXKcEKTrAbZ64pXn5Zfmi4UHSacWG0xT_hxufcBNaWPN7FIpOKNpK0PY68RNScPdwhgL8lYGITRFk/s1600/afterconfig.png&quot; height=&quot;372&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Before building we must make sure the&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt; pom.xml&lt;/span&gt; of the project has the correct plugins and reports configured.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
Maven pom.xml configuration&lt;/h3&gt;
&lt;div&gt;
After all the dependency specifications in the pom.xml add something similar to this. In this setup Cobertura is configured in the package phase and that&#39;s why we added that Maven goal above. If you hadn&#39;t added this in the pom file, you could have added separate Maven goals for Cobertura in Jenkins as well.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;build&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;finalName&amp;gt;Unitconversion&amp;lt;/finalName&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;plugins&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;plugin&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;groupId&amp;gt;org.codehaus.mojo&amp;lt;/groupId&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;artifactId&amp;gt;findbugs-maven-plugin&amp;lt;/artifactId&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;version&amp;gt;${findbugs.version}&amp;lt;/version&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/plugin&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;plugin&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;groupId&amp;gt;org.codehaus.mojo&amp;lt;/groupId&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;artifactId&amp;gt;cobertura-maven-plugin&amp;lt;/artifactId&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;version&amp;gt;${cobertura.version}&amp;lt;/version&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;configuration&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;formats&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;format&amp;gt;xml&amp;lt;/format&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/formats&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/configuration&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;executions&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;execution&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;phase&amp;gt;package&amp;lt;/phase&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;goals&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;goal&amp;gt;cobertura&amp;lt;/goal&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/goals&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/execution&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/executions&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/plugin&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;/plugins&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;/build&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;reporting&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;plugins&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;plugin&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;groupId&amp;gt;org.codehaus.mojo&amp;lt;/groupId&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;artifactId&amp;gt;findbugs-maven-plugin&amp;lt;/artifactId&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;version&amp;gt;${findbugs.version}&amp;lt;/version&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/plugin&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;plugin&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;artifactId&amp;gt;maven-checkstyle-plugin&amp;lt;/artifactId&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;version&amp;gt;${checkstyle.version}&amp;lt;/version&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/plugin&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;plugin&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;artifactId&amp;gt;maven-surefire-report-plugin&amp;lt;/artifactId&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;version&amp;gt;${surefire.reportplugin.version}&amp;lt;/version&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/plugin&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;plugin&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;groupId&amp;gt;org.codehaus.mojo&amp;lt;/groupId&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;artifactId&amp;gt;cobertura-maven-plugin&amp;lt;/artifactId&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;version&amp;gt;${cobertura.version}&amp;lt;/version&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;configuration&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;formats&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;format&amp;gt;xml&amp;lt;/format&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/formats&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/configuration&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/plugin&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;/plugins&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #274e13; font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;/reporting&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
Run the job and everything should work out of the box. Do another build to start getting history graphs like below of the trend of failing tests, checkstyle warnings, issues found by Findbugs and te code coverage statistics from Cobertura.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWa6woRRXQAbXSkTCLCA9s29W6p3PIG1RngjFbT7YJ34cgFuVqMqzuUKD1U-5kxHSSa2ygjnzoha1pjKST4V-aASJ4SvWLnM4bHJAdV6UMUoGmApZzcdViO0VwfjODVk-fELzXYe9YkMCa/s1600/finished.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWa6woRRXQAbXSkTCLCA9s29W6p3PIG1RngjFbT7YJ34cgFuVqMqzuUKD1U-5kxHSSa2ygjnzoha1pjKST4V-aASJ4SvWLnM4bHJAdV6UMUoGmApZzcdViO0VwfjODVk-fELzXYe9YkMCa/s1600/finished.png&quot; height=&quot;562&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/698981819985465844/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2014/01/setup-jenkins-project-from-git.html#comment-form' title='20 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/698981819985465844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/698981819985465844'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2014/01/setup-jenkins-project-from-git.html' title='Setup Jenkins project from Git repository with Findbugs, Cobertura and Checkstyle'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_-X-PsHTxqIknuMyfwhQVpCE3mJvNEN_qlwMvFBDGFTtj48sQfl190-D1PGa2LWa547KGMh8sFm7o2ZMHddOv6_yzGOVIvJxdgrZtN9zmgXD8nCPVJDHOegPGdjtgIDckZsMwekg1T5zQ/s72-c/managejenkins.png" height="72" width="72"/><thr:total>20</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-6807488260582673849</id><published>2014-01-21T17:59:00.000+01:00</published><updated>2014-01-21T17:59:04.668+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="git"/><category scheme="http://www.blogger.com/atom/ns#" term="gitbash"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="windows"/><title type='text'>Share code between Windows and Linux using git</title><content type='html'>Here&#39;s how I setup my git repository on my Linux HTPC which I can store my projects on from the Windows workstation. No extra daemons or servers running. Plain ssh.&lt;br /&gt;
&lt;br /&gt;
First create a repository on the Linux machine.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@johanhtpc ~ $&amp;nbsp;mkdir gitrepos&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@johanhtpc ~ $&amp;nbsp;cd gitrepos/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@johanhtpc ~ $&amp;nbsp;mkdir UnitConversion.git&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@johanhtpc ~ $&amp;nbsp;cd UnitConversion.git/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@johanhtpc ~ $&amp;nbsp;git --bare init --shared=all&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now, from the Windows machine, I start up gitbash and go to the directory where I have the code I want to share. Then I add a new remote against my Linux machine and name the remote &lt;i&gt;htpc&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Johan@ELLINGTONI5 /c/ws/UnitConversion&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;$ git init&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Initialized empty Git repository in c:/ws/UnitConversion/.git/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Johan@ELLINGTONI5 /c/ws/UnitConversion (master)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;$ git remote add htpc johan@johanhtpc:gitrepos/UnitConversion.git&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I add everything in this directory to the local repository&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Johan@ELLINGTONI5 /c/ws/UnitConversion (master)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;$ git add --all&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Johan@ELLINGTONI5 /c/ws/UnitConversion (master)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;$ git commit&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now, let&#39;s push everything over the network to the Linux machine.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Johan@ELLINGTONI5 /c/ws/UnitConversion (master)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;$ git push htpc master&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@johanhtpc&#39;s password:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Counting objects: 729, done.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Delta compression using up to 4 threads.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Compressing objects: 100% (601/601), done.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Writing objects: 100% (728/728), 141.03 MiB | 8.35 MiB/s, done.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Total 728 (delta 118), reused 0 (delta 0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;To johan@johanhtpc:johanrepo.git&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;869b12e..ab0f0b7 &amp;nbsp;master -&amp;gt; master&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now, if I want to checkout the code on the Linux machine as a working copy, it&#39;s really simple&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@johanhtpc ~/ws $ git clone ~/gitrepos/UnitConversion.git&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Cloning into &#39;UnitConversion&#39;...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;done.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Now, push and pull from the local repositories against the common to work. Notice that from the Linux working repository the remote is named by default &lt;i&gt;origin&lt;/i&gt;. So when pushing the command will be&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;johan@johanhtpc ~/ws/UnitConversion $ git push origin master&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/6807488260582673849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2014/01/share-code-between-windows-and-linux.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/6807488260582673849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/6807488260582673849'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2014/01/share-code-between-windows-and-linux.html' title='Share code between Windows and Linux using git'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-2615191212896156696</id><published>2014-01-01T18:51:00.000+01:00</published><updated>2015-01-06T13:43:17.485+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="raspberry pi"/><category scheme="http://www.blogger.com/atom/ns#" term="rest"/><category scheme="http://www.blogger.com/atom/ns#" term="temperature"/><category scheme="http://www.blogger.com/atom/ns#" term="tomcat"/><category scheme="http://www.blogger.com/atom/ns#" term="weather station"/><title type='text'>Weather Station using Raspberry Pi, Tomcat and CouchDB</title><content type='html'>As a Christmas gift I&#39;ve built a remote temperature sensoring system to make it possible to record and keep track of the temperature in a summer house on an island in the Baltic Sea. The background is that the temperature cannot be too cold in the house during the winter, since the piping may freeze. This gizmo could maybe help in tuning the electric heating of the house to avoid making it too warm but not too cold either. It will also help to identify when the power is out in the house and the heating is malfunctioning making it necessary to travel out to the house to avoid the water to freeze.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Overview&lt;/h4&gt;
&lt;div&gt;
The layout is a Raspberry Pi using a DS18B20 digital temperature sensor that reads the temperature in the house. There is a NMT radio router in the house which serves Internet access. On a Tomcat server in the cloud, a Java web app accepts readings from the Raspberry via a REST API and stores the information in a CouchDB database. The web application also presents a single page web app that reads temperature data via the REST API and presents some nice graphs and tables. The frontend is built using Bootstrap to get a responsive design for both desktop and mobile.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEInNylS0j8eZ3FCCcFW46sizxlKe-FXKv7jIMuNCOLu8KS14npm95073UCBhKUMlgs6LgQYCzrv5kAsE-i81dHVu14FxK9l66HYvbWg5akmE7o-hMU9QnXUUU3mHKkLX_RNrdFBc0PwOq/s1600/drawing.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEInNylS0j8eZ3FCCcFW46sizxlKe-FXKv7jIMuNCOLu8KS14npm95073UCBhKUMlgs6LgQYCzrv5kAsE-i81dHVu14FxK9l66HYvbWg5akmE7o-hMU9QnXUUU3mHKkLX_RNrdFBc0PwOq/s640/drawing.png&quot; height=&quot;403&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The finished web application would look like this on desktop&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEZO0hUZBV8XChwiO6Vtg9aq3AbDLtepbGzJeZSlezPzmQwisU1tsdprgl-ipy8w9r0qY8LWBew7Q49z2qtqhtVMvPnm4JyXRrVzVWSQylojfqdjV35zSo-voui3WKT94WNqUomMxyt3yE/s1600/screenshot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEZO0hUZBV8XChwiO6Vtg9aq3AbDLtepbGzJeZSlezPzmQwisU1tsdprgl-ipy8w9r0qY8LWBew7Q49z2qtqhtVMvPnm4JyXRrVzVWSQylojfqdjV35zSo-voui3WKT94WNqUomMxyt3yE/s640/screenshot.png&quot; height=&quot;588&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
and on a phone it would scale appropriately as well.&lt;br /&gt;
&lt;br /&gt;
At the top the application will report for how long the sensor has been active (possibly since the last electricity outtake). If the sensor has not reported any readings during 15 minutes, it is assumed to be offline and a warning will be presented that we have no knowledge of the current temperature. If the ekectricity is gone in the house the heat will probably also be gone.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4&gt;
Setup the hardware&lt;/h4&gt;
&lt;div&gt;
What you need:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Raspberry Pi&lt;/li&gt;
&lt;li&gt;SD card (at least 4GB)&lt;/li&gt;
&lt;li&gt;Micro USB cable&lt;/li&gt;
&lt;li&gt;Ethernet cable&lt;/li&gt;
&lt;li&gt;DS18B20 temperature sensor&lt;/li&gt;
&lt;li&gt;4.7 kOhm resistor&lt;/li&gt;
&lt;li&gt;Wires&lt;/li&gt;
&lt;li&gt;Piece of PCB bread board&lt;/li&gt;
&lt;li&gt;Some kind of case&lt;/li&gt;
&lt;li&gt;Soldering iron&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhT7uA3PCRLUDLuP9UCIEcP5z_AUg8ErDOCRTPGpXc40eZ1hDtIe1Z74xpDyP5y9mGBneZ9KzWWf6cXEDbvleMiQYyATtmxHGVyFUt0JAOsNIa9uP2Sg05dkkeH5Cwvu1WDqsGVsyhxOvP/s1600/Pi-board.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhT7uA3PCRLUDLuP9UCIEcP5z_AUg8ErDOCRTPGpXc40eZ1hDtIe1Z74xpDyP5y9mGBneZ9KzWWf6cXEDbvleMiQYyATtmxHGVyFUt0JAOsNIa9uP2Sg05dkkeH5Cwvu1WDqsGVsyhxOvP/s200/Pi-board.jpg&quot; height=&quot;147&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So first of all let&#39;s setup the Raspberry Pi unit. I had the oldest model with 256MB RAM and Ethernet. I also have one of the newer 512MB &amp;nbsp;models and I&#39;ve tried the setup successfully on both. Since the 256MB version worked, that&#39;s the one I&#39;ve shipped. Here&#39;s how to make it into a temperature sensor.&lt;br /&gt;
&lt;br /&gt;
Try out the connections on a breadboard according to this sketch (borrowed from &lt;a href=&quot;http://learn.adafruit.com/&quot;&gt;AdaFruit&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidkAV9g4705rC4FS4tsDcH8nPMG1bjfqsdqYYtW7lWZ52-lbF76XTmSQPTxBgESnMl7nlZGiJZBgMYsLsXvey9Io3z8NX5eMB-xmst0qnnG8yqdCsHxzDCOa77yABSoyMoBTul2TBIBW5K/s1600/breadboard-probe.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidkAV9g4705rC4FS4tsDcH8nPMG1bjfqsdqYYtW7lWZ52-lbF76XTmSQPTxBgESnMl7nlZGiJZBgMYsLsXvey9Io3z8NX5eMB-xmst0qnnG8yqdCsHxzDCOa77yABSoyMoBTul2TBIBW5K/s320/breadboard-probe.png&quot; height=&quot;320&quot; width=&quot;256&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
The ports on the Pi are if not obvious in the sketch the 3.3V power port at slot 1, the data pin is pin #4 and the third wire is connected to ground.&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: right; margin-left: 1em; text-align: right;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIQe9MdR6zF3-TekLznZ-dZyGn8YPm1dQWKiWujIqUN95iAhcmo_7XKaos4HBa6kT6hR3qZiOxOaoVDdEOnixZWZiXM3RUTdnAaKBodsAH-VPjeiKJgbGkTOjUsJMoCMGZHTF0GsfElV-8/s1600/waterproofds18b20.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIQe9MdR6zF3-TekLznZ-dZyGn8YPm1dQWKiWujIqUN95iAhcmo_7XKaos4HBa6kT6hR3qZiOxOaoVDdEOnixZWZiXM3RUTdnAaKBodsAH-VPjeiKJgbGkTOjUsJMoCMGZHTF0GsfElV-8/s200/waterproofds18b20.jpg&quot; height=&quot;153&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;DS18B20 water proof temp sensor&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
There are several versions of the DS18B20 temperature sensor. I used the water proof version, it&#39;s only marginally more expensive than the others but since it has a chord in contrast to the other ones it can be put outside a window if you want.&lt;br /&gt;
&lt;br /&gt;
Then install the software according to below and make sure everything works. However, to make the final product more stable and resistent to shakes you should of course solder the wires. I recommend using an experiment board for this with &lt;i&gt;lanes&lt;/i&gt;. I bought one of &lt;a href=&quot;http://www.kjell.com/sortiment/el/elektronik/monsterkort/experimentkort/experimentkort-p89416&quot;&gt;these a long time ago from Swedish Kjell &amp;amp; Company&lt;/a&gt;. It makes the soldering easy and you have lanes of conducting copper which makes it easy to overview your structure and debug errors with a voltmeter.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_DEQ90h0LcsnQGtYUq1KIeDgLkNS6zXA0xFNnG3jBu-arJQNmkNzsd65Y4HsLfge2FMxVwKYMhhxT6GfE0dD1BNhMbIPCAasxEPAl3BcxnmFZZ_02rncS-iJ9xX6uud4-M0KRF388mywa/s1600/inbyggnadslada-g010.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_DEQ90h0LcsnQGtYUq1KIeDgLkNS6zXA0xFNnG3jBu-arJQNmkNzsd65Y4HsLfge2FMxVwKYMhhxT6GfE0dD1BNhMbIPCAasxEPAl3BcxnmFZZ_02rncS-iJ9xX6uud4-M0KRF388mywa/s320/inbyggnadslada-g010.jpg&quot; height=&quot;211&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
In this build the amount of board needed is tiny so not many cents of hardware needed. I bought a general purpose plastic box as well to mount the parts within. The box I found had&amp;nbsp;&lt;a href=&quot;http://www.kjell.com/sortiment/el/elektronik/elektroniklador/inbyggnadslada-g010-p89012&quot;&gt;predrilled holes within the box&amp;nbsp;&lt;/a&gt;suitable for attaching PCBs and other parts. Very practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The final assembly looked like this with the top of the box removed&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp8WOxOqTk4Jl6irNxPHq-3UvgQgQToEZvEzZdvuX7htu7NaBzOsXNDCaXIC3_NuZ5M1BnkRBbnbEcDubXPeU7_OCFUwk-ByEv4Fns_NPMpaTCTCJhe54nVXQFNUlDQFp9E9s0pM0D-nKX/s1600/box.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp8WOxOqTk4Jl6irNxPHq-3UvgQgQToEZvEzZdvuX7htu7NaBzOsXNDCaXIC3_NuZ5M1BnkRBbnbEcDubXPeU7_OCFUwk-ByEv4Fns_NPMpaTCTCJhe54nVXQFNUlDQFp9E9s0pM0D-nKX/s640/box.jpg&quot; height=&quot;352&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h4&gt;
Setup the software&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Burn &lt;a href=&quot;http://www.raspberrypi.org/downloads&quot;&gt;Raspbian OS&lt;/a&gt; to SD card (I had an old 4GB digital camera SD card over.&lt;/li&gt;
&lt;li&gt;Enable SSHD as default. See&lt;a href=&quot;http://macgyverdev.blogspot.se/2012/08/raspberry-pi-how-to-get-ssh-and-tomcat.html&quot;&gt; http://macgyverdev.blogspot.se/2012/08/raspberry-pi-how-to-get-ssh-and-tomcat.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Create a script directory and copy the Python program into it. You find the python source code in the GitHub repository&amp;nbsp;&lt;a href=&quot;https://github.com/johannoren/WeatherStation&quot;&gt;https://github.com/johannoren/WeatherStation&lt;/a&gt;&amp;nbsp;in the folder &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;raspberrypi/src/weatherstation.py&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;mkdir weatherstation&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;scp /WeatherStationServer/raspberrypi/src/weatherstation.py &amp;nbsp; &amp;nbsp; &amp;nbsp;pi@piaddress:weatherstation/&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;So the juice is in the&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt; weatherstation.py&lt;/span&gt; python script. But to run it by default on start up we create a wrapper bash script. Create a file &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;/home/pi/weatherstation/weatherstation.sh&lt;/span&gt; containing&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#!/bin/sh&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sleep 10&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sudo python /home/pi/weatherstation/weatherstation.py&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Make sure this kicks in when the Raspberry boots by adding this to &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;/etc/rc.local&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;/home/pi/weatherstation/weatherstation.sh &amp;amp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;In the weatherstation.py script, adjust the URI to your potential backend server. The lines containing the following should be adjusted to your server and appname. The appname should be changed to the name of your system preferrably so that you may have multiple systems running on the same backend and CouchDB database.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;pre style=&quot;color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; line-height: 18px;&quot;&gt;&lt;div class=&quot;line&quot; id=&quot;LC38&quot; style=&quot;padding-left: 10px;&quot;&gt;
&lt;span class=&quot;n&quot;&gt;conn&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;font-weight: bold;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;httplib&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;font-weight: bold;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;HTTPConnection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot; style=&quot;color: #dd1144;&quot;&gt;&quot;192.168.1.6:8080&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;line&quot; id=&quot;LC39&quot; style=&quot;padding-left: 10px;&quot;&gt;
&lt;span class=&quot;n&quot;&gt;conn&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;font-weight: bold;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot; style=&quot;color: #dd1144;&quot;&gt;&quot;POST&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;color: #dd1144;&quot;&gt;&quot;/WeatherStationServer/api/temperature/appname&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Reboot the Raspberry Pi and the script should try to post readings to the URI in the script.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
If you want to make your own script or just verify that the sensor is working correctly the important thing about this sensor is that when you add the kernel modules that handle the protocol the sensor is using, specific file handles will be created by the operating system containing the current temperature.&lt;br /&gt;
So you could alternatively try&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sudo modprobe w1-gpio&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sudo modprobe w1-therm&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;cd /sys/bus/w1/devices&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;ls&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;cd 28-xxxx (change this to match what serial number pops up)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;cat w1_slave&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
So, assuming you are using the provided python script, now we must setup a server that can handle these temperature postings. The source code is in the GitHub &lt;a href=&quot;https://github.com/johannoren/WeatherStation&quot;&gt;repository&lt;/a&gt;, you can pull via&amp;nbsp;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;https://github.com/johannoren/WeatherStation.git&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Install this in a Java web server, I used Tomcat 7. To install Tomcat on a Linux Ubuntu flavoured server is trivial&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sudo apt-get install tomcat7 tomcat7-admin tomcat7-common&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I personally use Eclipse to build my code, and then export the Web module as war archive (Right-click on the module in Eclipse and choose Export -&amp;gt; WAR archive). Then you can deploy the war file directly in the Tomcat web admin console which is usually located here &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;http://serveraddress/manager/html&lt;/span&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
However, the application must store the temperature data in a database and it is configured to use HTTP RESTful calls to store and retrieve JSON data. CouchDB will make a perfect backend for this.&lt;br /&gt;
&lt;br /&gt;
Some notes on installation and how to work with CouchDB using curl in this blog post&amp;nbsp;&lt;a href=&quot;http://macgyverdev.blogspot.se/2013/12/couchdb-on-linux-mint.html&quot;&gt;http://macgyverdev.blogspot.se/2013/12/couchdb-on-linux-mint.html&lt;/a&gt;, but it is trivial, apt-get to install.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #fefdfa; color: #333333; font-family: &#39;Courier New&#39;, Courier, monospace; line-height: 18px;&quot;&gt;sudo apt-get install couchdb -y&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Create a database for the particular temperature sensor application via&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;curl -vX PUT http://127.0.0.1:5984/nameofapp&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Depending on where you have deployed the CouchDB databse the Java application must be adjusted to communicate to the correct address and port. Before building and exporting the war archive to deploy in Tomcat make sure this constant is correct&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;WeatherStation /src/se/noren/weatherstation/WeatherStationServiceImpl.java&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;kd&quot; style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 18px; white-space: pre;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kd&quot; style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 18px; white-space: pre;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kd&quot; style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 18px; white-space: pre;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;COUCHDB_SERVER&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 18px; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot; style=&quot;background-color: white; color: #dd1144; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;&quot;http://johanhtpc:5984&quot;&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 18px; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;o&quot; style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 18px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
That&#39;s it, now the web app on the server can start posting readings to the database via essentially doing POSTs to the same URL. I used Spring Templates in the Java code which makes REST calls a no brainer. Look at this source code to figure out how to wrap the Spring Template to handle cookies, error handling etcetera&amp;nbsp;&lt;a href=&quot;https://github.com/johannoren/WeatherStation/blob/master/src/se/noren/weatherstation/adapter/CouchDBAdapter.java&quot;&gt;https://github.com/johannoren/WeatherStation/blob/master/src/se/noren/weatherstation/adapter/CouchDBAdapter.java&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
If you wish to see the contents of the database you can do something like this&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;curl -X GET http://127.0.0.1:5984/nameofapp/_all_docs?include_docs=true&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
And if you want to delete it to reset testing, you can guess what you need&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;curl -vX DELETE http://127.0.0.1:5984/nameofapp&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
More commands in the previous mentioned &lt;a href=&quot;http://macgyverdev.blogspot.se/2013/12/couchdb-on-linux-mint.html&quot;&gt;post&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
All good. That&#39;s about it I think, if interested in more details on some part, please comment.&lt;br /&gt;
&lt;br /&gt;
If you want to use Fahrenheit or some other system of measurement for temperatures, check out my new hobby project &lt;a href=&quot;http://www.all-about-units.com/en/convert-temperatures&quot;&gt;All About Units&lt;/a&gt; where there&#39;s a lot of goodies on units.&lt;br /&gt;
&lt;br /&gt;
You can buy your Raspberry Pi from many places on the net. Amazon has got both &lt;a href=&quot;http://www.amazon.com/gp/product/B009SQQF9C/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=B009SQQF9C&amp;amp;linkCode=as2&amp;amp;tag=macgydevel-20&amp;amp;linkId=PRUHHJX3KQSYZBXD&quot;&gt;new and used ones&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=macgydevel-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B009SQQF9C&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
 for a cheaper prize.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/B009SQQF9C/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=B009SQQF9C&amp;amp;linkCode=as2&amp;amp;tag=macgydevel-20&amp;amp;linkId=W5HAU2SZE6BOFXTZ&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=B009SQQF9C&amp;amp;Format=_SL110_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=macgydevel-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=macgydevel-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B009SQQF9C&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Addition 2015-01-06:&lt;/b&gt;&lt;br /&gt;
This setup has been extended with another temperature sensor to monitor outside temperature as well. See this blogpost for the additions:&amp;nbsp;&lt;a href=&quot;http://macgyverdev.blogspot.se/2015/01/raspberry-pi-weather-station-with.html&quot;&gt;http://macgyverdev.blogspot.se/2015/01/raspberry-pi-weather-station-with.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Just for reference:&lt;br /&gt;
I added Google Analytics tracking to be able to see the utilization of the sensor. Here I learned a new thing as well about Analytics. I had the probe run for some time at home before christmas to see that it behaved stable and didn&#39;t crash after a long running time, which it didn&#39;t, but I unfortunately noticed that the first deployment I made in Google App Engine of the server backend used up to much resources and went over the free quota limit making the server unusable. So I moved the server backend to another server residing on a different domain. Suddenly the Analytics stats disappeared on december 22nd. I had already started wrapping the present. :-/&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKe89-AxuYRglgyDRu6n6uqDFcvKzUh4SZmTNAMJojHmYg-WxXqW7ex6tyQc2LuA1U8cXCCJV6eq1-4MXLcsKat6CwB4cvsSHuvgZmDaJgxhoIqo_Qa00BYir-Dx8b_H1X0e2NfjY0EXhj/s1600/analytics.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKe89-AxuYRglgyDRu6n6uqDFcvKzUh4SZmTNAMJojHmYg-WxXqW7ex6tyQc2LuA1U8cXCCJV6eq1-4MXLcsKat6CwB4cvsSHuvgZmDaJgxhoIqo_Qa00BYir-Dx8b_H1X0e2NfjY0EXhj/s400/analytics.png&quot; height=&quot;250&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So the problem is that Google Analytics is specifying the cookie domain in the Javascript. I think this is new, I have no domains in my old Analytics scripts. So what you need to do if you encounter this problem is to manually change this line in the Google Analytics Javascript snippet&lt;br /&gt;
&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;webkit-line-number&quot; value=&quot;24&quot;&gt;&lt;/td&gt;&lt;td class=&quot;webkit-line-content&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;   (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;webkit-line-number&quot; value=&quot;25&quot;&gt;&lt;/td&gt;&lt;td class=&quot;webkit-line-content&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;webkit-line-number&quot; value=&quot;26&quot;&gt;&lt;/td&gt;&lt;td class=&quot;webkit-line-content&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;   m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;webkit-line-number&quot; value=&quot;27&quot;&gt;&lt;/td&gt;&lt;td class=&quot;webkit-line-content&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;   })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;webkit-line-number&quot; value=&quot;28&quot;&gt;&lt;/td&gt;&lt;td class=&quot;webkit-line-content&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;webkit-line-number&quot; value=&quot;29&quot;&gt;&lt;/td&gt;&lt;td class=&quot;webkit-line-content&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;   ga(&#39;create&#39;, &#39;UA-46361998-1&#39;, &#39;&lt;span style=&quot;color: red;&quot;&gt;newdomain.com&lt;/span&gt;&#39;);&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;webkit-line-number&quot; value=&quot;30&quot;&gt;&lt;/td&gt;&lt;td class=&quot;webkit-line-content&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;   ga(&#39;send&#39;, &#39;pageview&#39;);&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/2615191212896156696/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2014/01/weather-station-using-raspberry-pi.html#comment-form' title='39 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/2615191212896156696'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/2615191212896156696'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2014/01/weather-station-using-raspberry-pi.html' title='Weather Station using Raspberry Pi, Tomcat and CouchDB'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEInNylS0j8eZ3FCCcFW46sizxlKe-FXKv7jIMuNCOLu8KS14npm95073UCBhKUMlgs6LgQYCzrv5kAsE-i81dHVu14FxK9l66HYvbWg5akmE7o-hMU9QnXUUU3mHKkLX_RNrdFBc0PwOq/s72-c/drawing.png" height="72" width="72"/><thr:total>39</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-5652305896247137606</id><published>2013-12-28T22:49:00.000+01:00</published><updated>2014-03-08T22:23:35.953+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="git"/><category scheme="http://www.blogger.com/atom/ns#" term="github"/><title type='text'>Git GitHub Cheat Sheet</title><content type='html'>Some of the most frequent git commands I use, but also forget between the times I need them.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Setup a repository&lt;/h3&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git clone &amp;lt;repository&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Clone the specified repo to current location. Think CVS checkout.&lt;/div&gt;
&lt;div&gt;
To clone a GitHub repository, copy the link to the repo on the GitHub site.&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git clone&amp;nbsp;https://github.com/johannoren/WeatherStation.git&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If you instead start by creating your project locally you initialize git by&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;mkdir MyProject&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;cd MyProject&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git init&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To add a file&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;touch foo&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git add foo&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git commit -m &quot;First commit&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To connect your local repository to GitHub (or other remote repository) assuming we have created a &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;MyProject &lt;/span&gt;project on GitHub we create a &lt;i&gt;remote &lt;/i&gt;named &lt;i&gt;origin&lt;/i&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git remote add origin https://github.com/johannoren/MyProject.git&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To push our local commited file to the remote &lt;i&gt;origin &lt;/i&gt;on the main branch &lt;i&gt;master&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git push origin master&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To clone a repository on one of your other machines, do this over ssh&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git clone ssh://johan@192.168.1.6:/home/johan/gitrepos/MyRepo.git&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;
Git configuration&lt;/h3&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git config -e&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Open the Git config file in the default editor&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git config --global user.name &#39;Johan Noren&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git config --global user.email abc@gmail.com&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Edit the author and email when making commits&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git config --list&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
List all Git configuration options&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If you add &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;--global&lt;/span&gt; after these config commands, they will be applied to all repositories and not only the current repo.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h3&gt;
Diffs, shows, blames, history and info&lt;/h3&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git diff&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
What has changed since your last commit? To diff only a file use&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git diff -- &amp;lt;filename&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git status&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
List added files to the staging area, changed files and untracked files.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git log&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Show the most recent commits. Comes with a collection of options:&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;--color&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Color coded&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;--graph&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Commit graph added to the left&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;--decorate&lt;/span&gt;&amp;nbsp; &amp;nbsp;Add branch and tag names to commits&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;--stat&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Show files changed, inserted, deleted&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;-p&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Show all diffs&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;--author=&quot;Johan Noren&quot;&lt;/span&gt;&amp;nbsp; Commits by a certain author&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;--after=&quot;MMM DD YYYY&quot;&lt;/span&gt; ex. (&quot;Jun 20 2008&quot;) Filter commits by date&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;--before=&quot;MMM DD YYYY&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;--merge &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Filter out commits occuring in the current merge conflict.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git show &amp;lt;revision&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Show the diff of a commit specified by &amp;lt;revision&amp;gt;. Revision can be any SHA1 commit ID, branch name, or tag.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git blame &amp;lt;filename&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Show the author of each line in a file.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git ls-files&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
List all files version controlled&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h3&gt;
Add and delete files&lt;/h3&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git add &amp;lt;file&amp;gt; &amp;lt;file&amp;gt; ...&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Add files to the git project&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git add &amp;lt;directory&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Add all files in direcotry including all subdirectories&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git add .&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Add all created/modified files in current directory (not deleted)&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git add -u &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Add to index only files deleted/modified and not those created&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git add -A &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Do both operation at once, add to index all files&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git add -p&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Patch mode allows you to stage parts of a changed file, instead of the entire file. This allows you to make concise, well-crafted commits that make for an easier to read history.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git rm &amp;lt;file&amp;gt; &amp;lt;file&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Remove the files from the git project.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git rm $(git ls-files --deleted)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Remove all deleted files from the git project&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h3&gt;
Stage and commit&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git add &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; ...&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git stage &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; ...&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Add changes in &amp;lt;file1&amp;gt;, &amp;lt;file2&amp;gt; ... to the staging area which will be included in the next commit&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git add -p&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git stage --patch&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Walk through the current changes (hunks) and decide for each change which to add to the staging area.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git reset HEAD &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; ...&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Remove files from the next commit&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git commit &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; ... [-m &amp;lt;message&amp;gt;]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Commit &amp;lt;file1&amp;gt;, &amp;lt;file2&amp;gt; ... optionally using commit message &amp;lt;msg&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git commit -a&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Commit all files changed since your last commit not including new (untracked) files.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h3&gt;
Branches and merging&lt;/h3&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git branch&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
List all local branches&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git branch -r&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
List all remote branches&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git branch &amp;lt;branchname&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Create a new branch named &amp;lt;branchname&amp;gt;, referencing the same point in history as the current branch.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git branch &amp;lt;branch&amp;gt; &amp;lt;start-point&amp;gt;&lt;/span&gt;&lt;br /&gt;
Create a new branch named &amp;lt;branch&amp;gt;, referencing &amp;lt;start-point&amp;gt;, which may be specified using a branch name or a tag name and more.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git push &amp;lt;repo&amp;gt; &amp;lt;start-point&amp;gt;:refs/heads/&amp;lt;branch&amp;gt;&lt;/span&gt;&lt;br /&gt;
Create a new remote branch named &amp;lt;branch&amp;gt;, referencing &amp;lt;start-point&amp;gt; on the remote. Repo is the name of the remote.&lt;br /&gt;
Examples:&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git push origin origin:refs/heads/branch-1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git push origin origin/branch-1:refs/heads/branch-2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git push origin branch-1 ## shortcut&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git branch -d &amp;lt;branchname&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Delete branch &amp;lt;branchname&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git branch -r -d &amp;lt;remote-branch&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Delete a remote-tracking branch. Example&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git branch -r -d branchname/master&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
git checkout &amp;lt;branchname&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Update the working directory to reflect the version referenced by &amp;lt;branchname&amp;gt; and make the current branch &amp;lt;branchname&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
git checkout -b &amp;lt;branchname&amp;gt; &amp;lt;start-point&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Create a new branch &amp;lt;branchname&amp;gt; referencing &amp;lt;start-point&amp;gt;, and check it out.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-size: 19px; font-weight: bold;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: small;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;git merge &amp;lt;branchname&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 19px; font-weight: bold;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;Merge branch &amp;lt;branchname&amp;gt; into the current branch.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 19px; font-weight: bold;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h3&gt;
Tags&lt;/h3&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git tag&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
List all available tags&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
There are two types of tags, lightweight and annotated. Less information is stored in lightweight tags so always use annotated &#39;-a&#39; if unsure.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git tag -a v1.0_20140102_2122 -m &#39;Tag information&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To push the tag to GitHub use&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git push origin &amp;lt;tagname&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
or if you have many tags or if you are lazy, push all tags&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git push origin --tags&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;h3&gt;
Handle remote repositories&lt;/h3&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git fetch &amp;lt;remote&amp;gt;&lt;/span&gt;&lt;br /&gt;
Update the remote-tracking branches for &amp;lt;remote&amp;gt; (defaults to &quot;origin&quot;). Does not initiate a merge into the current branch, see &quot;git pull&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git pull&lt;/span&gt;&lt;br /&gt;
Fetch changes from the server, and merge them into the current branch.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git push&lt;/span&gt;&lt;br /&gt;
Update the server with the commits across all branches that are &lt;i&gt;common&amp;nbsp;&lt;/i&gt;between the local copy and the server. Local branches that were never pushed to the server are not shared.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git push origin &amp;lt;branch&amp;gt;&lt;/span&gt;&lt;br /&gt;
Update the server with your commits made to &amp;lt;branch&amp;gt; since your last push. This is always required for new branches that you wish to share. After the first explicit push, &quot;git push&quot; is sufficient.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git remote add &amp;lt;remote&amp;gt; &amp;lt;remote_url&amp;gt;&lt;/span&gt;&lt;br /&gt;
Add a remote repository to your git config. &amp;nbsp;Can then be fetched locally.&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git remote add myworkteam git://github.com/somename/someproject.git&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git fetch myworkteam&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h3&gt;
Revert local changes&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
Assuming you did not commit the file, or add it to the index, then:&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git checkout filename&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Assuming you added it to the index, but did not commit it, then:&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git reset HEAD filename&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git checkout filename&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Assuming you did commit it, then:&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git checkout origin/master filename&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Assuming you want to blow away all commits from your branch (VERY DESTRUCTIVE):&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git reset --hard origin/master&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/5652305896247137606/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2013/12/git-github-cheat-sheet.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/5652305896247137606'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/5652305896247137606'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2013/12/git-github-cheat-sheet.html' title='Git GitHub Cheat Sheet'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-1802584425202574720</id><published>2013-12-20T22:41:00.000+01:00</published><updated>2013-12-30T22:34:45.191+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="couchdb"/><category scheme="http://www.blogger.com/atom/ns#" term="linux mint"/><title type='text'>CouchDB on Linux Mint - Cheat sheet</title><content type='html'>Here&#39;s my cheat sheet for working with&amp;nbsp;&lt;a href=&quot;http://couchdb.apache.org/&quot;&gt;CouchDB &lt;/a&gt;on a&amp;nbsp;Linux Mint server.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Installation&lt;/h4&gt;
Installation is trivial&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;sudo apt-get install couchdb -y&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Test to see that it works.&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;curl http://127.0.0.1:5984/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;should return something like&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;{&quot;couchdb&quot;:&quot;Welcome&quot;,&quot;version&quot;:&quot;1.2.0&quot;}&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Create a database named &lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&#39;johantest&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;curl -X PUT http://127.0.0.1:5984/johantest&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Delete the same database&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;curl -X DELETE http://127.0.0.1:5984/johantest&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;h4&gt;
Adding documents&lt;/h4&gt;
Assume you didn&#39;t delete the database, add a document like this&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;curl -X POST http://127.0.0.1:5984/johantest \&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;-H &#39;Content-Type: application/json&#39; \&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;-d &#39;{&quot;SomeProperty&quot;:&quot;Test1&quot;,&quot;AnotherProperty&quot;:&quot;Test2&quot;,&quot;Age&quot;:32,&quot;PropList&quot;:[&quot;Prop1&quot;,&quot;Prop2&quot;,&quot;Prop3&quot;]}&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
To retrieve all documents in a database&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;curl -X GET http://127.0.0.1:5984/johantest/_all_docs&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Gives&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;{&quot;total_rows&quot;:1,&quot;offset&quot;:0,&quot;rows&quot;:[&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;{&quot;id&quot;:&quot;4571d772c7d61fa34a7579ce6f04d47b&quot;,&quot;key&quot;:&quot;4571d772c7d61fa34a7579ce6f04d47b&quot;,&quot;value&quot;:{&quot;rev&quot;:&quot;1-a268e2541be30dae295fb88015bd1a5c&quot;}}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;]}&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
That will only give references so you can GET each document detail. To fetch the contents of an individual document, fetch using the key from the provious GET.&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;curl -X GET http://127.0.0.1:5984/johantest/4571d772c7d61fa34a7579ce6f04d47b&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Gives&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;{&quot;_id&quot;:&quot;4571d772c7d61fa34a7579ce6f04d47b&quot;,&quot;_rev&quot;:&quot;1-a268e2541be30dae295fb88015bd1a5c&quot;,&quot;SomeProperty&quot;:&quot;Test1&quot;,&quot;AnotherProperty&quot;:&quot;Test2&quot;,&quot;Age&quot;:32,&quot;PropList&quot;:[&quot;Prop1&quot;,&quot;Prop2&quot;,&quot;Prop3&quot;]}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&amp;nbsp;If you wish to fetch all documents in one large JSON blob&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;curl -X GET http://127.0.0.1:5984/johantest/_all_docs?include_docs=true&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Gives&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;{&quot;total_rows&quot;:1,&quot;offset&quot;:0,&quot;rows&quot;:[&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;{&quot;id&quot;:&quot;4571d772c7d61fa34a7579ce6f04d47b&quot;,&quot;key&quot;:&quot;4571d772c7d61fa34a7579ce6f04d47b&quot;,&quot;value&quot;:{&quot;rev&quot;:&quot;1-a268e2541be30dae295fb88015bd1a5c&quot;},&quot;doc&quot;:{&quot;_id&quot;:&quot;4571d772c7d61fa34a7579ce6f04d47b&quot;,&quot;_rev&quot;:&quot;1-a268e2541be30dae295fb88015bd1a5c&quot;,&quot;SomeProperty&quot;:&quot;Test1&quot;,&quot;AnotherProperty&quot;:&quot;Test2&quot;,&quot;Age&quot;:32,&quot;PropList&quot;:[&quot;Prop1&quot;,&quot;Prop2&quot;,&quot;Prop3&quot;]}}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;]}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h4&gt;
Settings and logs&lt;/h4&gt;
&lt;div&gt;
Settings are stored in&amp;nbsp;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;/etc/couchdb/default.ini&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
To be able to connect to the databse via HTTP from other machines on network, change&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;bind_address = 0.0.0.0&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The actual database is stored by default at&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;/var/lib/couchdb/1.2.0&lt;/span&gt; and is named in this case&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;johantest.couch&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
If you wish to move it to another partition or similar, change the settings&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;database_dir = /var/lib/couchdb/1.2.0&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;view_index_dir = /var/lib/couchdb/1.2.0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To get a feel of the amount of disk used by Couch I notice that my Weather Station application has stored 8800 JSON documents in a format like this&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;{&quot;id&quot;:&quot;6ea52d20ab226121a325d0e3c5ffe4b5&quot;,&quot;key&quot;:&quot;6ea52d20ab226121a325d0e3c5ffe4b5&quot;,&quot;value&quot;:{&quot;rev&quot;:&quot;1-087372f223546fb03c75605decb4a442&quot;},&quot;doc&quot;:{&quot;_id&quot;:&quot;6ea52d20ab226121a325d0e3c5ffe4b5&quot;,&quot;_rev&quot;:&quot;1-087372f223546fb03c75605decb4a442&quot;,&quot;temperature&quot;:23.75858110517378563,&quot;rawDate&quot;:1385961273368,&quot;key&quot;:&quot;holmon&quot;}}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
That will occupy 28.9 MB of disk with the default settings of compression etcetera.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To see what requests has been made against the database, the log is placed at&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;/var/log/couchdb/couch.log&lt;/div&gt;
&lt;div&gt;
which can be changed in the settings file as well. Output for the tests above&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;[Sat, 28 Dec 2013 09:08:41 GMT] [info] [&amp;lt;0.2082.8&amp;gt;] 127.0.0.1 - - PUT /johantest 201&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;[Sat, 28 Dec 2013 09:34:03 GMT] [info] [&amp;lt;0.28823.7&amp;gt;] 127.0.0.1 - - DELETE /johantest 200&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;[Sat, 28 Dec 2013 09:34:07 GMT] [info] [&amp;lt;0.25248.7&amp;gt;] 127.0.0.1 - - PUT /johantest 201&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;[Sat, 28 Dec 2013 09:34:13 GMT] [info] [&amp;lt;0.3856.8&amp;gt;] 127.0.0.1 - - POST /johantest 201&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;[Sat, 28 Dec 2013 09:34:22 GMT] [info] [&amp;lt;0.2437.8&amp;gt;] 127.0.0.1 - - GET /johantest/_all_docs?include_docs=true 200&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;[Sat, 28 Dec 2013 09:35:29 GMT] [info] [&amp;lt;0.2449.8&amp;gt;] 127.0.0.1 - - GET /johantest/_all_docs 200&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;[Sat, 28 Dec 2013 09:35:41 GMT] [info] [&amp;lt;0.2339.8&amp;gt;] 127.0.0.1 - - GET /johantest/4571d772c7d61fa34a7579ce6f04d47b 200&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/1802584425202574720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2013/12/couchdb-on-linux-mint.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/1802584425202574720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/1802584425202574720'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2013/12/couchdb-on-linux-mint.html' title='CouchDB on Linux Mint - Cheat sheet'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-1172703092145702459</id><published>2013-12-19T22:27:00.001+01:00</published><updated>2013-12-30T22:35:01.007+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="git"/><category scheme="http://www.blogger.com/atom/ns#" term="github"/><title type='text'>Clone a GitHub project into Eclipse</title><content type='html'>I&#39;ve been using the Git command line tools to setup my workspaces against GitHub and then importing projects into Eclipse going back and forth to the command line to diff, commit and push back to origin. In my current project I&#39;ve discovered the &lt;i&gt;Git Repository Explorer &lt;/i&gt;in Eclipse and how it makes many of the tasks much easier.&lt;br /&gt;
&lt;br /&gt;
To clone an existing GitHub repository add the perspective Git Repository Explorer&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMpHBmwrSPyQodXKJ4NOSG264JwlYn3P8XAvHM959A3PPRHAAd9k-IAWF87UTzfuU3ZhcLw4eyZw4AyUXgJIq2Tca-EnaXKmeFgWPotHoc-5iPwWloOLI7FuHTGjhzn8AK63WqclMl4bf4/s1600/perscpective.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMpHBmwrSPyQodXKJ4NOSG264JwlYn3P8XAvHM959A3PPRHAAd9k-IAWF87UTzfuU3ZhcLw4eyZw4AyUXgJIq2Tca-EnaXKmeFgWPotHoc-5iPwWloOLI7FuHTGjhzn8AK63WqclMl4bf4/s400/perscpective.png&quot; width=&quot;328&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Choose to clone a repository&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6mNuLvAIg6CBdJEaOaneifJwApUW5M95aN7N3ZKecPc6SBdjsU7MBAUVEOXbodAldQIrt7WnFkL-tFPs4pdnu6f-OYe0mXMpUr7aF7TPwMyjKpyw7N7XJ7UMSBKBzoldxJEAIiS371nSb/s1600/clonerepo.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;142&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6mNuLvAIg6CBdJEaOaneifJwApUW5M95aN7N3ZKecPc6SBdjsU7MBAUVEOXbodAldQIrt7WnFkL-tFPs4pdnu6f-OYe0mXMpUr7aF7TPwMyjKpyw7N7XJ7UMSBKBzoldxJEAIiS371nSb/s400/clonerepo.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Add details about the remote repository&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkZyLz3WPdfJBqzsWrLz86vStCogyeNNKLsH5_D_yuOoeOHtXQdCD_sVYJfxHp3osO3ZUJmNtr8PNA5IV7Fc55ZLx9AgXQKQuM_gSVKN7CtZdRUD7O_xEtRKvIy6d6BSQBjPzgJABnAMuO/s1600/repo.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkZyLz3WPdfJBqzsWrLz86vStCogyeNNKLsH5_D_yuOoeOHtXQdCD_sVYJfxHp3osO3ZUJmNtr8PNA5IV7Fc55ZLx9AgXQKQuM_gSVKN7CtZdRUD7O_xEtRKvIy6d6BSQBjPzgJABnAMuO/s400/repo.png&quot; width=&quot;393&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
The URI can be found on the GitHub page for the repository you wish to clone&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXe51W9HGrBv8bUenXBvB7kD6qNjKNMo0wG4nuUabzZF1jqzD4weTmGkDivXEcpVr_LAA-QIECkxV6xdp2RE-zBk42Pxc1qYOhe4DNmhZrTKxs8O2kE7F4mVFlrz-52ViU7abiVQJvImjy/s1600/github.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;203&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXe51W9HGrBv8bUenXBvB7kD6qNjKNMo0wG4nuUabzZF1jqzD4weTmGkDivXEcpVr_LAA-QIECkxV6xdp2RE-zBk42Pxc1qYOhe4DNmhZrTKxs8O2kE7F4mVFlrz-52ViU7abiVQJvImjy/s400/github.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Select the branch to check out and in the next view tick the &quot;Import all existing projects after clone finishes&quot;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGVaNP-8xxHwL4ucWu0lhF1zfnQLsPqeglsRyyWsJec9IpFmWSn_H_uDhdEzcO6VFTAww6hDZHKNq7hdC82dXMKWOG_p0vTOq8zS7Hr-SOd3gJFmhYWAWvDhUCyFUmCYyKh71ZVlAPx8wi/s1600/localdest.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGVaNP-8xxHwL4ucWu0lhF1zfnQLsPqeglsRyyWsJec9IpFmWSn_H_uDhdEzcO6VFTAww6hDZHKNq7hdC82dXMKWOG_p0vTOq8zS7Hr-SOd3gJFmhYWAWvDhUCyFUmCYyKh71ZVlAPx8wi/s400/localdest.png&quot; width=&quot;393&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Then you got your project in your workspace as expected&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwdkiQe4Oq4CdvTVy8yoIM8vT96flIPMHoeamDpm4iG9juOWOD1WsKtBgN7y2Lyi4m4nOIcPsJS7gdgIJT_obTseKNeK97iSG1I__ops3WB-csaOSvPgkP47VrmeGHg8x76cnGn7ZO6aqD/s1600/ws.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwdkiQe4Oq4CdvTVy8yoIM8vT96flIPMHoeamDpm4iG9juOWOD1WsKtBgN7y2Lyi4m4nOIcPsJS7gdgIJT_obTseKNeK97iSG1I__ops3WB-csaOSvPgkP47VrmeGHg8x76cnGn7ZO6aqD/s400/ws.png&quot; width=&quot;267&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now the usual Eclipse goodies har here for you, to diff local changes is much clearer than the command line diff utility for example&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiV23nhZ-oU4nxjMnFIH2FV1j9Upd7-5YObrNuZe4I8msz-rrHCT2Cv08bwaro9CYZPG1XhB0uJkUa3XaHoqAFTYX3i4NrtMWaOqtjcBb_lmLpWZ6t3sz65x-pk7XIWSaV3qaYYAbPnWFlZ/s1600/diff.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;170&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiV23nhZ-oU4nxjMnFIH2FV1j9Upd7-5YObrNuZe4I8msz-rrHCT2Cv08bwaro9CYZPG1XhB0uJkUa3XaHoqAFTYX3i4NrtMWaOqtjcBb_lmLpWZ6t3sz65x-pk7XIWSaV3qaYYAbPnWFlZ/s400/diff.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The synchronize option to see all changes in your local copy&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpOiudczuFZG5viQnIYefoH0IIjQgwpwJjM2HkzOBCjgGxREC5Giat80pTrxzZw1IhY8YnAQtWT_xXyuUMMvE43sZgbXDll9huJLNJN76UHJRywZt6XrTniSplB_nLEuh_ddsLx-da1As6/s1600/synch.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;177&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpOiudczuFZG5viQnIYefoH0IIjQgwpwJjM2HkzOBCjgGxREC5Giat80pTrxzZw1IhY8YnAQtWT_xXyuUMMvE43sZgbXDll9huJLNJN76UHJRywZt6XrTniSplB_nLEuh_ddsLx-da1As6/s400/synch.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Inspecting the history of the file is also presented in a more readable manner&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjq-QIjy4kyzxqQx2Lgg6mcAiDrw28lXJt2qsEEQ8rMR3_fguFKkbQBYAnAzYC9PmneFXz12Le2O7SnPCap6vNKUN__xoHv4fhNjVqWREE9sc-wRe0e7pujTacVX9yiTApEYV33rU9BYZ7P/s1600/history.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;137&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjq-QIjy4kyzxqQx2Lgg6mcAiDrw28lXJt2qsEEQ8rMR3_fguFKkbQBYAnAzYC9PmneFXz12Le2O7SnPCap6vNKUN__xoHv4fhNjVqWREE9sc-wRe0e7pujTacVX9yiTApEYV33rU9BYZ7P/s400/history.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Commit and push to origin (GitHub in this case) is a single operation if you wish&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-Xj4TmN-equPsOEKteMwZ6Q5EEtUqZvT4lX0CnCpXH0maJarntFfs-cZX6D9DQ_DOtTevpz4c6guo8jlHt-THFYcjpnYZIveXpUCxs9I-HTl4K4cpjEj9CWoFV-yVEaoW7izS-5p-fJqI/s1600/commit.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;396&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-Xj4TmN-equPsOEKteMwZ6Q5EEtUqZvT4lX0CnCpXH0maJarntFfs-cZX6D9DQ_DOtTevpz4c6guo8jlHt-THFYcjpnYZIveXpUCxs9I-HTl4K4cpjEj9CWoFV-yVEaoW7izS-5p-fJqI/s400/commit.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/1172703092145702459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2013/12/clone-github-project-into-eclipse.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/1172703092145702459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/1172703092145702459'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2013/12/clone-github-project-into-eclipse.html' title='Clone a GitHub project into Eclipse'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMpHBmwrSPyQodXKJ4NOSG264JwlYn3P8XAvHM959A3PPRHAAd9k-IAWF87UTzfuU3ZhcLw4eyZw4AyUXgJIq2Tca-EnaXKmeFgWPotHoc-5iPwWloOLI7FuHTGjhzn8AK63WqclMl4bf4/s72-c/perscpective.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-601581737739377272</id><published>2013-11-14T18:03:00.000+01:00</published><updated>2013-12-26T18:04:17.712+01:00</updated><title type='text'>Spice up your comments</title><content type='html'>I was searching for something on StackOverflow and found this off-topic &lt;a href=&quot;http://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered&quot; target=&quot;_blank&quot;&gt;thread on comments&lt;/a&gt;.&lt;br /&gt;
A few gems:&lt;br /&gt;
&lt;br /&gt;
&lt;br style=&quot;background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 21px;&quot; /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Exception up = new Exception(&quot;Something is really wrong.&quot;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;throw up; //ha ha&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;//When I wrote this, only God and I understood what I was doing&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;//Now, God only knows&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// Dear maintainer:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// Once you are done trying to &#39;optimize&#39; this routine,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// and have realized what a terrible mistake that was,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// please increment the following counter as a warning&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// to the next guy:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// total_hours_wasted_here = 42&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;//Mr. Compiler, please do not read this.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// I dedicate all this code, all my work, to my wife, Darlene, who will&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// have to support me and our three children and the dog once it gets&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// released into the public.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// drunk, fix later&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// Magic. Do not touch.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;return 1; # returns 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// If I from the future read this I&#39;ll back in time and kill myself.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;double penetration; // ouch&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;/////////////////////////////////////// this is a well commented line&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// I am not sure if we need this, but too scared to delete.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// I am not responsible of this code.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// They made me write it, against my will.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;//Dear future me. Please forgive me.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;//I can&#39;t even begin to express how sorry I am.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;options.BatchSize = 300; //Madness? THIS IS SPARTA!&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// I have to find a better job&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// hack for ie browser (assuming that ie is a browser)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;} catch (PartInitException pie) {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// Mmm... pie&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// John! If you&#39;ll svn remove this once more,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// I&#39;ll shut you, for God&#39;s sake!&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// That piece of code is not “something strange”!&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// That is THE AUTH VALIDATION.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;try {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;catch (SQLException ex) {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// Basically, without saying too much, you&#39;re screwed. Royally and totally.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;catch(Exception ex)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;//If you thought you were screwed before, boy have I news for you!!!&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// Catching exceptions is for communists&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// If you&#39;re reading this, that means you have been put in charge of my previous project.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// I am so, so sorry for you. God speed.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;* For the brave souls who get this far: You are the chosen ones,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;* the valiant knights of programming who toil away, without rest,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;* fixing our most awful code. To you, true saviors, kings of men,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;* I say this: never gonna give you up, never gonna let you down,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;* never gonna run around and desert you. Never gonna make you cry,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;* never gonna say goodbye. Never gonna tell a lie and hurt you.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// If this code works, it was written by Paul. If not, I don&#39;t know who wrote it&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;* If you don&#39;t understand this code, you should be flipping burgers instead.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;//Abandon all hope yea who enter beyond this point&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;catch (Ex as Exception)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// oh crap, we should do something.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// TODO make this work&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;// This is crap code but it&#39;s 3 a.m. and I need to get this working.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 21px;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/601581737739377272/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2013/12/spice-up-your-comments.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/601581737739377272'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/601581737739377272'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2013/12/spice-up-your-comments.html' title='Spice up your comments'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-4253307084445490913</id><published>2013-09-22T10:41:00.000+02:00</published><updated>2014-01-05T12:35:28.716+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="netflix"/><title type='text'>Netflix on Linux Mint 14</title><content type='html'>Netflix uses Microsoft Silverlight in their web version which makes it impossible to watch Netflix on Linux machines since no native client is available. The &lt;a href=&quot;http://fds-team.de/cms/articles/2013-08/pipelight-using-silverlight-in-linux-browsers.html&quot;&gt;Pipelight project &lt;/a&gt;has released a plugin&amp;nbsp;that emulates Silverlight using the Netscape Plugin API and &lt;a href=&quot;http://www.winehq.org/&quot;&gt;wine&lt;/a&gt;. So all browsers supporting the Netscape Plugin API like Firefox and Chrome should be able to use this trick.&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
This is tested on my Linux Mint 14 HTPC with Chrome and works like a charm. It is even faster then the earlier Linux Desktop Netflix client that was available as apt-get install.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If you have an earlier version of Pipelight first remove it&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: #fff2cc; font-family: Courier New, Courier, monospace;&quot;&gt;sudo apt-get remove pipelight&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Install the plugin and enable it&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: #fff2cc; font-family: Courier New, Courier, monospace;&quot;&gt;sudo apt-add-repository ppa:ehoover/compholio&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: #fff2cc; font-family: Courier New, Courier, monospace;&quot;&gt;sudo apt-add-repository ppa:mqchael/pipelight&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: #fff2cc; font-family: Courier New, Courier, monospace;&quot;&gt;sudo apt-get update&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: #fff2cc; font-family: Courier New, Courier, monospace;&quot;&gt;sudo apt-get install pipelight-multi&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: #fff2cc; font-family: Courier New, Courier, monospace;&quot;&gt;sudo pipelight-plugin --enable silverlight&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
That should be it. But the Netflix web site has a check that your browser is a Windows based browser. Emulate this by installing a plugin that enables you to choose which user agent your browser should mimick. I use the &lt;a href=&quot;https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg&quot;&gt;User Agent Shifter for Chrome&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
If you use this one, switch to &lt;i&gt;Windows Firefox 15 &lt;/i&gt;or similar in the menu.&lt;br /&gt;
&lt;br /&gt;
Pipelight also supports Adobe Flash, so if you have need for that, install it via&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #fff2cc; font-family: Courier New, Courier, monospace;&quot;&gt;pipelight-plugin --enable flash&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/4253307084445490913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2013/10/netflix-on-linux-mint-14.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/4253307084445490913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/4253307084445490913'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2013/10/netflix-on-linux-mint-14.html' title='Netflix on Linux Mint 14'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-4615347340465349707</id><published>2013-04-14T13:29:00.000+02:00</published><updated>2014-01-05T12:36:17.079+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="backups"/><category scheme="http://www.blogger.com/atom/ns#" term="rsync"/><title type='text'>Simple backups with rsync</title><content type='html'>Here&#39;s my notes on how I setup my home network backup system in case I forget it.&lt;br /&gt;
I was first thinking of backing everything to some cloud service like Google Drive or Dropbox, but it will be quite expensive since I have too much home movies, images and sound recordings. So what I&#39;ve done is that I have one backup of the stuff on a USB harddrive and another duplicate on the HTPC server. The same technique could be used to backup to a server at a friends house to make the backups completely fire proof.&lt;br /&gt;
&lt;br /&gt;
Using the old Unix command rsync it is really easy to automate this. I installed rsync via cygwin, google for &lt;i&gt;cwrsync &lt;/i&gt;which is rsync for Windows. My HTPC is a Linux Mint server so I created a RSA keypair for my Linux user and stored the keys on my Windows desktop machine in directory&amp;nbsp;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;c:\docume~1\Johan\.ssh\id_rsa_rsync_johanhtpc&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
So now we can authenticate against the HTPC with ssh which rsync supports and I only need to create a configuration of what I want to synchronize.&lt;br /&gt;
&lt;br /&gt;
I created a config command file like this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;java:nocontrols:nogutter&quot; name=&quot;code&quot;&gt;@ECHO OFF

SETLOCAL

SET CWRSYNCHOME=%ProgramFiles(x86)%\CWRSYNC

SET CYGWIN=nontsec

SET HOME=%HOMEDRIVE%%HOMEPATH%

SET CWOLDPATH=%PATH%

SET PATH=%CWRSYNCHOME%\BIN;%PATH%



rsync -av --chmod u+rwx -e &quot;ssh -i c:\docume~1\Johan\.ssh\id_rsa_rsync_johanhtpc&quot; &quot;/cygdrive/e/Dokument&quot; johan@johanhtpc:PCBackups

rsync -av --chmod u+rwx -e &quot;ssh -i c:\docume~1\Johan\.ssh\id_rsa_rsync_johanhtpc&quot; &quot;/cygdrive/e/Musik&quot; johan@johanhtpc:PCBackups

rsync -av --chmod u+rwx -e &quot;ssh -i c:\docume~1\Johan\.ssh\id_rsa_rsync_johanhtpc&quot; &quot;/cygdrive/e/Programmering&quot; johan@johanhtpc:PCBackups

rsync -av --chmod u+rwx -e &quot;ssh -i c:\docume~1\Johan\.ssh\id_rsa_rsync_johanhtpc&quot; &quot;/cygdrive/e/Bilder&quot; johan@johanhtpc:PCBackups

rsync -av --chmod u+rwx -e &quot;ssh -i c:\docume~1\Johan\.ssh\id_rsa_rsync_johanhtpc&quot; &quot;/cygdrive/e/Audiobooks&quot; johan@johanhtpc:PCBackups

rsync -av --chmod u+rwx -e &quot;ssh -i c:\docume~1\Johan\.ssh\id_rsa_rsync_johanhtpc&quot; &quot;/cygdrive/c/ws&quot; johan@johanhtpc:PCBackups

rsync -av --chmod u+rwx -e &quot;ssh -i c:\docume~1\Johan\.ssh\id_rsa_rsync_johanhtpc&quot; &quot;/cygdrive/c/recordings&quot; johan@johanhtpc:PCBackups

rsync -av --chmod u+rwx -e &quot;ssh -i c:\docume~1\Johan\.ssh\id_rsa_rsync_johanhtpc&quot; &quot;/cygdrive/c/render&quot; johan@johanhtpc:PCBackups

&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So when run, rsync will check each folder on the Windows harddrive or external harddrive against the directory on the backup server. If new files have been created or existing files are updated they will be synchronized. No action will be taken for directories or files that are unchanged.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To automate this, I used the Windows scheduler. I added a task that will run each night at 00:59. It will simply run the above command.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_RTM_v5TVbd3ccS-Qn_6NVfPsxwQH0lcjqLxlBxKkhC8YPl8mUG2stqXcTbMIE4oz2_BKF5wuqgsJg-bGL2N6wqrUhRgO-GK1_CpClzGf9uuJaXG5gco3LyflRj68qJ_xte0-iY1PcErD/s1600/scheduler.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;122&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_RTM_v5TVbd3ccS-Qn_6NVfPsxwQH0lcjqLxlBxKkhC8YPl8mUG2stqXcTbMIE4oz2_BKF5wuqgsJg-bGL2N6wqrUhRgO-GK1_CpClzGf9uuJaXG5gco3LyflRj68qJ_xte0-iY1PcErD/s320/scheduler.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjVxsE2vUcUc7VHRsdKccvgY-xMAfKkPxDOGihc0hAp6h6TwIv_yE-FvewsBqvHjYaIiieakSeSoLYcMqKKRCxc1r17qIO57c_1HpnUFKXewiJIt5U8S4iFeb-oTrcDNLxy5bJgQBD_VcN/s1600/properties.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjVxsE2vUcUc7VHRsdKccvgY-xMAfKkPxDOGihc0hAp6h6TwIv_yE-FvewsBqvHjYaIiieakSeSoLYcMqKKRCxc1r17qIO57c_1HpnUFKXewiJIt5U8S4iFeb-oTrcDNLxy5bJgQBD_VcN/s320/properties.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/4615347340465349707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2013/04/simple-backups-with-rsync.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/4615347340465349707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/4615347340465349707'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2013/04/simple-backups-with-rsync.html' title='Simple backups with rsync'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_RTM_v5TVbd3ccS-Qn_6NVfPsxwQH0lcjqLxlBxKkhC8YPl8mUG2stqXcTbMIE4oz2_BKF5wuqgsJg-bGL2N6wqrUhRgO-GK1_CpClzGf9uuJaXG5gco3LyflRj68qJ_xte0-iY1PcErD/s72-c/scheduler.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-8531451544077281329</id><published>2013-02-02T17:59:00.003+01:00</published><updated>2014-01-05T12:36:42.922+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="security"/><category scheme="http://www.blogger.com/atom/ns#" term="sql injection"/><title type='text'>Create server backdoors using SQL Injection</title><content type='html'>If you&#39;re a web programmer you are probably aware of the most common security mistakes we make. OWASP keeps statistics on what exploits are the most common. If you&#39;re not familiar with these, this should be mandatory reading&amp;nbsp;&lt;a href=&quot;https://www.owasp.org/index.php/Top_10_2010-Main&quot;&gt;https://www.owasp.org/index.php/Top_10_2010-Main&lt;/a&gt;.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
As shown, injections are still one of the worse problems. If you&#39;re not familiar with SQL injection &lt;a href=&quot;http://en.wikipedia.org/wiki/SQL_injection&quot;&gt;check out &lt;/a&gt;some basic ways to exploit it on vulnerable site. The examples are often about trying to select some sensitive data and getting the data to be rendered on the vulnerable site.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I&#39;m not a black hat hacker so I&#39;ve always thought about SQL injection as something primarily putting the site and it&#39;s data into danger. But tag along to see that SQL injection can be the entry point of pwning the complete server and getting inside the firewall and the internal network.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now, I was reading up on SQL the other day for a project at work and stumbled upon some SQL syntax I didn&#39;t know about. Combining this with an SQL injection vulnerability could be dynamite.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So first, assume you found a weakness on a site. There are tools for that, but basically try to append code to request parameters like&amp;nbsp;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&#39; or &#39;foo&#39;=&#39;1&amp;nbsp;&lt;/span&gt;or similar to look for server crashes giving you a hint of SQL injection problems like &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Unknown column &#39;foo&#39; in &#39;where clause&#39;&lt;/span&gt;. Now you would &quot;normally&quot; start the tiresome work of finding something valuable in the database.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
But, with the SQL syntax &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;INTO FILE&lt;/span&gt; you can write files. Nice. So depending on what technology the server is based on you could write files that can be accessed via the web interface. If the file names in the URI don&#39;t give away what technology used look at the HTTP header value of &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Server&lt;/span&gt;. If for example the header talks about JBoss you can guess that the site is Java based and we could try to create JSP files. Similarly you could aim for creating PHP script files etc if that&#39;s whats dished out by the server.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So, by using something like this in the injection exploit (the red is what is supplied by the hacker via the request parameter injection)&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;SELECT a, b FROM someunknowntable WHERE someunknowncolumn = &#39;&lt;span style=&quot;color: red;&quot;&gt;&#39; UNION SELECT &#39;&amp;lt;?php system($_GET[&quot;cmd&quot;]); ?&amp;gt;&#39; INTO OUTFILE &#39;/var/www/htdocs/pwn.php&#39;; --&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
or similar for other scripting technologies like JSP, ASP etc you have created a public backdoor.&lt;/div&gt;
&lt;div&gt;
Catastrophe!&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Point you&#39;re browser to &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;http://thesite.com/pwn.php?cmd=pwd&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
to print out the currect working directory of the web server process.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now only imagination stops you. &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;cmd=cat /etc/passwd /etc/shadow&lt;/span&gt; to dump all user credentials. If the web server is running as root it&#39;s too easy to start creating misery like keylogging the other users or dumping all databases.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The lesson from this is that if you have five web servers and databases hosting different sites on your server it is the weakest link of them that defines the total security. So by hacking the not so important server with an SQL injection weakness you can get to the data of the highly secured applications with no SQL injection weaknesses via a backdoor.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Some thought on avoiding this kind of problems&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Always use frameworks and libraries that removes the possibility of SQL injection. Java has prepared statements or some of the ORM technologies. The other languages has their own ways.&lt;/li&gt;
&lt;li&gt;Run the database process as a user with low file access priviligies so that it can&#39;t write files anywhere it shouldn&#39;t be able to. Or even better, run it on a separate machine.&lt;/li&gt;
&lt;li&gt;Same for the web server, don&#39;t run it as root. There are other ways of hacking web or application servers to gain shell access.&lt;/li&gt;
&lt;li&gt;A general good thought is not to reveal to much information about what technology serves the site if possible to make it harder to exploit knowledge about how it behaves. For example, don&#39;t show server versions in HTTP headers, don&#39;t show crash stacktraces in server responses in production mode and so on.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/8531451544077281329/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2013/02/create-server-backdoors-using-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/8531451544077281329'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/8531451544077281329'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2013/02/create-server-backdoors-using-sql.html' title='Create server backdoors using SQL Injection'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-3944223946936366011</id><published>2013-01-04T14:17:00.003+01:00</published><updated>2013-01-04T14:30:32.074+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="blender"/><category scheme="http://www.blogger.com/atom/ns#" term="camera tracking"/><title type='text'>Sink Hole Animation</title><content type='html'>I made a little animation which fakes a sink hole in the platform outside the Umeå Östra train station. This relies on camera tracking which takes a real scene and incorporates it in a simulated 3D environment.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/aegDnlPjxwE?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
Prerequisities&amp;nbsp;&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
A camera, (in my case a Canon 550D), some bright post-its,&amp;nbsp;&lt;a href=&quot;http://www.blender.org/&quot;&gt;Blender&lt;/a&gt;&amp;nbsp;(free and open source), Gimp or other image processing software and a few hours of modelling time and a nights sleep for rendering the scene.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
Pick a scene&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Figure out a scene. To make the camera tracking easiser to automate, pick a bright scene so that you will have short shutter times. Also, (which I failed to follow) try to keep your camera steady and make pans slow and steady to avoid blurry and unsharp images in your film. Record in highest possible resolution of your camera.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
Object tracking&lt;/h3&gt;
&lt;div class=&quot;&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJ8gkFZJlwJGRi8pbVzuzA4O_gCRBGuGJexLBzR25PsQSytIRPgnPMISxaXfwA_4Iu6wqEsg1qZXWtDIpfwxN01IK67fXxhgiBUNF7HNQ9L_tXU97Ayp89nqsJ6q6M_vd9-g0zz9scuIV2/s1600/scattered.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;148&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJ8gkFZJlwJGRi8pbVzuzA4O_gCRBGuGJexLBzR25PsQSytIRPgnPMISxaXfwA_4Iu6wqEsg1qZXWtDIpfwxN01IK67fXxhgiBUNF7HNQ9L_tXU97Ayp89nqsJ6q6M_vd9-g0zz9scuIV2/s320/scattered.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;You must find some high contrast objects in the scene which you will use to track during the movement of the real camera in order for Blender to figure out the relative position of these objects. Preferrably use objects which will have parallax shifts when you move around in the scene. Also use a few objects that lie in your ground plane (the train platform) so that you can create a correct coordinate system.&lt;/div&gt;
&lt;div class=&quot;&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
In this scene, I want good resolution around the sink hole, but there are few high contrast objects, so I scattered some yellow pieces of post it notes around the area.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: right;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdw2mHYw1mfZCr0ZgdppuO8lsce-fTvbNEE0OEhpgo1B8_a4pfhNKtxJlGbt2aPJ4eIQKON0I1NMaMNpCi0BVLZ7m6TvLtLc8RAqCjbuBtvOpLewfDkEeC-DyWhZBtLYjDK33QDTzPpqVO/s1600/trackers.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;297&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdw2mHYw1mfZCr0ZgdppuO8lsce-fTvbNEE0OEhpgo1B8_a4pfhNKtxJlGbt2aPJ4eIQKON0I1NMaMNpCi0BVLZ7m6TvLtLc8RAqCjbuBtvOpLewfDkEeC-DyWhZBtLYjDK33QDTzPpqVO/s320/trackers.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;Record your movie, import it into Blender and use the new Movie Clip Editor, which has come in one of the latest releases, to tag tracking objects. In the best of worlds, the software can follow the movement of the high contrast objects through the whole movie clip. Didn&#39;t work like a charm for me, had to manually help the tracker when the camera panned fast, so that&#39;s a note to self for future trackings. When you solve the system, Blender will figure out how the camera has moved during the photo shoot and create a camera animation for that for the virtual camera used later when rendering.&lt;/div&gt;
&lt;div class=&quot;&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
Modelling and rendering&lt;/h3&gt;
&lt;div class=&quot;&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_T68OFU-uCVvl8MSLbxCMkZ7JwSqTDx0Egn59ZgHcF8LXXayfKFnCBqsb2f6Zaf3aEhy5Gh7RkkGW8jfR0P6wGMWk8y0IJH6ptifgREgjMm3NFb82tK7t-f3wHCsV4vqgngd6WLKJ-wBb/s1600/wireframe.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;174&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_T68OFU-uCVvl8MSLbxCMkZ7JwSqTDx0Egn59ZgHcF8LXXayfKFnCBqsb2f6Zaf3aEhy5Gh7RkkGW8jfR0P6wGMWk8y0IJH6ptifgREgjMm3NFb82tK7t-f3wHCsV4vqgngd6WLKJ-wBb/s320/wireframe.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;I made a real simple hole model in Blender with some gravel textures overlaying eachother. Then by using the composition features of Blender you can merge each frame in the original movie clip with the rendered model with the correct camera position. In this example, the large disk in the image representing the ground is not rendered in the final composition, but it can receive renderable shadows, so that you can have your own 3D objects cast shadows onto the ground in the movie.&lt;br /&gt;
&lt;br /&gt;
For reference, the original movie looks like&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/5k1Cr5nib54?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;br /&gt;
This is based in an excellent explanation of the Blender camera tracking functionality by Andrew Price on &lt;a href=&quot;http://www.blenderguru.com/&quot;&gt;BlenderGuru&lt;/a&gt;.&lt;/div&gt;
&lt;div class=&quot;&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/3944223946936366011/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2013/01/sink-hole.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/3944223946936366011'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/3944223946936366011'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2013/01/sink-hole.html' title='Sink Hole Animation'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJ8gkFZJlwJGRi8pbVzuzA4O_gCRBGuGJexLBzR25PsQSytIRPgnPMISxaXfwA_4Iu6wqEsg1qZXWtDIpfwxN01IK67fXxhgiBUNF7HNQ9L_tXU97Ayp89nqsJ6q6M_vd9-g0zz9scuIV2/s72-c/scattered.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-44446440792021133</id><published>2012-12-29T01:55:00.002+01:00</published><updated>2013-01-03T14:25:40.419+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="distortion pedal"/><category scheme="http://www.blogger.com/atom/ns#" term="diy"/><category scheme="http://www.blogger.com/atom/ns#" term="electronics"/><category scheme="http://www.blogger.com/atom/ns#" term="fuzz pedal"/><title type='text'>Hermanizer Power Pedal - A DIY Fuzz Box</title><content type='html'>For christmas gift to my brother I thought I&#39;d try to make a guitar effect pedal. The main feature would be to have a nice sounding distortion effect, classic rock fuzz. I also found an article on Instructables by &lt;a href=&quot;http://www.instructables.com/id/Distortion-Pedal-With-Stutter-Effect/&quot;&gt;Harrymatic &lt;/a&gt;discussing adding a timer IC to the circuit to create a sound slicing/chopping kind of effect. This construction is based on his ideas.&lt;br /&gt;
&lt;br /&gt;
So what you need is an amplifier IC, I used an LM386 circuit which can amplify a signal up to 200 times. To be able to control the amplification and the output signal, two potentiometers (resistors with variable resistance) acts as gain and volume controls. The sound slicing effect is created by a NE555 timer circuit which flips the voltage on its output pin high and low in a repeating fashion. The frequency of this is determined by a third potentiometer which is glued to a &quot;effect rate&quot; knob.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7nC6cpfS1vV7jpdcaCdQPHHb4Mf0-gDBIhEMpO5DN3IllApmj0H9oRxoKKCAFPGcX30YzXQBvgbLJTTy5y6sMlSudhEJQd6R-zt-6xkUgsl5BvX5o0urBIeshYjsQWhEMjxq5xdsjFYXO/s1600/hermanizer-power-pedal.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;276&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7nC6cpfS1vV7jpdcaCdQPHHb4Mf0-gDBIhEMpO5DN3IllApmj0H9oRxoKKCAFPGcX30YzXQBvgbLJTTy5y6sMlSudhEJQd6R-zt-6xkUgsl5BvX5o0urBIeshYjsQWhEMjxq5xdsjFYXO/s400/hermanizer-power-pedal.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Circuit diagram of the effect pedal - click for larger picture&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Depending on the state of the FX On/Off switches, pin 6 of the amplifier IC is fed by either a constant feed from the power source or a chopped up square wave from the timer IC.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2XTtZ3EqDmNuc6L88ZRSA-H1QWfqZqOgr4oQINeYY6A9wXo-6z-X7cSY6AJZP0the2xp32UBYRkncOZy_sIlnWrDVITm5EORuQMJkb68Pjx1HxBUuY8sDTEWILrQLF7ejyHeG0w-iqVly/s1600/breadboard.JPG&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; display: inline !important; float: right; margin-bottom: 1em; margin-left: 1em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2XTtZ3EqDmNuc6L88ZRSA-H1QWfqZqOgr4oQINeYY6A9wXo-6z-X7cSY6AJZP0the2xp32UBYRkncOZy_sIlnWrDVITm5EORuQMJkb68Pjx1HxBUuY8sDTEWILrQLF7ejyHeG0w-iqVly/s320/breadboard.JPG&quot; width=&quot;239&quot; /&gt;&lt;/a&gt;So first step to try this out was connect everything on a breadboard.&lt;br /&gt;
&lt;br /&gt;
If you buy your ICs with DIL8 sockets they will fit nicely on a standard breadboard. An important lesson from this setup is that you must ground both your input jack coming from your instrument and the output jack going to headphones/speakers/amplifiers or else you will get very disturbing hizzes and noises.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJLSEfIoInI3Gkgk7yT12bVTklsRNMho27prw9OlEjz_3-hjYUhL_M93P4pq6V1UGObgiuLF-8wnGT97Ox3sRWGwSF-MlvofxjETIblBZs2YP4TMeMVGhv3w6E5dV6jI5xjgwaRakGlxj2/s1600/boxed.JPG&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJLSEfIoInI3Gkgk7yT12bVTklsRNMho27prw9OlEjz_3-hjYUhL_M93P4pq6V1UGObgiuLF-8wnGT97Ox3sRWGwSF-MlvofxjETIblBZs2YP4TMeMVGhv3w6E5dV6jI5xjgwaRakGlxj2/s320/boxed.JPG&quot; width=&quot;239&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Once everything worked out on the breadboard I printed and soldered the circuits on a stripboard. The soldering is not shown in this picture since the circuits are on the backside of the stripboard.&lt;br /&gt;
&lt;br /&gt;
For a case I bought a metal case and drilled the necessary holes for the potentiometers, switches and the power LED.&lt;br /&gt;
&lt;br /&gt;
I bought the stuff I didn&#39;t already have at home from ELFA. It amounts to somewhere around 200 SEK.&amp;nbsp;The integrated circuits are about 8 SEK each but the casing and the knobs turned out to be the most expensive stuff.&lt;br /&gt;
&lt;br /&gt;
After stuffing everything inside the pedal works fine. When only using the distortion effect no hearable background fuzz is noticed. However, when enabling the chopping effect there is a constant background noise which is evident if no signal is coming from the instrument.&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: right; margin-left: 1em; text-align: right;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbgY2uFXD4yDbEyMSD1POZxN2HnrSe2dnHMSbnfn8-BFVKxiEJoxY47c3xDqJXvekpZstUZWgJsTfRPvGUlMuAg4bjvLX603rOsFikw9zMac44QSpiua2g_guopmgzqK3U4vIcfIW3suDW/s1600/powerpedal.JPG&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbgY2uFXD4yDbEyMSD1POZxN2HnrSe2dnHMSbnfn8-BFVKxiEJoxY47c3xDqJXvekpZstUZWgJsTfRPvGUlMuAg4bjvLX603rOsFikw9zMac44QSpiua2g_guopmgzqK3U4vIcfIW3suDW/s320/powerpedal.JPG&quot; width=&quot;239&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The final effect box&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
So how does the pedal sound? Well, this is the sound when applying quite a lot of distortion effect on an otherwise clean &lt;a href=&quot;http://www.acc.umu.se/~noren/audio/powerpedal/organ.mp3&quot;&gt;organ sound&lt;/a&gt;. I&#39;m not a guitar player like my brother, but here&#39;s a few chords from my old Squire guitar lined directly into the effect pedal with pretty &lt;a href=&quot;http://www.acc.umu.se/~noren/audio/powerpedal/gitarr.mp3&quot;&gt;much distortion&lt;/a&gt;.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Here&#39;s a synth line which after a few seconds get the the &lt;a href=&quot;http://www.acc.umu.se/~noren/audio/powerpedal/synth.mp3&quot;&gt;chopper effect applied&lt;/a&gt;. In the end of the clip the rate of the effect is increased to maximum.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/44446440792021133/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2012/12/hermanizer-power-pedal-diy-fuzz-box.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/44446440792021133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/44446440792021133'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2012/12/hermanizer-power-pedal-diy-fuzz-box.html' title='Hermanizer Power Pedal - A DIY Fuzz Box'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7nC6cpfS1vV7jpdcaCdQPHHb4Mf0-gDBIhEMpO5DN3IllApmj0H9oRxoKKCAFPGcX30YzXQBvgbLJTTy5y6sMlSudhEJQd6R-zt-6xkUgsl5BvX5o0urBIeshYjsQWhEMjxq5xdsjFYXO/s72-c/hermanizer-power-pedal.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-2665002969605561792</id><published>2012-10-06T11:18:00.001+02:00</published><updated>2014-01-05T12:34:15.771+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="closures"/><category scheme="http://www.blogger.com/atom/ns#" term="functional programming"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="lambda expressions"/><title type='text'>Functional programming in Java?</title><content type='html'>After more toying with Scala on my spare time while hacking Java in office hours I miss out on using all these functional idioms in my Java programs. So with Java 8 coming closer I got interested in how the JDK team is planning on utilizing the new Java closure syntax in for example the collections libraries to support a more functional style of programming. While I have it fresh in memory, let me tell you some cool aspects of this!&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Closures in Java&amp;nbsp;&lt;/h2&gt;
&lt;div&gt;
Closures are anonymous functions also known as lambda expression. In languages where functions are first class members you could assign a lamba expression to a function variable. However, this is not entirely true for the Java implementation. In order not to mess up the type system to much, the engineers behind the implementation of the Lambda JSR 335 in OpenJDK has taken the approach to use interfaces containing &lt;i&gt;one &lt;/i&gt;method to become special in the language. Such an interface is called a &lt;i&gt;functional interface&lt;/i&gt;. An example of such an interface is &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;ActionListener&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;code style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;public interface ActionListener { 
    void actionPerformed(ActionEvent e);
}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
or &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Runnable &lt;/span&gt;or &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Comparator&lt;/span&gt;.&lt;/div&gt;
&lt;div&gt;
So in JDK 7 or earlier syntax, this is how you would declare for example an ActionListener&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;code style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;ActionListener l = new ActionListener() { 
  public void actionPerformed(ActionEvent e) { 
    doWork(e.getModifiers());
  }
};&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
However, with the new Java 8 syntax, you&#39;d write it as&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;code style=&quot;font-family: &#39;courier new&#39;, monospace; font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;ActionListener l = (ActionEvent e) -&amp;gt; doWork(e.getModifiers());&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
So you get rid of all the unnecessary boilerplate code inherent in anonymous class creations so common in Java.&amp;nbsp;More pleasing examples of usages of this syntax&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;code style=&quot;font-family: &#39;courier new&#39;, monospace; font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Comparator&amp;lt;String&amp;gt; c = (s1, s2) -&amp;gt; s1.compareToIgnoreCase(s2);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;code style=&quot;font-family: &#39;courier new&#39;, monospace; font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;FileFilter java = f -&amp;gt; f.getName().endsWith(&quot;.java&quot;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
There&#39;s a lot of interesting things going on here like how lexical scopes work, variable binding, type inference etcetera. Check out project lead Brian Goetz &lt;a href=&quot;http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-4.html&quot;&gt;report &lt;/a&gt;on how these things works.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;
Java Collection libraries&amp;nbsp;&lt;/h2&gt;
&lt;div&gt;
So how will this be used in the collection libraries which are probably the most used toolkit of the Java platform? First of all, the Collections team has decided not to restart by rewriting the collections libraries from scratch. While mentioning that this might be a candidate for future JDK versions, version 8 will instead provide an evolutionary step forward in the Collections by adding extension methods to existing interfaces (List, Set, Iterable) and retrofit existing classes with new interfaces such as &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Stream&lt;/span&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
A major shift will be from the imperative style of external iteration to the more functional style of internal iteration. For example, the recommended idiom in Java 5+ to change a property on all objects in a collection uses&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;code style=&quot;font-family: &#39;courier new&#39;, monospace; font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;for (Car c : cars) {
    c.setState(MOVING);
}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
With closures you&#39;ll write this as&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;code style=&quot;font-family: &#39;courier new&#39;, monospace; font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;cars.forEach(c -&amp;gt; { c.setState(MOVING); });&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
What are the benefits of this idiom? You move the control flow to the library instead of the client code. In this way the library can decide on potentially use laziness, parallelism and out-of-order execution to improve performance which will be showed in later examples.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
You can pipeline operations. In this example the &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;filter &lt;/span&gt;operation uses a predicate to decide which objects in the collection to pipe to the final &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;forEach &lt;/span&gt;clause.&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;code style=&quot;font-family: &#39;courier new&#39;, monospace; font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;cars.filter(c -&amp;gt; c.getWeight() &amp;gt; 2000)
      .forEach(c -&amp;gt; { c.setState(STOPPED); });&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
And to store results from computations using for example the map operation which operates on each value in the piped collection use something like&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;code style=&quot;font-family: &#39;courier new&#39;, monospace; font-weight: bold;&quot;&gt;Set&amp;lt;Engine&amp;gt; smallEngines = cars.filter(c -&amp;gt; c.getMaxSpeed() &amp;lt; 100)
                .map(c -&amp;gt; c.getEngine())
                .into(new HashSet&amp;lt;&amp;gt;());&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
or to sum them. This is the well known functional idiom of &lt;i&gt;map reduce&lt;/i&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;code style=&quot;font-family: &#39;courier new&#39;, monospace; font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;int sum = cars.filter(c -&amp;gt; c.getState() == MOVING)
                .map(c -&amp;gt; c.getWeight())
                .sum();&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So, all these operations will not create temporary new collections and pass on to the next operation. Instead they operate lazily and stream values between the control blocks. This implies good performance when for example searching for the first object that satisfies some condition. The upstream iterator in this example will not continue the iteration when&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt; getFirst()&lt;/span&gt; has found a match.&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;code style=&quot;font-family: &#39;courier new&#39;, monospace; font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Car fastCar = cars.filter(c -&amp;gt; c.getSpeed() &amp;gt; 120).getFirst();&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
When used to these constructs, a lot of boilerplate code should be possible to remove. Here Brian Goetz shows an &lt;a href=&quot;http://cr.openjdk.java.net/~briangoetz/lambda/collections-overview.html&quot;&gt;example &lt;/a&gt;of a method in &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;java.lang.Class&lt;/span&gt; as today&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;code style=&quot;font-family: &#39;courier new&#39;, monospace; font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; for (Method m : enclosingInfo.getEnclosingClass().getDeclaredMethods()) {
     if (m.getName().equals(enclosingInfo.getName()) ) {
         Class&amp;lt;?&amp;gt;[] candidateParamClasses = m.getParameterTypes();
         if (candidateParamClasses.length == parameterClasses.length) {
             boolean matches = true;
             for(int i = 0; i &amp;lt; candidateParamClasses.length; i++) {
                 if (!candidateParamClasses[i].equals(parameterClasses[i])) {
                     matches = false;
                     break;
                 }
             }

             if (matches) { // finally, check return type
                 if (m.getReturnType().equals(returnType) )
                     return m;
             }
         }
     }
 }

 throw new InternalError(&quot;Enclosing method not found&quot;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
and how it could be rewritten without all the temporary variables making it both more readable and less error prone.&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;code style=&quot;font-family: &#39;courier new&#39;, monospace; font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Method matching =
  Arrays.asList(enclosingInfo.getEnclosingClass().getDeclaredMethods())
    .filter(m -&amp;gt; Objects.equals(m.getName(), enclosingInfo.getName())
    .filter(m -&amp;gt;  Arrays.equals(m.getParameterTypes(), parameterClasses))
    .filter(m -&amp;gt; Objects.equals(m.getReturnType(), returnType))
    .getFirst();
if (matching == null)
    throw new InternalError(&quot;Enclosing method not found&quot;);
return matching;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
There&#39;s a lot of more cool features on the project &lt;a href=&quot;http://cr.openjdk.java.net/~briangoetz/lambda/collections-overview.html&quot;&gt;site&lt;/a&gt;, but before ending you should see how easy parallel computation can become. By streaming the pipeline via parallel() the library will try to divide the pipeline stream of operations to all your cores.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: #e8e8e8; margin: 1.5ex 2em; padding: 1px 1ex;&quot;&gt;&lt;code style=&quot;font-family: &#39;courier new&#39;, monospace; font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;int sum = cars.&lt;span style=&quot;color: red;&quot;&gt;parallel()&lt;/span&gt;
                .filter(c -&amp;gt; c.getState() == MOVING)
                .map(c -&amp;gt; c.getWeight())
                .sum();&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Via the new interface &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Splittable &lt;/span&gt;you can also very easily use the Fork/Join framwork for divide and conquer tasks.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;
Timeplans&lt;/h2&gt;
&lt;div&gt;
This looks awesome. But when can we use it? According to the milestone plan the public review version should be available in January 2013. The JDK 8 timeplan currently looks like&lt;br /&gt;
&lt;br /&gt;
2012/7&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Expert Group formation&lt;br /&gt;
2012/9&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Early Draft Review&lt;br /&gt;
2013/1&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Public Review&lt;br /&gt;
2013/6&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Proposed Final Draft&lt;br /&gt;
2013/8&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Final Release&lt;br /&gt;
&lt;a href=&quot;http://openjdk.java.net/projects/jdk8/spec/&quot;&gt;http://openjdk.java.net/projects/jdk8/spec/&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
But you can download bleeding edge versions of the OpenJDK 8 binaries today and play around with the lambda language construct and the current implementations in the collections libraries as well as a lot of the other libraries.&amp;nbsp;&lt;a href=&quot;http://jdk8.java.net/download.html&quot;&gt;http://jdk8.java.net/download.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4&gt;
&lt;/h4&gt;
&lt;h2&gt;
Alternative functional libraries&lt;/h2&gt;
&lt;div&gt;
If you can&#39;t wait there are libraries for functional programming in Java that will work with JDK5 or newer.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Guava&lt;/h3&gt;
Googles &lt;a href=&quot;http://code.google.com/p/guava-libraries/wiki/FunctionalExplained&quot;&gt;Guava &lt;/a&gt;libraries have support for functional idioms. However without language support the code easily becomes messed up with boilerplate. On the other hand, there are a lot of good stuff in Guava like a richer set of collection constructs and easier use of immutable collections types. Here&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-color: #eeeeee; font-size: 12px; max-width: 70em; overflow: auto; padding: 0.5em;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Multiset&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; lengths &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;HashMultiset&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;FluentIterable&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;strings&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Predicate&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;boolean&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; apply&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;CharMatcher&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;JAVA_UPPER_CASE&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;matchesAllOf&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;})&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Function&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; apply&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;}));&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;h3&gt;
Lambdaj&lt;/h3&gt;
Another interesting library is &lt;i&gt;&lt;a href=&quot;http://code.google.com/p/lambdaj/&quot;&gt;Lambdaj&lt;/a&gt;&amp;nbsp;&lt;/i&gt;which uses static imported methods to hide give a nicer looking syntax. This is some typical Java code to sort a list of persons according to age&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-color: #eeeeee; font-family: Monaco, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Lucida Console&#39;, monospace; font-size: 12px; max-width: 70em; overflow: auto; padding: 0.5em;&quot;&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; sortedByAgePersons &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;ArrayList&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;persons&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Collections&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;sortedByAgePersons&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Comparator&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; compare&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; p1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; p2&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;valueOf&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;p1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getAge&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;compareTo&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;p2&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getAge&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;());&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;});&lt;/span&gt;&lt;/pre&gt;
With Lambdaj, you could express this as&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-color: #eeeeee; font-family: Monaco, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Lucida Console&#39;, monospace; font-size: 12px; max-width: 70em; overflow: auto; padding: 0.5em;&quot;&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; sortedByAgePersons &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;persons&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; on&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #660066;&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #000088;&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getAge&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #666600;&quot;&gt;());&lt;/span&gt;&lt;/pre&gt;
Check out more features at&amp;nbsp;&lt;a href=&quot;http://code.google.com/p/lambdaj/wiki/LambdajFeatures&quot;&gt;http://code.google.com/p/lambdaj/wiki/LambdajFeatures&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
FunctionalJava&lt;/h3&gt;
&lt;a href=&quot;http://functionaljava.org/&quot;&gt;FunctionalJava &lt;/a&gt;solves the syntax verbosity problem by using the&amp;nbsp;&lt;a href=&quot;http://javac.info/&quot;&gt;Java 7 BGGA proposal syntax&lt;/a&gt;. This adds closures as a part of the language dialect. However, this requires a pass with a pre compiler to render compilable Java code.&lt;br /&gt;
This is an example of code that adds 42 to each element in the array.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ol class=&quot;dp-j&quot; start=&quot;1&quot; style=&quot;background-color: white; border: none; color: #5c5c5c; font-family: Consolas, &#39;Courier New&#39;, Courier, mono, serif; font-size: 12px; list-style: none !important; margin: 0px 0px 1px !important; padding: 0px;&quot;&gt;
&lt;li class=&quot;alt&quot; style=&quot;border: 0px; color: inherit; line-height: 14px; list-style: none !important; margin: 0px !important; padding: 0px 3px 0px 10px !important;&quot;&gt;&lt;span style=&quot;background-color: inherit; border: none; color: black; margin: 0px; padding: 0px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;background-color: inherit; border: none; color: #006699; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;background-color: inherit; border: none; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Array&amp;lt;Integer&amp;gt;&amp;nbsp;a&amp;nbsp;=&amp;nbsp;array(&lt;/span&gt;&lt;span class=&quot;number&quot; style=&quot;background-color: inherit; border: none; color: #c00000; margin: 0px; padding: 0px;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;background-color: inherit; border: none; margin: 0px; padding: 0px;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;number&quot; style=&quot;background-color: inherit; border: none; color: #c00000; margin: 0px; padding: 0px;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;background-color: inherit; border: none; margin: 0px; padding: 0px;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;number&quot; style=&quot;background-color: inherit; border: none; color: #c00000; margin: 0px; padding: 0px;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;background-color: inherit; border: none; margin: 0px; padding: 0px;&quot;&gt;);&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;&quot; style=&quot;background-color: #f8f8f8; border: 0px; line-height: 14px; list-style: none !important; margin: 0px !important; padding: 0px 3px 0px 10px !important;&quot;&gt;&lt;span style=&quot;background-color: inherit; border: none; color: black; margin: 0px; padding: 0px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;background-color: inherit; border: none; color: #006699; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;background-color: inherit; border: none; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;Array&amp;lt;Integer&amp;gt;&amp;nbsp;b&amp;nbsp;=&amp;nbsp;a.map({&lt;/span&gt;&lt;span class=&quot;keyword&quot; style=&quot;background-color: inherit; border: none; color: #006699; font-weight: bold; margin: 0px; padding: 0px;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;background-color: inherit; border: none; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;i&amp;nbsp;=&amp;gt;&amp;nbsp;i&amp;nbsp;+&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;number&quot; style=&quot;background-color: inherit; border: none; color: #c00000; margin: 0px; padding: 0px;&quot;&gt;42&lt;/span&gt;&lt;span style=&quot;background-color: inherit; border: none; margin: 0px; padding: 0px;&quot;&gt;});&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;alt&quot; style=&quot;border: 0px; color: inherit; line-height: 14px; list-style: none !important; margin: 0px !important; padding: 0px 3px 0px 10px !important;&quot;&gt;&lt;span style=&quot;background-color: inherit; border: none; color: black; margin: 0px; padding: 0px;&quot;&gt;arrayShow(intShow).println(b);&amp;nbsp;&lt;span class=&quot;comment&quot; style=&quot;background-color: inherit; border: none; color: #008200; margin: 0px; padding: 0px;&quot;&gt;//&amp;nbsp;{43,44,45}&lt;/span&gt;&lt;span style=&quot;background-color: inherit; border: none; margin: 0px; padding: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Noteworthy is that solution also heavily relies on static imports. Check out more example at&amp;nbsp;http://functionaljava.org/examples/1.5/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;h2&gt;
My thoughts&lt;/h2&gt;
In the end though, due to the lack of anonymous functions in Java today, the best choice to program in a functional way is probably to stick to Scala, Clojure, Groovy or another of the JVM languages that has inherent support for this style until Java 8. With what we got today in Java you can still use many of the functional concepts like preferring immutable data, avoiding side effects and more.&lt;br /&gt;
&lt;br /&gt;
The above mentioned alternatives are just a few of what&#39;s out there. But common among them are either that you must rely on preprocessing some functional dialect of Java to produce compilable Java code or to use a verbose syntax like Guava. In my opinion these tradeoffs effect on readability, maintainability and possibly portability just isn&#39;t worth it.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
By the way, Brian Goetz appears 20 mins into the Java One 2012 Technical keynote to show off some collection examples of Java 8.&amp;nbsp;&lt;a href=&quot;http://medianetwork.oracle.com/video/player/1871712019001&quot;&gt;http://medianetwork.oracle.com/video/player/1871712019001&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/2665002969605561792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2012/10/functional-programming-in-java.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/2665002969605561792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/2665002969605561792'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2012/10/functional-programming-in-java.html' title='Functional programming in Java?'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-2990776458426767558</id><published>2012-09-03T20:29:00.000+02:00</published><updated>2012-09-03T20:29:45.437+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="knockout.js"/><title type='text'>Debugging Knockout.js</title><content type='html'>&lt;a href=&quot;http://knockoutjs.com/&quot;&gt;Knockout.js&lt;/a&gt;&amp;nbsp;is really powerful. A consequence of being awesome is unfortunately that its magic makes it hard to debug when it doesn&#39;t behave as you expect.&lt;br /&gt;
&lt;br /&gt;
Here&#39;s a trick that might come in handy if a data binding does not behave properly. You can print the the variables of the view model that is in the current scope by inserting this debugging tag in your HTML source.&lt;br /&gt;
&lt;div&gt;
&lt;pre data-bind=&quot;text: JSON.stringify(ko.toJS($data), null, 3)&quot; style=&quot;background-color: whitesmoke; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.148438); color: #333333; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 13px; line-height: 20px; margin-bottom: 10px; padding: 9.5px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;&amp;lt;pre data-bind=&quot;text: JSON.stringify(ko.toJS($data), null, 3)&quot;&amp;gt;&amp;lt;/pre&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Yielding a print like this in the rendered page&lt;/div&gt;
&lt;div&gt;
&lt;pre data-bind=&quot;text: JSON.stringify(ko.toJS($data), null, 3)&quot; style=&quot;background-color: whitesmoke; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.148438); color: #333333; font-family: Monaco, Menlo, Consolas, &#39;Courier New&#39;, monospace; font-size: 13px; line-height: 20px; margin-bottom: 10px; padding: 9.5px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;&quot;&gt;{
   &quot;myViewModelVar1&quot;: &quot;someValue&quot;,
   &quot;myViewModelVar2&quot;: &quot;someOtherValue&quot;
}&lt;/pre&gt;
You know any other handy tricks?&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/2990776458426767558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2012/09/debugging-knockoutjs.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/2990776458426767558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/2990776458426767558'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2012/09/debugging-knockoutjs.html' title='Debugging Knockout.js'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-5954368626480861824</id><published>2012-08-19T15:28:00.000+02:00</published><updated>2012-08-19T18:57:28.399+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="github"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="odersky"/><category scheme="http://www.blogger.com/atom/ns#" term="photo collage"/><category scheme="http://www.blogger.com/atom/ns#" term="scala"/><title type='text'>Learning Scala - Photo collage creator</title><content type='html'>I finally took the time this summer to read a book on Scala. I bought&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/gp/product/0981531644/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&amp;amp;tag=macgydevel-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0981531644&quot; target=&quot;_blank&quot;&gt;Programming in Scala&lt;/a&gt;&amp;nbsp;by Martin Odersky, the father of the language, which I think was a good choice. Regardless whether I&#39;ll write a lot of Scala programs in the future I learnt some new general programming techniques and a well needed recap on &amp;nbsp;programming language fundamentals from school. After reading it and applied it on a couple of hobby projects I must say that I feel excited.&lt;br /&gt;
&lt;br /&gt;
My first project to play around with the language is a photo collage creator where you supply the program a motive and a set of images to create a collage from. The algorithm tries to puzzle the images together to create a collage that best fits the motive.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDokGCLwzBTJCPXGIVbEdv3Ws7KeHisL3vw7tymzknBgWzs-g-C1guALdquC0pqi_LotsZj4y2LWWZJGuoVlbjZ2F_u3CzPROwNMUPObke3efgX98LImcPMN84TSoFgaa7OSjk1KwfYYmJ/s1600/motive.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDokGCLwzBTJCPXGIVbEdv3Ws7KeHisL3vw7tymzknBgWzs-g-C1guALdquC0pqi_LotsZj4y2LWWZJGuoVlbjZ2F_u3CzPROwNMUPObke3efgX98LImcPMN84TSoFgaa7OSjk1KwfYYmJ/s320/motive.png&quot; title=&quot;Motive images&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The motive to create collage from.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiawvE-iCDgF7OfpI77kfT52nk2e6hLryow3nl36K6KX7rc2bAMCGt7YJ78yHNCvr-oTgd0JTRvddQ29YWCzSxR744gctXqJlIroqDMU80s5mv-0q6F5C3XTK-yIBqED1qohyphenhyphenn67YFkwWTo/s1600/example.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;227&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiawvE-iCDgF7OfpI77kfT52nk2e6hLryow3nl36K6KX7rc2bAMCGt7YJ78yHNCvr-oTgd0JTRvddQ29YWCzSxR744gctXqJlIroqDMU80s5mv-0q6F5C3XTK-yIBqED1qohyphenhyphenn67YFkwWTo/s320/example.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The motive is divided in segments and the image catalogue is searched for best fitting images to puzzle together.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiEfenZGzd1j6nKC8JWaHEmUKnyIUJblkDxs7raToFxUXt3Nrk9EEa7MxZ4ofwEyQkpFt6sEAg2vUauIGnQF-P0DgChrC7vjk8l-tWrMD85wbL9PCIBEUHz9mFbkOh_NUpoi7J9xABV6sX/s1600/canvas.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;216&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiEfenZGzd1j6nKC8JWaHEmUKnyIUJblkDxs7raToFxUXt3Nrk9EEa7MxZ4ofwEyQkpFt6sEAg2vUauIGnQF-P0DgChrC7vjk8l-tWrMD85wbL9PCIBEUHz9mFbkOh_NUpoi7J9xABV6sX/s320/canvas.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The final collage in low-res.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
When printing the collage in high resolution, for example 16384 x 10922 pixels the effect becomes quite cool when you approach the collage from a distance to a near closeup.&lt;br /&gt;
&lt;br /&gt;
Let me just show you an arbitrary Scala function in this program that demonstrates a few of the things that I like compared to my daily work horse Java.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;java:nocontrols:nogutter&quot; name=&quot;code&quot;&gt;&amp;nbsp; /**
&amp;nbsp; &amp;nbsp;* Calculate the average brightness of a portion of an image.
&amp;nbsp; &amp;nbsp;* 
&amp;nbsp; &amp;nbsp;* @param img Image to analyse for average brightness.
&amp;nbsp; &amp;nbsp;* @param startx Start x coordinate of image subset to analyze 
&amp;nbsp; &amp;nbsp;* @param starty Start y coordinate of image subset to analyze
&amp;nbsp; &amp;nbsp;* @param stopx Stop x coordinate of image subset to analyze
&amp;nbsp; &amp;nbsp;* @param stopy Stop y coordinate of image subset to analyze
&amp;nbsp; &amp;nbsp;* @return Average brightness of the subset of the image
&amp;nbsp; &amp;nbsp;*/
&amp;nbsp; def brightness(img: BufferedImage, startx: Int, starty: Int, stopx: Int, stopy: Int): Int = {

&amp;nbsp; &amp;nbsp; @tailrec
&amp;nbsp; &amp;nbsp; def estimateBrightness(x: Int, y: Int, maxx: Int, maxy: Int, aggr: Int): Int = {
&amp;nbsp; &amp;nbsp; &amp;nbsp; if (y == maxy)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; aggr
&amp;nbsp; &amp;nbsp; &amp;nbsp; else if (x == maxx)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; estimateBrightness(startx, y + 1, maxx, maxy, aggr)
&amp;nbsp; &amp;nbsp; &amp;nbsp; else
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; estimateBrightness(x + 1, y, maxx, maxy, aggr + rgb2gray(img.getRGB(x, y)))
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; /*
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Average the brightness of the number of evaluated pixels with 
&amp;nbsp; &amp;nbsp; &amp;nbsp;* the aggregate of their calculated values.
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/
&amp;nbsp; &amp;nbsp; val aggregatedBrightness = estimateBrightness(startx, starty, stopx, stopy, 0)
&amp;nbsp; &amp;nbsp; aggregatedBrightness / ((stopx - startx) * (stopy - starty))
&amp;nbsp; }

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
As you can see, Scala is statically typed, but the compiler tries to infer as much as possible. You can create a constant variable with the &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;val &lt;/span&gt;keyword. But it will in this example figure out that the variable&amp;nbsp;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;aggregatedBrightness &lt;/span&gt;must be of the type (or subclass) &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Int &lt;/span&gt;since it is evaluated via the function&amp;nbsp;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;estimateBrightness()&lt;/span&gt;. You will save yourself a lot of boilerplate declarations.&lt;br /&gt;
&lt;br /&gt;
But what about the function&amp;nbsp;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;estimateBrightness&lt;/span&gt;? It is declared inside the scope of the function&amp;nbsp;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;brightness()&lt;/span&gt;. In Scala a function is on par with any plain old objects and can be referenced via variables or passed as arguments to functions and also be declared inside functions as a consequence. Why wouldn&#39;t it always be so?&lt;br /&gt;
&lt;br /&gt;
Everything has a value, even a &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;for &lt;/span&gt;loop or an&amp;nbsp;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;if &lt;/span&gt;clause will result in something that can be passed to a variable or statement. This makes for concise and beautiful code.&lt;br /&gt;
&lt;br /&gt;
Scala is basically a functional language but with all the imperative concepts around to make it easy for imperative people like me to make the transition to a more functional style in the tempo that suits me. In this example I made my calculations in a functional style using recursion instead of using loop constructs. I tried to write the program without any &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;for &lt;/span&gt;or &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;while &lt;/span&gt;loops at all but my conclusion is that just because it is nice to make everything recursive and functional it must not inherently be readable and understandable. I&#39;ll stick to my imperative guns when I need them for some time more.&lt;br /&gt;
&lt;br /&gt;
An interesting annotation is &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;@tailrec&lt;/span&gt; on the local function declaration. It forces the compiler to verify that this recursive function will be&lt;a href=&quot;http://blog.richdougherty.com/2009/04/tail-calls-tailrec-and-trampolines.html&quot; target=&quot;_blank&quot;&gt; tail-call optimized&lt;/a&gt;, meaning that you can be sure that this function will not create stack frames for each invocation in the recusive loop. If so you would be running out of stack after some 10 000 invocations depending on your JVM startup flags.&lt;br /&gt;
&lt;br /&gt;
To be able to write efficient and understandable functional programs my impression is that the requirements of the programmer are heightened compared to programming in plain old Java/C/C++. A challenge I&#39;m gladly willing to continue with.
&lt;br /&gt;
&lt;br /&gt;
Instead of me trying to convince you that Scala seems like a great contribution to the Java VM family I strongly recommend you to read the book. You&#39;ll definitively become a better C# or Java programmer as well afterwards.&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=macgydevel-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=as1&amp;amp;asins=0981531644&amp;amp;ref=qf_sp_asin_til&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=516C00&amp;amp;bc1=FFFFFF&amp;amp;bg1=FFFFFF&amp;amp;npa=1&amp;amp;f=ifr&quot; style=&quot;height: 240px; width: 120px;&quot;&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT2Zp60LDRs2dZfWkleQJJ9c6uOpU7GlK0tzCaHWc7of-MUDed5na_nvgZlSTmcMMGaEcrWME6TswEXMpH8h_nx6Btgc-Z6kK7juoXjpamiEKrzjynLd19V6DFLgSK8B5IuPJvFx4TBUfg/s1600/eclipse.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT2Zp60LDRs2dZfWkleQJJ9c6uOpU7GlK0tzCaHWc7of-MUDed5na_nvgZlSTmcMMGaEcrWME6TswEXMpH8h_nx6Btgc-Z6kK7juoXjpamiEKrzjynLd19V6DFLgSK8B5IuPJvFx4TBUfg/s1600/eclipse.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
If you want to play around with the Photo Collage creator program and generate som collages of your own clone the code from GitHub.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://github.com/johannoren/PhotoCollage&quot; target=&quot;_blank&quot;&gt;https://github.com/johannoren/PhotoCollage&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I have used Eclipse with the Scala plugin which make the program run without any hazzle. To configure it without any code changes, create a directory &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;photos &lt;/span&gt;in the module, and put one image in that directory as your motive and name if &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;motive.jpg&lt;/span&gt;. Put all your images that will be part of the puzzle in a subdirectory called &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;inputphotos&lt;/span&gt;. Run &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;PhotoCollage&lt;/span&gt;&amp;nbsp;and monitor the standard out until the program is finished. Run time depends mainly on the number of images in the directory &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;inputphotos&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;/ul&gt;
</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/5954368626480861824/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2012/08/learning-scala-photo-collage-creator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/5954368626480861824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/5954368626480861824'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2012/08/learning-scala-photo-collage-creator.html' title='Learning Scala - Photo collage creator'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDokGCLwzBTJCPXGIVbEdv3Ws7KeHisL3vw7tymzknBgWzs-g-C1guALdquC0pqi_LotsZj4y2LWWZJGuoVlbjZ2F_u3CzPROwNMUPObke3efgX98LImcPMN84TSoFgaa7OSjk1KwfYYmJ/s72-c/motive.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1611368930203661681.post-8895601761883922467</id><published>2012-08-04T02:21:00.000+02:00</published><updated>2014-01-05T12:37:44.163+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="raspberry pi"/><category scheme="http://www.blogger.com/atom/ns#" term="ssh"/><category scheme="http://www.blogger.com/atom/ns#" term="tomcat"/><title type='text'>Raspberry Pi - how to get ssh and Tomcat running</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5pSOz6PoQDlXcQYaHxzHCKl5h1GUR7S62NxlgjxORwe_atxnNFmELNQ_oLmQNq9Ngs5Bp2N44ujI8oBO56k6fVuVK6RxhQpnY4k90q3R68CCDsbivoOG2G7LZJfxIDjcDaU0WR2QXSduX/s1600/pi.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5pSOz6PoQDlXcQYaHxzHCKl5h1GUR7S62NxlgjxORwe_atxnNFmELNQ_oLmQNq9Ngs5Bp2N44ujI8oBO56k6fVuVK6RxhQpnY4k90q3R68CCDsbivoOG2G7LZJfxIDjcDaU0WR2QXSduX/s1600/pi.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Finally got my &lt;a href=&quot;http://www.raspberrypi.org/&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;! The cheap $25/$35 board with 700Mhz ARM cpu, GPU, 256 mb RAM, dual USB, ethernet and a bunch of general purpose IO pins. Looking awesome in its bare metal and firing it up is no problem. I flashed an SD card with the&amp;nbsp;&lt;a href=&quot;http://www.raspberrypi.org/downloads&quot; target=&quot;_blank&quot;&gt;Raspbian “wheezy”&lt;/a&gt;&amp;nbsp;Linux distribution. To write the image to the SD card I used&amp;nbsp;&lt;a href=&quot;http://www.softpedia.com/get/CD-DVD-Tools/Data-CD-DVD-Burning/Win32-Disk-Imager.shtml&quot; target=&quot;_blank&quot;&gt;Win32DiskImager&lt;/a&gt;&amp;nbsp;from a PC with SD card slot.&lt;br /&gt;
&lt;br /&gt;
After attaching USB keyboard, network cable and HDMI &amp;nbsp;it comes to life by using a micro USB as power supply. The diods flashes and even X runs quite smooth on this limited hardware.&lt;br /&gt;
&lt;br /&gt;
However, after playing around I soon realised I will be much more comfortable working on a distance from my ordinary desktop machine. So how to enable ssh?&lt;br /&gt;
A lot of tutorials talks about something as simple as this to enable ssh daemon on boot.&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sudo mv /boot/boot_enable_ssh.rc /boot/boot.rc&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Sorry, I have no such files in my /boot directory. Furthermore, when trying to start the ssh daemon with&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;/etc/init.d/ssh start&lt;/span&gt;&lt;br /&gt;
it refuses to start. Clues in the startup log are&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Could not load host key: /etc/ssh/ssh_host_rsa_key Could not load host key: /etc/ssh/ssh_host_dsa_key&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Why these are corrupt I don&#39;t know, but it&#39;s easy to regenerate them.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_rsa_key&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Make ssh daemon start permanent&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sudo update-rc.d ssh defaults&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
A&amp;nbsp;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sudo reboot&lt;/span&gt; and everything seems ok.&lt;br /&gt;
&lt;br /&gt;
Now, my mission for tonight was to get a web server running on the chipset. Here&#39;s what you need to do to make Tomcat 7 run.&lt;br /&gt;
&lt;br /&gt;
Tomcat obviously need Java:&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sudo apt-get install openjdk-6-jdk&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
And you obviously need a potent editor&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sudo apt-get install vim&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Clean up your installs to save some space on the SD card&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sudo apt-get clean&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now, download, unpack and install Tomcat&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;wget&amp;nbsp;&lt;a href=&quot;http://mirrors.axint.net/apache/tomcat/tomcat-7/v7.0.28/bin/apache-tomcat-7.0.28.tar.gz&quot;&gt;http://mirrors.axint.net/apache/tomcat/tomcat-7/v7.0.28/bin/apache-tomcat-7.0.28.tar.gz&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;tar xzf apache-tomcat-7.0.28.tar.gz&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;cd&amp;nbsp;apache-tomcat-7.0.28/conf&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;vim tomcat-users.xml&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Add a user to the authorization file, directly below&amp;nbsp;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;tomcat-users&amp;gt;&lt;/span&gt;&amp;nbsp;add&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;lt;user username=&quot;system&quot; password=&quot;raspberry&quot; roles=&quot;manager-gui&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now start Tomcat&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;cd ../bin&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sudo sh startup.sh&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Nice! From your PC (or via a browser on the Pi) surf against the Tomcat console.&lt;br /&gt;
&lt;a href=&quot;http://192.168.1.90:8080/&quot;&gt;http://192.168.1.90:8080/&lt;/a&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwlx5oR9aPS1kKBODSdxh4VW6v6NfIHbMH675myfAdCH66uIxdpnTZKohZ44ndNnfrUXv0ia4PEiH4ZTIeCkDVrytvCeHl4dcLpr9sw1mBqupq52GoDJ-WsDCOEY0-7XHKCoqOl3Nkdt-j/s1600/tomcat.gif&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwlx5oR9aPS1kKBODSdxh4VW6v6NfIHbMH675myfAdCH66uIxdpnTZKohZ44ndNnfrUXv0ia4PEiH4ZTIeCkDVrytvCeHl4dcLpr9sw1mBqupq52GoDJ-WsDCOEY0-7XHKCoqOl3Nkdt-j/s1600/tomcat.gif&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
(Figure out the ip address via for example &lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;ifconfig&lt;/span&gt;)&lt;br /&gt;
&lt;br /&gt;
It takes a short while to warm up the server but then you can login via Manager App. Now, it&#39;s business as usual. Upload a war archive and you have a nifty web server running you web application, for $35!&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://macgyverdev.blogspot.com/feeds/8895601761883922467/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://macgyverdev.blogspot.com/2012/08/raspberry-pi-how-to-get-ssh-and-tomcat.html#comment-form' title='33 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/8895601761883922467'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1611368930203661681/posts/default/8895601761883922467'/><link rel='alternate' type='text/html' href='http://macgyverdev.blogspot.com/2012/08/raspberry-pi-how-to-get-ssh-and-tomcat.html' title='Raspberry Pi - how to get ssh and Tomcat running'/><author><name>Johan Norén</name><uri>http://www.blogger.com/profile/14636265442070759165</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Nwm5r8QCWqO47u2YiIUnUbSU_itkXCttaRDPnWaxosB8nz_ciTZAvV4euMYi2ho1M-JmBAvXBp8FgHUepvRRFJ_5vVKiMSmrnOcQg-y_lMstfw03ol8TrKxdrxPd5g/s220/IMG_1243.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5pSOz6PoQDlXcQYaHxzHCKl5h1GUR7S62NxlgjxORwe_atxnNFmELNQ_oLmQNq9Ngs5Bp2N44ujI8oBO56k6fVuVK6RxhQpnY4k90q3R68CCDsbivoOG2G7LZJfxIDjcDaU0WR2QXSduX/s72-c/pi.jpg" height="72" width="72"/><thr:total>33</thr:total></entry></feed>