banterly.net_ghost4.rss.xml - sfeed_tests - sfeed tests and RSS and Atom files | |
git clone git://git.codemadness.org/sfeed_tests | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
banterly.net_ghost4.rss.xml (179684B) | |
--- | |
1 <?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/… | |
2 ]]></description><link>https://www.banterly.net/2021/07/31/new-in-git-sw… | |
3 <img src="https://www.banterly.net/content/images/2021/07/1200px-Git-log… | |
4 </blockquote> | |
5 <p>For those that work with git for some time, it is not often that you … | |
6 <ul> | |
7 <li><code>git restore</code></li> | |
8 <li><code>git switch</code></li> | |
9 </ul> | |
10 <p>To understand why they came to be, let's first visit our old fri… | |
11 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
12 <p><code>git checkout</code> is one of the many reasons why newcomers fi… | |
13 The way most people use it is to switch the active branch in their local… | |
14 <p><code>git checkout develop</code></p> | |
15 <p>You can also make your HEAD pointer reference a specific commit inste… | |
16 <p><code>git checkout f8c540805b7e16753c65619ca3d7514178353f39</code></p> | |
17 <p>Where things get tricky is that if you provide a file as an argument … | |
18 For example, if you checked out the develop branch and you made some cha… | |
19 <p><code>git checkout -- test.txt</code></p> | |
20 <h3 id="amethodtothemadness">A method to the madness</h3> | |
21 <p>If you first look at these two behaviors you might think that it does… | |
22 <p><code>git checkout <tree-ish> -- <pathspec></code></p> | |
23 <p>What is <code><tree-ish></code> ? It can mean a lot of differen… | |
24 <p><code>git checkout main -- test.txt</code></p> | |
25 <p>With this in mind, maybe things start to make sense. When you provide… | |
26 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
27 <p>So even if things may start to make sense after reading the previous … | |
28 <h3 id="switch">Switch</h3> | |
29 <p>This one implements the behavior of git checkout when running it only… | |
30 <p><code>git switch develop</code></p> | |
31 <p>While with <code>git checkout</code> you can switch to a commit and t… | |
32 <p><code>git switch -d f8c540805b7e16753c65619ca3d7514178353f39</code></… | |
33 <p>Another difference is that with git checkout you can create and switc… | |
34 <code>git checkout -b new_branch</code></p> | |
35 <p>You can do the same with the new one, but the flag is -c:<br> | |
36 <code>git switch -c new_branch</code></p> | |
37 <h3 id="restore">Restore</h3> | |
38 <p>This one implements the behavior of git when running it against a fil… | |
39 <p><code>git restore -- test.txt</code></p> | |
40 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h1 id="conclu… | |
41 <p>These methods are still marked experimental, but for all intents and … | |
42 <p>More details about the two commands can be found in their git documen… | |
43 <ul> | |
44 <li><a href="https://git-scm.com/docs/git-switch">git switch</a></li> | |
45 <li><a href="https://git-scm.com/docs/git-restore">git restore</a></li> | |
46 </ul> | |
47 <!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![… | |
48 <p>Due to work and family obligations, this took more time than expected… | |
49 <p>I will follow up this article with part 2 where I will explain more t… | |
50 <h2 id="solvingaproblem">Solving a problem</h2> | |
51 <p>Firstly, if you are planning on writing a plugin(or any piece of soft… | |
52 <h3 id="builders">Builders</h3> | |
53 <p>If you are coming from the Java or C# world(and not only) I assume yo… | |
54 <p>It always irked me the wrong way that, while being a lot better than … | |
55 <h3 id="solutions">Solutions</h3> | |
56 <p>My first attempt at solving this problem was to define a series of Bu… | |
57 <p>In practice, it turns out that the Step Builder pattern is not ideal … | |
58 <p>The previously mentioned post actually was the inspiration for my fin… | |
59 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card kg-card… | |
60 <p>Now let us get started with some Intellij platform quirks that you sh… | |
61 <h3 id="1extensionpointshelp">1. Extension Points Help</h3> | |
62 <p>Extension Points are quite a central concept in Intellij plugin devel… | |
63 I discovered it quite late, but luckily there is a tool that JetBrains h… | |
64 You can access it <a href="https://plugins.jetbrains.com/intellij-platfo… | |
65 <ol> | |
66 <li>get from <a href="https://plugins.jetbrains.com/docs/intellij/extens… | |
67 <li>search for the one that you think will probably help you to accompli… | |
68 <li>look at the related platform class which may have some documentation… | |
69 <li>look for other plugins implementing it since that will most likely a… | |
70 </ol> | |
71 <h3 id="2enablejavafunctionality">2. Enable Java functionality</h3> | |
72 <p>My plugin is in Java developed for Java. I had a lot of headaches whe… | |
73 <ul> | |
74 <li>declare in your plugin.xml file the following:</li> | |
75 </ul> | |
76 <pre><code class="language-xml"><depends>com.intellij.modules.java… | |
77 </code></pre> | |
78 <ul> | |
79 <li>if you are using the gradle-intellij-plugin(as you should) then you … | |
80 </ul> | |
81 <pre><code class="language-groovy">intellij { | |
82 plugins = ['com.intellij.java'] | |
83 // ... | |
84 } | |
85 </code></pre> | |
86 <p>The above is for groovy based graddle. For kotlin based graddle use:<… | |
87 <pre><code class="language-kotlin">intellij { | |
88 setPlugins("java") | |
89 // ... | |
90 } | |
91 </code></pre> | |
92 <h3 id="psiviewer">PsiViewer</h3> | |
93 <p>In the Intellij platform, the contents of a file are structured under… | |
94 A very helpful tool that will allow you to experiment and discover how t… | |
95 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
96 <pre><code>idea.is.internal=true | |
97 </code></pre> | |
98 <h3 id="debugging">Debugging</h3> | |
99 <p>For sure you will want to debug your plugin in order to solve some is… | |
100 First, you should be happy to know that you do not need to create any sp… | |
101 <p>If you try to do this as-is, you will probably encounter quite fast w… | |
102 <ul> | |
103 <li><em>-Didea.auto.reload.plugins=false</em></li> | |
104 <li><em>-Didea.ProcessCanceledException=disabled</em></li> | |
105 </ul> | |
106 <p>The way I managed to do this was with the following configuration in … | |
107 <pre><code class="language-kotlin"> withType<org.jetbrains.intellij.t… | |
108 jvmArgs("-Didea.auto.reload.plugins=false") | |
109 jvmArgs("-Didea.ProcessCanceledException=disabled") | |
110 } | |
111 </code></pre> | |
112 <h2 id="tobecontinued">To be continued</h2> | |
113 <p>This was a fun experience for me and will try to improve on the curre… | |
114 <!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![… | |
115 <img src="https://www.banterly.net/content/images/2020/04/The-Silver-Lin… | |
116 </blockquote> | |
117 <p>As you all know, maybe too much which is partly the point of this pos… | |
118 <h2 id="doomsayersclub">Doomsayers Club</h2> | |
119 <p>Monitoring the online sphere during the last few weeks, I observed so… | |
120 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
121 <p>I want to put in the same category the journalists who either do not … | |
122 <p>Everyday I see a titles that are either misleading or are meant to in… | |
123 <p>I will give two example of titles that I see almost every day.</p> | |
124 <ul> | |
125 <li>"The number of new cases has skyrocketed" - this I saw a l… | |
126 <li>"Scary new number of deaths today: 1000". Regarding this o… | |
127 <ul> | |
128 <li>At the time of this writing there have been reported 65 000 deaths w… | |
129 <li>In the first 10 hours of this day it is estimated that 65 000 deaths… | |
130 <li>Since the beginning of the year it is estimated around 15 000 000 pe… | |
131 </ul> | |
132 </li> | |
133 </ul> | |
134 <p>Looking at the examples above I hope you understand why the scary and… | |
135 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
136 <h2 id="puttingsomepositivelightintoallthismess">Putting some positive l… | |
137 <p>Today I want to do the opposite of what I mentioned above. I will com… | |
138 <p>Before I begin I want to be clear, I am not dismissing all the negati… | |
139 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
140 <p>"Wash your hands thoroughly when coming from outside!", &qu… | |
141 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h3 id="prepar… | |
142 <p>COVID-19 has shown that the world is not prepared for an epidemic of … | |
143 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h3 id="antiva… | |
144 <p>Most anti-vaxxers, at least the moderate ones, consider vaccines too … | |
145 Now with the whole world witnessing how much global health and economic … | |
146 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
147 <p>The current situation has forced organizations to widen the range of … | |
148 <ul> | |
149 <li>The employee saves on commute time, time which he can spend on learn… | |
150 <li>For employers, it would allow them to transform their local pool of … | |
151 <li>As an extra benefit, less commuters will mean less traffic which mea… | |
152 </ul> | |
153 <p>Of course this is not possible for everyone and some may just prefer … | |
154 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h3 id="animal… | |
155 <p>With people suffering from loneliness during these times of isolation… | |
156 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
157 <p>There are a lot of jobs that cannot be performed from home. As a resu… | |
158 The idea is that if we as a society can survive and even prosper without… | |
159 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h3 id="lessfo… | |
160 <p>Another thing that has been exposed during this pandemic is the amoun… | |
161 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h3 id="lessdi… | |
162 <p>Polarization has been skyrocketing in the last decade so one of the h… | |
163 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h2 id></h2> | |
164 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h2 id="sharey… | |
165 <p>Those are some of the main positive ideas I identified. If you make a… | |
166 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
167 <img src="https://www.banterly.net/content/images/2020/02/meme2.jpg" alt… | |
168 </blockquote> | |
169 <p>Sadly for me (I guess happily for my sanity) sometimes when I read an… | |
170 <p>For some crazy reason, recently I revisited the two well known graph … | |
171 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
172 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
173 <p>BFS starts with a node of the graph which will act as a root node in … | |
174 For the example above the traversal order would be:</p> | |
175 <ul> | |
176 <li>Level 0: 1</li> | |
177 <li>Level 1: 2 -> 3 -> 4</li> | |
178 <li>Level 2: 5 -> 6 -> 7</li> | |
179 <li>Level 3: 8 -> 9</li> | |
180 </ul> | |
181 <p>The classic implementation of this algorithm is iterative and involve… | |
182 <pre><code class="language-java">void breadthFirstTraversal(Node root) { | |
183 if (root == null) | |
184 return; | |
185 | |
186 //Create and initialize the set which | |
187 //will contain discovered nodes | |
188 Set<Node> discovered = new HashSet<>(); | |
189 discovered.add(root); | |
190 | |
191 //Create and initialize queue which | |
192 //will contain the nodes left to visit | |
193 Deque<Node> queue = new ArrayDeque<>(); | |
194 queue.offer(root); | |
195 | |
196 while (!queue.isEmpty()) { | |
197 Node current = queue.poll(); | |
198 | |
199 //visit the node; in this case just print | |
200 // the node value | |
201 System.out.println(current.getValue()); | |
202 | |
203 for (Node child : current.getChildren()) { | |
204 //add to the queue any child node of the | |
205 //current node that has not already been discovered | |
206 //and also add it to the set of | |
207 //discovered nodes | |
208 if (!discovered.contains(child)) { | |
209 queue.offer(child); | |
210 discovered.add(child); | |
211 } | |
212 } | |
213 } | |
214 } | |
215 </code></pre> | |
216 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h2 id="depthf… | |
217 <p>Now that we know what BFS is, it should be intuitive how using a DFS … | |
218 <ul> | |
219 <li>Branch 1: 1 -> 2 -> 5 -> 8 -> 7 > 9</li> | |
220 <li>Branch 2: 6</li> | |
221 <li>Branch 3: 3 -> 4</li> | |
222 </ul> | |
223 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
224 <pre><code class="language-java">void depthFirstTraversal(Node root){ | |
225 if(root == null){ | |
226 return; | |
227 } | |
228 | |
229 //initialize the set which will contain | |
230 // our discovered nodes | |
231 Set<Node> discovered = new HashSet<>(); | |
232 //call the recursive function starting | |
233 //with the provided root | |
234 dfsRecursive(root, discovered); | |
235 } | |
236 | |
237 void dfsRecursive(Node current, Set<Node> discovered){ | |
238 //mark the node as discovered | |
239 discovered.add(current); | |
240 | |
241 //visit the node; in this case we just | |
242 //print the value of the node | |
243 System.out.println(current.getValue()); | |
244 | |
245 //recursively call the function on all of | |
246 //the children of the current node if | |
247 //they have not already been discovered | |
248 for(Node child : current.getChildren()){ | |
249 if(!discovered.contains(child)) { | |
250 dfsRecursive(child, discovered); | |
251 } | |
252 } | |
253 } | |
254 </code></pre> | |
255 <p>At this point your teacher will say: "You know what? To help you… | |
256 1. Use a stack instead of a queue.<br> | |
257 2. Check if we have visited a node after we pop from the stack. This is … | |
258 <p>The classic implementation looks something like this (even on Wikiped… | |
259 <pre><code class="language-java">void depthFirstTraversalIterative(Node … | |
260 if (root == null) | |
261 return; | |
262 | |
263 //Create the set which | |
264 // will contain discovered nodes | |
265 Set<Node> discovered = new HashSet<>(); | |
266 | |
267 //Create and initialize stack which | |
268 // will contain the nodes left to visit | |
269 Deque<Node> stack = new ArrayDeque<>(); | |
270 stack.push(root); | |
271 | |
272 while (!stack.isEmpty()) { | |
273 Node current = stack.pop(); | |
274 | |
275 if(!discovered.contains(current)){ | |
276 discovered.add(current); | |
277 | |
278 //visit the node; in this case just print | |
279 // the node value | |
280 System.out.println(current.getValue()); | |
281 | |
282 //add to the stack all the children | |
283 //of the current node | |
284 for(Node child : current.getChildren()){ | |
285 stack.push(child); | |
286 } | |
287 } | |
288 } | |
289 } | |
290 </code></pre> | |
291 <p>The student runs the two versions of DFS and he sees that the results… | |
292 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
293 <p>A more inquisitive mind will stop and ask: Wait a minute, where do th… | |
294 <p>The first one is usually answered with the following: When implementi… | |
295 <p>The second difference is not usually discussed though and here things… | |
296 First let's ask ourselves why in the BFS implementation we check if… | |
297 To answer that let's see what happens if we check after we poll the… | |
298 Node 4 will in both cases be already in our queue. If we do what we usua… | |
299 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
300 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
301 <p>If we turn our attention to the DFS iterative version we can think th… | |
302 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
303 <li>Branch 1: 1 -> 2 -> 5 -> 8</li> | |
304 <li>Branch 2: 6</li> | |
305 <li>Branch 3: 7 -> 9</li> | |
306 <li>Branch 4: 3</li> | |
307 <li>Branch 5: 4</li> | |
308 </ul> | |
309 <p>Wait what? We get different result than in the recursive approach...t… | |
310 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h2 id="beingm… | |
311 <p>So what is happening here? We need to realize that just by using a st… | |
312 <p>If you think a little more in depth about what the recursive version … | |
313 <p>In our iterative approach we save all the children on the stack with … | |
314 <p>So I think here is where people are misled because when we take all i… | |
315 <ul> | |
316 <li>When we implement BFS we are being taught that we do not want duplic… | |
317 <li>When we implement iterative DFS we are being taught to forget about … | |
318 </ul> | |
319 <p>The second teaching seems contradictory with the first one. If this i… | |
320 <p>Because of the differences between the inner workings of the recursiv… | |
321 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
322 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h2 id="truedf… | |
323 <p>The good news is that once we actually understand what the recursive … | |
324 <pre><code class="language-java">// data structure for storing the requi… | |
325 class TraversalInfo{ | |
326 Node parent; | |
327 int childPos; | |
328 | |
329 public TraversalInfo(Node parent, int childPos) { | |
330 this.parent = parent; | |
331 this.childPos = childPos; | |
332 } | |
333 | |
334 public Node getParent() { | |
335 return parent; | |
336 } | |
337 | |
338 | |
339 public int getChildPos() { | |
340 return childPos; | |
341 } | |
342 | |
343 public void setChildPos(int childPos) { | |
344 this.childPos = childPos; | |
345 } | |
346 } | |
347 | |
348 void trueDepthFirstTraversalIterative(Node root){ | |
349 | |
350 //as always create and initialize | |
351 //the set of discovered nodes | |
352 Set<Node> discovered = new HashSet<>(); | |
353 discovered.add(root); | |
354 | |
355 //create and initialize the stack which will | |
356 //indicate which node to visit next. You can | |
357 //observer that we are not saving anymore directly | |
358 //what node to visit next, but a parent node and | |
359 //the index of its child that we should visit next | |
360 Deque<TraversalInfo> stack = new ArrayDeque<>(); | |
361 stack.push(new TraversalInfo(root, 0)); | |
362 | |
363 //we visit the root node before going | |
364 //into our loop | |
365 System.out.println(root.getValue()); | |
366 | |
367 | |
368 while (!stack.isEmpty()) { | |
369 TraversalInfo current = stack.pop(); | |
370 Node currentParent = current.getParent(); | |
371 int currentChildPos = current.getChildPos(); | |
372 | |
373 //we check if there are more child nodes | |
374 if(currentChildPos < currentParent.getChildren().size()){ | |
375 Node child = currentParent.getChildren().get(currentChil… | |
376 //we save in the stack the next child index | |
377 //together with its parent | |
378 current.setChildPos(currentChildPos + 1); | |
379 stack.push(current); | |
380 | |
381 //check if current child discovered already | |
382 if(!discovered.contains(child)){ | |
383 //add it to the set of discovered nodes | |
384 discovered.add(child); | |
385 //visit the child; in this case just print out its v… | |
386 System.out.println(child); | |
387 //add to the stack the info for visiting its child n… | |
388 //starting from the first one | |
389 stack.push(new TraversalInfo(child, 0)); | |
390 } | |
391 } | |
392 } | |
393 } | |
394 | |
395 </code></pre> | |
396 <p>As we can see this implementation is a little more complex than the o… | |
397 <p>In some circles this iterative implementation and the recursive one a… | |
398 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
399 <p>Let me know in the comments for how many of you this was obvious from… | |
400 <p>Also let me know of any other simmilar example that you may have.</p> | |
401 <p>If you like the content do not forget to subscribe!</p> | |
402 <!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![… | |
403 For a while know, I became more and more amazed on how useful enums are … | |
404 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
405 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h2 id="whatis… | |
406 <p>In Java enum is short for Enumerated type and in other parts it is al… | |
407 <p>They are data types that consist of a set of named values called eith… | |
408 <p>Basically they define a type of which only certain values are possibl… | |
409 <p>Specific to Java, an enum has quite an extended behavior: it is like … | |
410 <p>If this sounds too abstract, let us give an example that will introdu… | |
411 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
412 <p>Let's imagine that we have a function that accepts as a paramete… | |
413 <pre><code class="language-java">public void function(String dayOfWeek){ | |
414 //do stuff | |
415 } | |
416 </code></pre> | |
417 <p>And a user would call it like this:</p> | |
418 <pre><code class="language-java">// some logic | |
419 function("Thursday"); | |
420 // some other logic | |
421 </code></pre> | |
422 <p>One big problem with this is that a user could pass anything to our f… | |
423 <pre><code class="language-java">// some logic | |
424 function("banterly"); | |
425 // some other logic | |
426 </code></pre> | |
427 <p>A user could either be making a typo, pass in a wrong value or just d… | |
428 <p>Another serious implication is performance degradation: if the functi… | |
429 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
430 <pre><code class="language-java">public static final int MONDAY = 1; | |
431 public static final int TUESDAY = 2; | |
432 public static final int WEDNESDAY = 3; | |
433 public static final int THURSDAY = 4; | |
434 public static final int FRIDAY = 5; | |
435 public static final int SATURDAY = 6; | |
436 public static final int SUNDAY = 7; | |
437 | |
438 public void function(int weekOfDay){ | |
439 //do stuff | |
440 } | |
441 | |
442 //call it later like this | |
443 function(SUNDAY); | |
444 | |
445 </code></pre> | |
446 <p>This solves the performance problem and it allows the users to pass i… | |
447 <pre><code class="language-java">//traffic lights | |
448 public static final int GREEN = 0; | |
449 public static final int ORANGE = 1; | |
450 public static final int RED = 2; | |
451 | |
452 //for fruits | |
453 public static final int PEAR = 0; | |
454 public static final int ORANGE = 1; // will give a compile error since O… | |
455 public static final int APPLE = 2; | |
456 </code></pre> | |
457 <p>If defined in the same class the above will not compile, so you will … | |
458 <pre><code class="language-java">public static final int TRAFFIC_LIGHT_O… | |
459 public static final int FRUIT_ORANGE = 1; | |
460 </code></pre> | |
461 <p>Another issue with these definitions is that a function can now accep… | |
462 <p>I hope this entire essay convinced you why it is not a good idea to u… | |
463 <h3 id="usingenumsempoweringtheuserandthecompiler">Using enums - Empower… | |
464 <p>Let us define a very simple enum that will represent the days of the … | |
465 <pre><code class="language-java">enum Weekday {MONDAY, TUESDAY, WEDNESDA… | |
466 </code></pre> | |
467 <p>Now we can define our function to take a parameter of type Weekday:</… | |
468 <pre><code class="language-java">public void function(Weekday weekday){ | |
469 //do stuff | |
470 } | |
471 | |
472 // later on we call it | |
473 function(Weekday.TUESDAY); | |
474 </code></pre> | |
475 <p>This will mean that a user can only pass in one of the values defined… | |
476 <ul> | |
477 <li>No risk of the user accidentally typing a wrong input or a malicious… | |
478 <li>The user knows what he needs to pass in by just looking at the signa… | |
479 <li>Another benefit over the previous two methods is that the enum types… | |
480 <li>Using enums opens the door for using EnumSet and EnumMap, two type s… | |
481 </ul> | |
482 <pre><code class="language-java">//obsolete idiom | |
483 public class Renderer{ | |
484 public static final int COLOR_RED = 1; | |
485 public static final int COLOR_BLUE = 2; | |
486 public static final int COLOR_ORANGE = 4; | |
487 public static final int COLOR_GREEN = 8; | |
488 | |
489 public void draw(int colors){ | |
490 // draw | |
491 } | |
492 } | |
493 </code></pre> | |
494 <p>Calling the draw function for colors blue and red would be something … | |
495 <pre><code class="language-java">renderer.draw(COLOR_RED | COLOR_BLUE); | |
496 </code></pre> | |
497 <p>With an EnumMap you do not have to apply any of those tricks, things … | |
498 <pre><code class="language-java">public class Renderer{ | |
499 public enum Color{RED, BLUE, GREEN, ORANGE} | |
500 | |
501 public void draw(Set<Color> colors){ | |
502 //draw | |
503 } | |
504 } | |
505 </code></pre> | |
506 <p>We now can call the draw method like this:</p> | |
507 <pre><code class="language-java">renderer.draw(EnumSet.of(Color.RED, Col… | |
508 </code></pre> | |
509 <ul> | |
510 <li>Enum values are by definition the only instances created of the enum… | |
511 <li>It helps the compiler identify attempts to compare incompatible type… | |
512 </ul> | |
513 <pre><code class="language-java">enum Weekday {MONDAY, TUESDAY, WEDNESDA… | |
514 enum Color{BLACK, WHITE}; | |
515 | |
516 if(Color.BLACK.equals(Weekday.Monday); // does not throw a compile error… | |
517 if(Color.BLACK == Weekday.Monday); // does not compile because the compi… | |
518 </code></pre> | |
519 <p>So to recap, if your function or logic needs to use a parameter or va… | |
520 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
521 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><p>The singlet… | |
522 The classical best practice approach is to use something like the follow… | |
523 <pre><code class="language-java">public class Singleton{ | |
524 private static final Singleton INSTANCE = new Singleton(); | |
525 | |
526 private Singleton(){}; | |
527 public static Singleton getInstance(){ | |
528 return INSTANCE; | |
529 } | |
530 public void doSomething(){ | |
531 //do stuff | |
532 } | |
533 | |
534 //other methods ... | |
535 } | |
536 </code></pre> | |
537 <p>While this works, there are some issue:</p> | |
538 <ul> | |
539 <li>If you want your singleton class to be serializable you need not onl… | |
540 <li>The class could still be instantiated with a new instance through th… | |
541 </ul> | |
542 <p>In light of these issues Joshua Bloch recommends, in his famous book … | |
543 <p>So our example from above would become:</p> | |
544 <pre><code class="language-java">public enum Singleton{ | |
545 INSTANCE; | |
546 | |
547 public void doSomething(){ | |
548 // do stuff | |
549 } | |
550 | |
551 // other methods | |
552 } | |
553 </code></pre> | |
554 <p>First of all this looks a lot cleaner right? Now how does this solve … | |
555 <ul> | |
556 <li>I will not enter in all the details of how serialization in Java wor… | |
557 <li>The enum type actually extends the java Enum class. The reason that … | |
558 </ul> | |
559 <pre><code class="language-java">if ((clazz.getModifiers() & Modifie… | |
560 throw new IllegalArgumentException("Cannot reflectively create … | |
561 </code></pre> | |
562 <p>So as a best practice, unless one of the caveats from above applies t… | |
563 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
564 <p>One of the latest things I realized an enum is actually really useful… | |
565 <p>Lets have a quick recap of the pattern: The Strategy Pattern defines … | |
566 <p>If that definition sounds to abstract let's showcase its classic… | |
567 <p>First we need to identify a case where we could apply this pattern:<b… | |
568 Let us imagine we have a bar and since we want to attract customers we h… | |
569 <ul> | |
570 <li>we have the normal hours where clients are charged the full price of… | |
571 <li>we have the morning happy hour where clients are charged 0.5 of what… | |
572 <li>we have the afternoon happy hour where clients are charged 0.75 of w… | |
573 </ul> | |
574 <p>So we define an interface that encapsulates this logic(don't eve… | |
575 <pre><code class="language-java">interface BillingStrategy{ | |
576 double bill(double rawPrice); | |
577 } | |
578 </code></pre> | |
579 <p>Then we define different classes that implement the <em>BillingStrate… | |
580 <pre><code class="language-java">public MorningHappyHourBilling implemen… | |
581 double bill(double rawPrice){ | |
582 return rawPrice * 0.5; | |
583 } | |
584 } | |
585 | |
586 public EveningHappyHourBilling implements BillingStrategy{ | |
587 double bill(double rawPrice){ | |
588 return rawPrice * 0.75; | |
589 } | |
590 } | |
591 | |
592 public FullPriceBilling implements BillingStrategy{ | |
593 double bill(double rawPrice){ | |
594 return rawPrice ; | |
595 } | |
596 } | |
597 </code></pre> | |
598 <p>Then we define a <em>BillCalculator</em> that would be used by the ba… | |
599 <pre><code class="language-java">BillCalculator { | |
600 private BillingStrategy billingStrategy = new FullPriceBilling() ; | |
601 | |
602 public void setBillingStrategy(BillingStrategy billingStrategy){ | |
603 this.billingStrategy = billingStrategy; | |
604 } | |
605 | |
606 public void printBill(int price, String customer){ | |
607 System.out.format("Bill for customer %s is %f", custom… | |
608 } | |
609 } | |
610 </code></pre> | |
611 <p>As you can see, now the hypothetical <em>Bar</em> class when using th… | |
612 <p>Now you might say: "this is nice and all, but it brings quite so… | |
613 <ul> | |
614 <li>we have to define a new interface</li> | |
615 <li>we need to define a new class for each possible strategy,</li> | |
616 </ul> | |
617 <p>You are right, usually thats the tradeoff when using design patterns,… | |
618 <p>Instead of defining an interface, we will define an enum as the type … | |
619 <pre><code class="language-java">public enum BillingStrategy{ | |
620 MORNING_HAPPY_HOUR{ | |
621 @Override | |
622 public double bill(double price){ | |
623 return rawPrice * 0.5; | |
624 } | |
625 }, | |
626 AFTERNOON_HAPPY_HOUR{ | |
627 @Override | |
628 public double bill(double price){ | |
629 return rawPrice * 0.75; | |
630 } | |
631 }, | |
632 FULL_PRICE{ | |
633 @Override | |
634 public double bill(double price){ | |
635 return rawPrice; | |
636 } | |
637 } | |
638 | |
639 public abstract double bill(double price); | |
640 } | |
641 </code></pre> | |
642 <p>Now we can redefine our BillCalculator like this:</p> | |
643 <pre><code class="language-java">BillCalculator { | |
644 private BillingStrategy billingStrategy = BillingStrategy.FULL_PRICE; | |
645 | |
646 public void setBillingStrategy(BillingStrategy billingStrategy){ | |
647 this.billingStrategy = billingStrategy; | |
648 } | |
649 | |
650 public void printBill(int price, String customer){ | |
651 System.out.format("Bill for customer %s is %f", custom… | |
652 } | |
653 } | |
654 </code></pre> | |
655 <p>A lot cleaner right?</p> | |
656 <p>As an added bonus, if you are familiar with the State pattern you kno… | |
657 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
658 <p>That is all I have for now to share and I hope at least some of you d… | |
659 <p>If you have some other great use cases for enums or some insights abo… | |
660 <p>If you enjoyed the article you can subscribe or like our facebook pag… | |
661 <a href="https://www.facebook.com/pg/banterly.net/posts/">https://www.fa… | |
662 <!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![… | |
663 <p>"Success is getting what you want, happiness is wanting what you… | |
664 </blockquote> | |
665 <p>A trend that started in companies for a few years now has been for ma… | |
666 <img src="https://www.banterly.net/content/images/2019/01/post2-1.jpg" a… | |
667 </blockquote> | |
668 <p>A trend that started in companies for a few years now has been for ma… | |
669 <ul> | |
670 <li>Why the hell would companies care about developer happiness?</li> | |
671 <li>What would actually make a developer happy?</li> | |
672 </ul> | |
673 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
674 <p>The ideas expressed will probably be biased towards the western socie… | |
675 <p>If anyone wants to express some insights from different perspectives … | |
676 With this small disclaimer in place lets see what we have here.</p> | |
677 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h2 id="whydev… | |
678 <p>First question you may have is: why am I talking about developer happ… | |
679 <p>First of all, development is my profession right now, so I know most … | |
680 <p>Secondly, the thing is that in general companies do not care that muc… | |
681 The reason why developers are these days in the privileged position of c… | |
682 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
683 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h2 id="thecos… | |
684 <p>So why would a company care if it has a high turnover rate, cant they… | |
685 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
686 <h4 id="directcosts">Direct costs:</h4> | |
687 <ul> | |
688 <li>Recruiter fees - when using external recruiters their fee is usually… | |
689 <li>Advertising the open position on different channels like job website… | |
690 <li>In some cases external training for the new employee.</li> | |
691 <li>Travel expenses if the candidate is brought in from a foreign countr… | |
692 </ul> | |
693 <h4 id="indirectcosts">Indirect costs</h4> | |
694 <ul> | |
695 <li>Loss of productivity caused by the team having one less member.</li> | |
696 <li>Loss of productivity caused by team members interviewing candidates.… | |
697 <li>Even after a good candidate is found, there will be extra loss of pr… | |
698 <li>A high turnover rate also impacts the morale of the other employees … | |
699 <li>A place with a high turnover rate may become infamous in the job mar… | |
700 </ul> | |
701 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h2 id="whatca… | |
702 <h4 id="numbersanddata">Numbers and data</h4> | |
703 <p>Some companies may still not look seriously at the problem of employe… | |
704 <h4 id="theexitinterview">The exit interview</h4> | |
705 <p>Secondly they should have in place the so called exit interviews: a t… | |
706 <p>This activity should be carefully planned since it is easy to gather … | |
707 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
708 <p>The exit interview is useful not only to find causes of dissatisfacti… | |
709 <h4 id="awareness">Awareness</h4> | |
710 <p>Of course another action point would be to have a pulse of all employ… | |
711 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h2 id="whatbr… | |
712 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
713 <h3 id="money">Money</h3> | |
714 <p>Lets first get rid of the elephant in the room. Usually when companie… | |
715 <p>There are a couple of points to be made here. First is that some peop… | |
716 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
717 <p>Of course there are companies who just cant afford to pay as much mon… | |
718 <p>Another aspect worth mentioning is that even if an employee is satisf… | |
719 <p>One last point regarding this topic is that an increase in salary is … | |
720 <p>I guess there is more to say about this aspect so let me know in the … | |
721 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h3 id="manage… | |
722 <p>In the end probably most of the other subjects can be tied to this on… | |
723 <p>For a developer there are two aspects to this topic</p> | |
724 <ul> | |
725 <li><strong>his direct manager</strong> - the one to whom he directly re… | |
726 <li><strong>upper management</strong> - the ones that control the compan… | |
727 </ul> | |
728 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
729 <p>This relationship is very important since, for a developer, his direc… | |
730 Because of this, when talking about loyalty, the developer will most of … | |
731 <p>An employee wants to feel appreciated, trusted and cared for by the c… | |
732 <p>In a lot of cases, what the employee wants will go against the desire… | |
733 <p>In Daniel Pinks book <em><strong>Drive</strong></em> it is argued tha… | |
734 <ul> | |
735 <li>Autonomy - Everyone wants to express himself and have a degree of fr… | |
736 <li>Mastery - developers want to get better at what they do and need the… | |
737 <li>Purpose - Everyone needs a purpose for what they are doing. If in a … | |
738 </ul> | |
739 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
740 <h4 id="uppermanagement">Upper management</h4> | |
741 <p>No matter how hard the direct manager tries, if the people in control… | |
742 <p>One of the most cited problems from developers perspective about big … | |
743 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h3 id="benefi… | |
744 <p>Benefits are an excellent way to provide extra value to employees in … | |
745 Another thing is that some benefits scale better than salary increases: … | |
746 <!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h3 id="thelis… | |
747 <!--kg-card-end: markdown--><figure class="kg-card kg-image-card"><img s… | |
748 <p>Since this article became longer than I wanted I will leave you with … | |
749 <ul> | |
750 <li>Team events, not only company events - team events are usually more … | |
751 <li>Minimal bureaucracy - No need for 5 committees approval for each sma… | |
752 <li>Communication and interaction with customers - it brings a lot of jo… | |
753 <li>Flexible schedule - no hard enforced scheduled working hours, allow … | |
754 <li>Good tools - The easier it is to use the tools required to do the jo… | |
755 <li>Office where you can focus when you work. That is why a lot of devel… | |
756 <li>Properly equipped office: 2 monitors(or 1 big one), a nice chair, a … | |
757 <li>Good work life balance - when developers start having families this … | |
758 <li>Management transparency - clear communications on why certain decisi… | |
759 <li>Clear responsibilities of persons in the company and clear examples … | |
760 <li>Investment in human resources</li> | |
761 </ul> | |
762 <!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![… | |
763 <p>"Conceal a flaw, and the world will imagine the worst" - Ma… | |
764 </blockquote> | |
765 <p>In my <a href="https://www.banterly.net/2016/12/31/blockchain-beyond-… | |
766 <p>Today I want to talk about something else, about a realization that I… | |
767 <h2 id="shortblockchainrecap">Short blockchain recap</h2> | |
768 <p>In case you were too lazy to go to any of the resources indicated abo… | |
769 <p><img src="https://www.banterly.net/content/images/2018/07/Capture.PNG… | |
770 <a href="https://medium.com/creativeblockchain/the-blockchain-illustrate… | |
771 <p>The main idea of blockchain is that of decentralization, more specifi… | |
772 <p>Truth be told, there are <strong>a lot</strong> of problems with bloc… | |
773 <ul> | |
774 <li><strong>No proven use cases</strong> - even as a currency it arguabl… | |
775 <li><strong>No proven scalability solution</strong> - a few solutions ar… | |
776 <li><strong>No proven solution for private data storage</strong> - there… | |
777 <li><strong>The tendency of blockchain networks to become centralized</s… | |
778 </ul> | |
779 <h2 id="decentralizationatadisadvantage">Decentralization at a disadvant… | |
780 <p>Actually, arguably the only success stories in the blockchain world, … | |
781 <p>The only advantage they could claim is that they operate in a trustle… | |
782 <p>I am not saying decentralization is bad, just that centralized system… | |
783 The internet itself, which was considered the go-to model of a decentral… | |
784 <h2 id="beingoptimisticdidnothelp">Being optimistic did not help</h2> | |
785 <p>Even with all this problems being evident to me, I wanted to ignore t… | |
786 It is true that this money also attracted a lot of scammers who got rich… | |
787 <p><img src="https://www.banterly.net/content/images/2018/07/there-amp-0… | |
788 <p>I realized that even when ignoring all these issues, there is one pro… | |
789 <h2 id="thehypegeneratingpromise">The hype-generating promise</h2> | |
790 <p>Let us assume we have the perfect blockchain system: scalable, fast,… | |
791 <p>I am here to tell you that things are not so black and white. It is a… | |
792 <p><img src="https://www.banterly.net/content/images/2018/07/thecakeisal… | |
793 <h2 id="thenotsohypegeneratingtruth">The not so hype-generating truth</h… | |
794 <p>My guess is that this misconception comes from the fact that the tech… | |
795 <p>But if we think in terms of the distributed ledger that is constructe… | |
796 <p><img src="https://www.banterly.net/content/images/2018/07/9wsxhj0rhst… | |
797 <a href="https://www.reddit.com/r/Bitcoin/comments/78g5k2/how_bitcoin_fo… | |
798 <p>This leads me to the following statement which I think everyone needs… | |
799 <blockquote> | |
800 <p>The blockchain distributed ledger is not immutable, it is just a coll… | |
801 </blockquote> | |
802 <h2 id="decentralizationhelps">Decentralization helps...</h2> | |
803 <p>Following this rule, we can see why private blockchains (all miners c… | |
804 <p>That is why most people will tell you it is important for the majorit… | |
805 <h2 id="theissueemerges">The issue emerges</h2> | |
806 <p>We need to realize that ultimately this ledger's underlying infr… | |
807 <p>That is all fine until we realize that this effect may intersect with… | |
808 <h2 id="historyalreadytaughtus">History already taught us</h2> | |
809 <p>You may say that this is all hypothetical and the chances of this act… | |
810 <p><img src="https://www.banterly.net/content/images/2018/07/2ewqau.jpg"… | |
811 <p>Short summary of what happenened then:</p> | |
812 <ul> | |
813 <li>The DAO is setup on the Ethereum blockchain network.</li> | |
814 <li>The DAO gathers from its crowdsale 150 million dollars worth of ethe… | |
815 <li>A hacker takes 50 million dollars worth of ether from the DAO using … | |
816 <li>In fear of Ethereum losing further investors and to maintain the val… | |
817 </ul> | |
818 <p>The reason why I put "decides" between quotes is because th… | |
819 <h2 id="thefatalflaw">The fatal flaw</h2> | |
820 <p>With the previous example in mind I hope you realize, the same way I … | |
821 <p><img src="https://www.banterly.net/content/images/2018/07/1526884_555… | |
822 <p>If you think about it, this does not sound like the kind of decision … | |
823 <p>...except that is exactly on what blockchain systems are based on.<br> | |
824 And this is the <em><strong>fatal flaw</strong></em> of blockchain.</p> | |
825 <!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![… | |
826 <ol> | |
827 <li>I was in the process of changing jobs in that period so it took quit… | |
828 <li>I was working on a project that I am finally proud to announce is li… | |
829 </ol> | |
830 <p>After I held a guest lecture at my former master program on the topic… | |
831 <p>After more than 4 months of work, I am proud to present:</p> | |
832 <h2 id="masteringblockchainbeyondcryptomania">Mastering blockchain - Bey… | |
833 <iframe width="560" height="315" src="https://www.youtube.com/embed/SBdw… | |
834 <p>Since you are a reader of mine, I will offer you special limited (100… | |
835 <a href="https://www.udemy.com/mastering-blockchain-beyond-cryptomania/?… | |
836 <p>Can't wait to see you on the course and have your feedback.</p> | |
837 <!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![… | |
838 <p><img src="https://www.banterly.net/content/images/2017/07/download-1.… | |
839 <p>I was just busy in the last months with multiple things, but I am pre… | |
840 <p>In</p>]]></description><link>https://www.banterly.net/2017/07/23/im-n… | |
841 <p><img src="https://www.banterly.net/content/images/2017/07/download-1.… | |
842 <p>I was just busy in the last months with multiple things, but I am pre… | |
843 <p>In the meantime you can now follow me on my new twitter account and I… | |
844 <iframe width="560" height="315" src="https://www.youtube.com/embed/K1b8… | |
845 <p>"If something doesn't make sense it means that one of your … | |
846 </blockquote> | |
847 <p>If you want to present to your friend a problem that he will probably… | |
848 <p>"If something doesn't make sense it means that one of your … | |
849 </blockquote> | |
850 <p>If you want to present to your friend a problem that he will probably… | |
851 <p>Of course the previous paragraph alludes to the (in)famous Monty Hall… | |
852 <p><img src="https://www.banterly.net/content/images/2017/02/MHDealPromo… | |
853 <p>It is renowned not only because of its counter-intuitive answer, but … | |
854 <blockquote> | |
855 <p><em>May I suggest that you obtain and refer to a standard textbook on… | |
856 </blockquote> | |
857 <blockquote> | |
858 <p><em>Maybe women look at math problems differently than men.</em> - Do… | |
859 </blockquote> | |
860 <blockquote> | |
861 <p><em>I am sure you will receive many letters on this topic from high s… | |
862 </blockquote> | |
863 <p>I am sure everyone who tried to present this problem to their acquain… | |
864 <p>What I will do in this article is present the problem and answer it. … | |
865 <h3 id="themontyhallproblem">The Monty Hall Problem</h3> | |
866 <p>The story goes like this:</p> | |
867 <p><img src="https://www.banterly.net/content/images/2017/02/Capture2.PN… | |
868 <p><img src="https://www.banterly.net/content/images/2017/02/Capture.PNG… | |
869 <p><img src="https://www.banterly.net/content/images/2017/02/Capture-1.P… | |
870 <p><img src="https://www.banterly.net/content/images/2017/02/Capture-2.P… | |
871 <p>This is it. The famous Monty Hall problem resumes to the simple quest… | |
872 <p>Think of what you would do and go on and read the next of the article… | |
873 <h3 id="thesolution">The solution</h3> | |
874 <p><img src="https://www.banterly.net/content/images/2017/02/359b162052a… | |
875 Maybe surprisingly for some, the answer is that it is always better to s… | |
876 <h3 id="explanationsranked">Explanations Ranked</h3> | |
877 <p>I will next rank all the explanations that I am aware of. Please post… | |
878 <h4 id="5informationmatters">5. Information Matters</h4> | |
879 <p>Many people have the misconception that since there are two doors, th… | |
880 <p>One of the sources for this mistake is that people disregard the fact… | |
881 <h4 id="4takeallpossiblecases">4. Take all possible cases</h4> | |
882 <p>An easy way to explain this will be to ask the non believer to take a… | |
883 <p><img src="https://www.banterly.net/content/images/2017/02/Capture-3.P… | |
884 <p>As you can see, if you do not switch, you can only win if you initial… | |
885 <h4 id="3multipledoors">3. Multiple doors</h4> | |
886 <p>This explanation is where most of the people realize that they were a… | |
887 <h4 id="2tryityourself">2. Try it yourself</h4> | |
888 <p>Another great way to convince you of the truth is to try this experim… | |
889 <h4 id="1doingthemath">1. Doing the math</h4> | |
890 <p>Now we get to the serious part.</p> | |
891 <p>As a warning, skip this part if you are not a fan of probabilities an… | |
892 <p><img src="https://www.banterly.net/content/images/2017/02/14608107_11… | |
893 This is actually not trivial, even though it does look like a very simpl… | |
894 <p>We will use <a href="https://en.wikipedia.org/wiki/Random_variable">r… | |
895 <ul> | |
896 <li>D: the the door containing the car.</li> | |
897 <li>P: the first door selected by the player.</li> | |
898 <li>H: the door opened by the host.</li> | |
899 <li>X: the final door selected by the player.</li> | |
900 </ul> | |
901 <p>Since each variables will represent a door, they can only have as pos… | |
902 <p>We will now impose some restrictions based on some common sense:</p> | |
903 <ul> | |
904 <li>The first thing you will notice is that the host cannot open a door … | |
905 <li>The second thing to notice, and this is very important, is that the … | |
906 </ul> | |
907 <p>It is fair to assume that the car is randomly hidden behind one of th… | |
908 <p>\[P(D = i)=\frac{1}{3}\ for\ i∈\{1,2,3\} \]</p> | |
909 <p>The player will first choose randomly a door, since he has no informa… | |
910 \[P(P = j)=\frac{1}{3}\ for\ j∈\{1,2,3\} \]</p> | |
911 <p>Next we define the conditional density function of the door the host … | |
912 <p>\[<br> | |
913 P(H = k ∣ D = i, P = j) = \left\{<br> | |
914 \begin{array}{ll}<br> | |
915 1,\ i≠j,i≠k,k≠j \\<br> | |
916 \frac{1}{2},\ i=j,k≠i \\<br> | |
917 0,\ k=i,k=j<br> | |
918 \end{array}<br> | |
919 \right. for\ i,j,k∈\{1,2,3\}<br> | |
920 \]</p> | |
921 <p>The probability density function of the player's second choice i… | |
922 <ul> | |
923 <li>If the player never switches, <em><strong>s=0</strong></em></li> | |
924 <li>If the player always switches, <em><strong>s=1</strong></em></li> | |
925 </ul> | |
926 <p>Taking all these facts into account we get the following:</p> | |
927 <p>\[<br> | |
928 P(X = l ∣ P = j, H = k) = \left\{<br> | |
929 \begin{array}{ll}<br> | |
930 s,\ l≠j,l≠k,k≠j \\<br> | |
931 1-s,\ l=j,k≠j \\<br> | |
932 0,\ k=l,k=j<br> | |
933 \end{array}<br> | |
934 \right. for\ l,j,k∈\{1,2,3\}\ with\ j≠k<br> | |
935 \]</p> | |
936 <p>We will now unite all these functions in one giant one that will be a… | |
937 <p>\(P(D=i,P=j,H=k,X=l)=<br> | |
938 P(D=i) \times P(P=j) \times P(H=k∣D=i,P=j) \times P(X=l∣P=… | |
939 <p>\[i,j,k,l∈\{1,2,3\}\]</p> | |
940 <p>Remember that the first two terms are constant so the formula above b… | |
941 <p>\(P(D=i,P=j,H=k,X=l)=<br> | |
942 \frac{1}{9} \times P(H=k∣D=i,P=j) \times P(X=l∣P=j,H=k)\)<… | |
943 <p>\[i,j,k,l∈\{1,2,3\}\]</p> | |
944 <p>We are almost done. The only remaining thing in our setup is to defin… | |
945 <p>Now it is calculating time. We have to sum the probabilities of all s… | |
946 <p>\(\frac{1}{9} \times P(H=2∣D=1,P=1) \times P(X=1∣P=1,H=… | |
947 \(\frac{1}{9} \times P(H=3∣D=1,P=1) \times P(X=1∣P=1,H=3) … | |
948 \frac{1}{9}\times\frac{1}{2}\times(1-s)=\frac{1-s}{18}\)<br> | |
949 \(\frac{1}{9} \times P(H=3∣D=1,P=2) \times P(X=1∣P=2,H=3) … | |
950 \frac{1}{9}\times1\times s=\frac{s}{9}\)<br> | |
951 \(\frac{1}{9} \times P(H=2∣D=1,P=3) \times P(X=1∣P=3,H=2)=… | |
952 \frac{1}{9}\times1\times s=\frac{s}{9}\)</p> | |
953 <p>Added up we get:</p> | |
954 <p>\(P(D=1,P=j,H=k,X=1)= \frac{1+s}{9}\)</p> | |
955 <p>But this is equal with the probabilities of the scenarios where D=X=2… | |
956 <p>\(P(D=X)=\frac{1+s}{3}\)</p> | |
957 <p>This is expressing the probability of winning the car using the param… | |
958 <ul> | |
959 <li>The player never switches: \(P(D=X)=\frac{1}{3}\)</li> | |
960 <li>The player always switches: \(P(D=X)=\frac{2}{3}\)</li> | |
961 </ul> | |
962 <p>As you can see we made the proof that switching is always better than… | |
963 <p>All I can say is <em><strong>Q.E.D.</strong></em></p> | |
964 <!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![… | |
965 I was recently looking through my university days archive (ahh the days … | |
966 I was recently looking through my university days archive (ahh the days … | |
967 <p>I will first show the problem. Try to answer it for yourself and post… | |
968 <h1 id="theproblem">The problem</h1> | |
969 <p>Assume that we have the following two very simple classes:</p> | |
970 <pre><code>class Parent { | |
971 public: | |
972 virtual void print(){ | |
973 std::cout<<"I am the parent class"<<std::endl; | |
974 } | |
975 }; | |
976 | |
977 class Derived : public Parent { | |
978 public: | |
979 virtual void print(int x){ | |
980 std::cout<<"I am the derived class"<<std::endl; | |
981 } | |
982 }; | |
983 </code></pre> | |
984 <p>What will each of the following two small pieces of code do and why?<… | |
985 <pre><code>int main(){ | |
986 Derived *derived=new Derived; | |
987 derived->print(); | |
988 return 0; | |
989 } | |
990 | |
991 int main(){ | |
992 Parent *derived = new Derived; | |
993 derived->print(); | |
994 return 0; | |
995 } | |
996 </code></pre> | |
997 <p>That is it. I know that maybe for some of you this is completely obvi… | |
998 <h1 id="thesolution">The solution</h1> | |
999 <p><img src="https://www.banterly.net/content/images/2017/01/1i2lo9.jpg"… | |
1000 <ul> | |
1001 <li>The first case fails</li> | |
1002 <li>The second case will print: <em><strong>"I am the parent class&… | |
1003 </ul> | |
1004 <p>The first example has to do with the dominance(or name hiding) mechan… | |
1005 <p>Now the question comes...why didn't the second one also fail, si… | |
1006 <p>The key here is that name lookup does not start with the actual type … | |
1007 <p>I hope you found this as interesting as me and see you next time for,… | |
1008 <!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![… | |
1009 <p>"Git good" - anonymous</p> | |
1010 </blockquote> | |
1011 <p><img src="https://www.banterly.net/content/images/2017/01/git.png" al… | |
1012 Since everyone these days is becoming a developer, there is a high chanc… | |
1013 <p>"Git good" - anonymous</p> | |
1014 </blockquote> | |
1015 <p><img src="https://www.banterly.net/content/images/2017/01/git.png" al… | |
1016 Since everyone these days is becoming a developer, there is a high chanc… | |
1017 <h4 id="gitbisect">Git bisect</h4> | |
1018 <p>If you are in a well organized development environment, this command … | |
1019 <img src="https://www.banterly.net/content/images/2017/01/1hfav8.jpg" al… | |
1020 <p>You are happily developing cool new features for your application whe… | |
1021 <p>The idea is simple. You pick a commit from history, using <em>git log… | |
1022 <p>Let's say we have passionate people who want to save awesome son… | |
1023 <pre><code>[bdl@composer]$cat amazing_lyrics | |
1024 Oh! When you're down and looking for some cheering up | |
1025 Then just head right on up to the candy mountain cave | |
1026 When you get inside you'll find yourself a cheery land | |
1027 Such a happy and joyful and perky, merry land | |
1028 They've got lollipops and gummy drops and candy things | |
1029 Oh so many things that will brighten up your day | |
1030 It's impossible to wear a frown in candy town | |
1031 It's the mecca of love, the candy cave | |
1032 They've got jelly beans and coconuts with little hats | |
1033 Candy rabbits, chocolate bunnies, it's a wonderland of sweets | |
1034 Ride the candy train to town and hear the candy band | |
1035 Candy bells it's a treat as they march across the land | |
1036 Cherry ribbons stream across the sky into the ground | |
1037 Turn around | |
1038 It astounds! | |
1039 It's a dancing candy tree | |
1040 In the candy cave imagination runs so free | |
1041 So now Charlie, please will you go into the cave | |
1042 </code></pre> | |
1043 <p>Then you think that you should evolve your setup with some tests. You… | |
1044 <pre><code>[bdl@composer]$ python check_song.py amazing_lyrics | |
1045 WOW!! LYRICS DO NOT MATCH WITH THE ORIGINAL!! YOU ARE RUINING A GREAT … | |
1046 </code></pre> | |
1047 <p>Disaster!!! There is an error in the lyrics, even tough looking at th… | |
1048 We checkout the first commit and verify that it is correct(in general se… | |
1049 <pre><code>[dragos@composer]$git checkout first_verse | |
1050 [dragos@composer]$python check_song.py amazing_lyrics | |
1051 GOOD JOB! THE SONG IS INTACT | |
1052 </code></pre> | |
1053 <p>Now we know our guilty commit is somewhere in between these ranges an… | |
1054 <pre><code>[dragos@composer]$git bisect start | |
1055 [dragos@composer]$git bisect good first_verse | |
1056 [dragos@composer]$git bisect bad bad_verse | |
1057 Bisecting: 8 revisions left to test after this (roughly 3 steps) | |
1058 [9a2b4ea392d81192b3f0971dc9e0388b0827f10d] Adding amazing ninth verse | |
1059 </code></pre> | |
1060 <p>You see what happened? After giving the two commits between which we … | |
1061 <pre><code>[dragos@composer]$python check_song.py amazing_lyrics | |
1062 GOOD JOB! THE SONG IS INTACT | |
1063 [dragos@composer]$git bisect good | |
1064 Bisecting: 4 revisions left to test after this (roughly 2 steps) | |
1065 [eada803203224f16fb0760255575473ff3353cbc] Adding amazing thirteenth v… | |
1066 </code></pre> | |
1067 <p>With this info, git did a checkout on the commit halfway between this… | |
1068 <pre><code>[dragos@composer]$python check_song.py amazing_lyrics | |
1069 WOW!! LYRICS DO NOT MATCH WITH THE ORIGINAL!! YOU ARE RUINING A GREAT … | |
1070 Bisecting: 1 revision left to test after this (roughly 1 step) | |
1071 [4b9da3dddf2dcaeb11f3e64746e67cf40882e507] Adding amazing eleventh ver… | |
1072 [dragos@composer]$python check_song.py amazing_lyrics | |
1073 WOW!! LYRICS DO NOT MATCH!! YOU ARE RUINING THIS GREAT SONG. | |
1074 [dragos@composer]$git bisect bad | |
1075 Bisecting: 0 revisions left to test after this (roughly 0 steps) | |
1076 [634f0ad38519901d7db8885ed67a9c4122f7d756] Adding amazing tenth verse | |
1077 [dragos@composer]$python check_song.py amazing_lyrics | |
1078 GOOD JOB! THE SONG IS INTACT | |
1079 [dragos@composer]$git bisect good | |
1080 4b9da3dddf2dcaeb11f3e64746e67cf40882e507 is the first bad commit | |
1081 commit 4b9da3dddf2dcaeb11f3e64746e67cf40882e507 | |
1082 Author: bad_person <[email protected]> | |
1083 Date: Fri Jan 13 00:23:04 2017 +0100 | |
1084 Adding amazing eleventh verse | |
1085 :100644 100644 6b805f5880efc6b3aca886c33b892a3c54c69bcd | |
1086 ab327e224638a8bb744a78d9c1985c80bdb8e852 M amazing_lyrics | |
1087 </code></pre> | |
1088 <p>In the end we found the guilty commit so now we can see what was the … | |
1089 <pre><code>[dragos@composer]$git bisect reset 4b9da | |
1090 Previous HEAD position was 634f0ad... Adding amazing tenth verse | |
1091 HEAD is now at 4b9da3d... Adding amazing eleventh verse | |
1092 [dragos@composer]$git diff HEAD^ HEAD | |
1093 diff --git a/amazing_lyrics b/amazing_lyrics | |
1094 index 6b805f5..ab327e2 100644 | |
1095 --- a/amazing_lyrics | |
1096 +++ b/amazing_lyrics | |
1097 @@ -7,4 +7,5 @@ Oh so many things that will brighten up your day | |
1098 It's impossible to wear a frown in candy town | |
1099 It's the mecca of love, the candy cave | |
1100 They've got jelly beans and coconuts with little hats | |
1101 -Candy rats, chocolate bats, it's a wonderland of sweets | |
1102 +Candy rabbits, chocolate bunnies, it's a wonderland of sweets | |
1103 +Ride the candy train to town and hear the candy band | |
1104 </code></pre> | |
1105 <p>Aha! So someone did not like candy rats and chocolate bats. Now we kn… | |
1106 <p>In conclusion, this is useful when you know the behavior that changed… | |
1107 <h4 id="gitblame">Git blame</h4> | |
1108 <p>This is maybe the most known command on the list, but since I met a l… | |
1109 <p><em>Git blame</em> annotates your files with information about each l… | |
1110 <p>As an example we can take the file from our previous section:</p> | |
1111 <pre><code>[dragos@compser]$git blame amazing_lyrics | |
1112 ^d5c5a92 (bdl 2017-01-13 00:06:29 +0100 1) Oh! When you're… | |
1113 fa76d21a (bdl 2017-01-13 00:07:17 +0100 2) Then just head right… | |
1114 bab5fc16 (bdl 2017-01-13 00:07:58 +0100 3) When you get inside … | |
1115 b96e74ec (bdl 2017-01-13 00:08:50 +0100 4) Such a happy and joy… | |
1116 aa5c8716 (bdl 2017-01-13 00:12:05 +0100 5) They've got lol… | |
1117 2b26aaf7 (bdl 2017-01-13 00:14:48 +0100 6) Oh so many things th… | |
1118 7e06c9bb (best_guy 2017-01-13 00:15:45 +0100 7) It's impossible… | |
1119 104cfd46 (best_guy 2017-01-13 00:16:11 +0100 8) It's the mecca … | |
1120 5e259be9 (bdl 2017-01-13 00:16:53 +0100 9) They've got jel… | |
1121 b743274c (bad_person 2017-01-13 00:23:04 +0100 10) Candy rabbits, choco… | |
1122 b743274c (bad_person 2017-01-13 00:23:04 +0100 11) Ride the candy train… | |
1123 896d4c44 (bdl 2017-01-13 00:25:32 +0100 12) Candy bells it'… | |
1124 6e788500 (bdl 2017-01-13 00:27:23 +0100 13) Cherry ribbons strea… | |
1125 33bbe8ef (bdl 2017-01-13 00:28:02 +0100 14) Turn around | |
1126 1efad606 (bdl 2017-01-13 00:29:47 +0100 15) It astounds! | |
1127 9352d03d (bdl 2017-01-13 00:30:45 +0100 16) It's a dancing … | |
1128 140da6b7 (random_guy 2017-01-13 00:31:17 +0100 17) In the candy cave … | |
1129 eb97f1c2 (bdl 2017-01-13 00:31:52 +0100 18) So now Charlie, plea… | |
1130 </code></pre> | |
1131 <p>Looking at this, we could notice that there are two lines modified by… | |
1132 Another use is if you just don't understand what a piece of code do… | |
1133 <p><strong>Fun fact #1</strong>: If a commit hash has the <strong>^</str… | |
1134 <p><strong>Fun fact #2</strong>: Git can track even line movements acros… | |
1135 <h4 id="gitreflog">Git reflog</h4> | |
1136 <p>Probably you were told to avoid using <em>git reset --hard</em> becau… | |
1137 <p><img src="https://www.banterly.net/content/images/2017/01/1hndjf.jpg"… | |
1138 <p>What you may not know is that there is (mostly) nothing to worry abou… | |
1139 <p><em>Reflog</em> is a local structure that records where your HEAD and… | |
1140 <p><strong>Example time!!</strong></p> | |
1141 <p>Let's look at our current commit history.</p> | |
1142 <pre><code>[dragos@composer]$git log --pretty=oneline | |
1143 8ef8a6b18d4c76497a0cd5b0104336f8253d33a4 first commit of checking softw… | |
1144 eb97f1c20d82226f4d04e96237bf6956fa09e345 Adding amazing eighteenth verse | |
1145 140da6b784e33367e200349e6da5c0ddc48e7ef8 Adding amazing seventeenth ver… | |
1146 9352d03d455b4c646f3de91abd2aacd2998f34b8 Adding amazing sixteenth verse | |
1147 ... | |
1148 </code></pre> | |
1149 <p>Just as a reminder: what <em>git reset</em> does is that it moves the… | |
1150 <pre><code>[dragos@composer]$git reset HEAD^ | |
1151 [dragos@composer]$git log --pretty=oneline | |
1152 eb97f1c20d82226f4d04e96237bf6956fa09e345 Adding amazing eighteenth verse | |
1153 140da6b784e33367e200349e6da5c0ddc48e7ef8 Adding amazing seventeenth ver… | |
1154 9352d03d455b4c646f3de91abd2aacd2998f34b8 Adding amazing sixteenth verse | |
1155 1efad606e509a3eca835678ebf2e9c2fffaae45c Adding amazing fifteenth verse | |
1156 ... | |
1157 </code></pre> | |
1158 <p>We notice that the latest commit from our previous <em>git log</em> o… | |
1159 <p><img src="https://www.banterly.net/content/images/2017/01/Capture3.PN… | |
1160 <p>We realize that actually the commit we reset was actually perfect and… | |
1161 <pre><code>[dragos@composer]$git reflog | |
1162 eb97f1c HEAD@{0}: reset: moving to HEAD^ | |
1163 8ef8a6b HEAD@{1}: commit: first commit of checking software | |
1164 eb97f1c HEAD@{2}: checkout: moving from d5c5a925da0dc687e8a7d5d40111bbd… | |
1165 d5c5a92 HEAD@{3}: checkout: moving from master to first | |
1166 ... | |
1167 </code></pre> | |
1168 <p>The list goes longer, but for our case we are only interested in the … | |
1169 <pre><code>[dragos@composer]$git reset HEAD@{1} | |
1170 [dragos@composer]$git log --pretty=oneline | |
1171 8ef8a6b18d4c76497a0cd5b0104336f8253d33a4 first commit of checking softw… | |
1172 eb97f1c20d82226f4d04e96237bf6956fa09e345 Adding amazing eighteenth verse | |
1173 140da6b784e33367e200349e6da5c0ddc48e7ef8 Adding amazing seventeenth ver… | |
1174 9352d03d455b4c646f3de91abd2aacd2998f34b8 Adding amazing sixteenth verse | |
1175 ... | |
1176 </code></pre> | |
1177 <p>As we can see, things are back to normal. So the next time you panic … | |
1178 <p><img src="https://www.banterly.net/content/images/2017/01/download--1… | |
1179 <p><strong>Fun fact #3</strong>: I said before that by default <em>git l… | |
1180 <h4 id="commitranges">Commit ranges</h4> | |
1181 <p>You reached the final section, congratulations for going the extra mi… | |
1182 <p><img src="https://www.banterly.net/content/images/2017/01/download.jp… | |
1183 <p>Here we will see how to specify range of commits using three methods,… | |
1184 <p><img src="https://www.banterly.net/content/images/2017/01/Capture1.PN… | |
1185 <h5 id="doubledot">Double dot</h5> | |
1186 <p>I guess you used this one, even if you did not know fully what it act… | |
1187 <pre><code>[dragos@composer]$git log --pretty=oneline B..F | |
1188 F | |
1189 D | |
1190 </code></pre> | |
1191 <p>So this shows the commits between the range specified without includi… | |
1192 <pre><code>[dragos@composer]$git log --pretty=oneline G..F | |
1193 F | |
1194 D | |
1195 [dragos@composer]$git log --pretty=oneline F..G | |
1196 G | |
1197 E | |
1198 [dragos@composer]$git log --pretty=oneline C..G | |
1199 G | |
1200 E | |
1201 [dragos@composer]$git log --pretty=oneline G..C | |
1202 C | |
1203 </code></pre> | |
1204 <p>If you have not deduced exactly what this does form the previous outp… | |
1205 <p>One useful usage of this is before you want to push your changes to a… | |
1206 <p><code>[dragos@composer]$git log --pretty=oneline origin/master..HEAD<… | |
1207 <p>The output of the above command will represent the commits that you w… | |
1208 <h5 id="multiplebranches">Multiple branches</h5> | |
1209 <p>So the double dot is all fine and cool, but what do we do when we wan… | |
1210 <pre><code>[dragos@composer]$git log --pretty=oneline G..F | |
1211 [dragos@composer]$git log --pretty=oneline ^G F | |
1212 [dragos@composer]$git log --pretty=oneline F --not G | |
1213 </code></pre> | |
1214 <p>And an example with multiple branches:</p> | |
1215 <pre><code>[dragos@composer]$git log --pretty=oneline G --not H F | |
1216 G | |
1217 </code></pre> | |
1218 <h5 id="tripledot">Triple dot</h5> | |
1219 <p>The last method that we are covering for specifying commit ranges is … | |
1220 <p>Last example and you can go on with your life:</p> | |
1221 <pre><code>[dragos@composer]$git log --pretty=oneline C...G | |
1222 49a59058100707187ac6e8980e77e45e57785407 G | |
1223 4f1615031ededc27944ed43f4fc410b69a637919 E | |
1224 b73244c413956a356ed5076b5b87f087d978ba2f C | |
1225 </code></pre> | |
1226 <h4 id="goodbye">Goodbye</h4> | |
1227 <p>Thats it guys, I hope you learnt at least one thing from this and als… | |
1228 <img src="https://www.banterly.net/content/images/2017/01/1ho2ql.jpg" al… | |
1229 <!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![… | |
1230 <p>"You can't stop things like Bitcoin. It will be everywhere … | |
1231 </blockquote> | |
1232 <p>I am sure by now everyone at least heard in some context of Bitcoin, … | |
1233 <img src="https://www.banterly.net/content/images/2016/12/download--3-.j… | |
1234 </blockquote> | |
1235 <p>I am sure by now everyone at least heard in some context of Bitcoin, … | |
1236 <p><img src="https://www.banterly.net/content/images/2016/12/65-1.png" a… | |
1237 <p>While that may be one of its uses, the truth is that there are a lot … | |
1238 <img src="http://na2.www.gartner.com/imagesrv/newsroom/images/emerging-t… | |
1239 <br> | |
1240 <h4 id="somewordsaboutcryptocurrencies">Some words about cryptocurrencie… | |
1241 <p>Each blockchain has an associated digital currency (aka <strong>crypt… | |
1242 <h4 id="blockchainthedatastructure">Blockchain - The data structure</h4> | |
1243 <p>So what is blockchain? The name is pretty revealing, it is a chain of… | |
1244 <p><img src="https://www.banterly.net/content/images/2016/12/Picture3.pn… | |
1245 <p>Inside the block there is other information, which varies according t… | |
1246 <ul> | |
1247 <li>you can only find the input value corresponding to an output value b… | |
1248 <li>a small change to a message should change the hash value so extensiv… | |
1249 <li>you cannot find two inputs with the same output value easily</li> | |
1250 </ul> | |
1251 <p>Congratulations, you know the basics of the blockchain data structure… | |
1252 <h4 id="blockchainthenetwork">Blockchain - The network</h4> | |
1253 <p>The whole point of cryptocurrencies is to function on a decentralized… | |
1254 <p><img src="https://www.banterly.net/content/images/2016/12/Picture4.pn… | |
1255 If you were ever intrigued by the term miner here is where the mystery w… | |
1256 <p>Miners have three big roles:</p> | |
1257 <ul> | |
1258 <li>They all keep a full copy of the current blockchain that they have a… | |
1259 <li>Each of them constructs independently a new block containing new tra… | |
1260 <li>They must reach a consensus on what block will be added to the canon… | |
1261 </ul> | |
1262 <p>How is that consensus reached and how can we trust this network since… | |
1263 <p>To answer this we have to turn away from a pure scientific answer, be… | |
1264 <h4 id="consensusbeatingtheodds">Consensus - Beating the odds</h4> | |
1265 <p>This is one of the holy grails of Computer Science, <strong>Distribut… | |
1266 <p>Why blockchain works is because it departs from classical distributed… | |
1267 <ul> | |
1268 <li>It introduces the idea of offering incentives to miners to play nice… | |
1269 <li>It embraces randomness. It acts on probabilities more than on certai… | |
1270 </ul> | |
1271 <p>Let's enumerate the steps in which Bitcoin tries to reach consen… | |
1272 <ol> | |
1273 <li>A "random" miner is selected by the network</li> | |
1274 <li>The selected miner sends a local new block to the other miners</li> | |
1275 <li>The other miners validate the received new block. A basic check is t… | |
1276 <li>If it is valid, they discard their local new block and add to the bl… | |
1277 </ol> | |
1278 <p>If you think about it carefully, this mechanism prevents a lot of com… | |
1279 <ul> | |
1280 <li><strong>The Double Spend Attack</strong> - An attacker might try to … | |
1281 <img src="https://www.banterly.net/content/images/2016/12/DoubleSpend.PN… | |
1282 <li><strong>Stealing money</strong> - if one of the users would try to i… | |
1283 <li><strong>Denial of service</strong> - if some miners want to block so… | |
1284 </ul> | |
1285 <p>This looks fine technically, but it still doesn't answer how the… | |
1286 <h4 id="embracingtherandomness">Embracing the randomness</h4> | |
1287 <p>What is the problem? We are trying to make unrelated entities (which … | |
1288 Sure enough, blockchains come up with incentives to promote good behavio… | |
1289 <ul> | |
1290 <li><strong>A block reward</strong> - every miner who is "randomly&… | |
1291 <li><strong>The transaction fee</strong> - Again this works in different… | |
1292 </ul> | |
1293 <p>This looks pretty neat, but as long as there is something to gain, hu… | |
1294 <img src="https://www.banterly.net/content/images/2016/12/TragedyOfTheDi… | |
1295 Image source <a href="https://xkcd.com/958/">xkcd</a><br> | |
1296 This incentives system creates the "free for all" problem. Eve… | |
1297 <p>There are multiple ways of solving these issues, which in the end tur… | |
1298 <p><img src="https://www.banterly.net/content/images/2016/12/prisoners-d… | |
1299 Image source <a href="http://thedeclination.com/virtue-signalling-game-t… | |
1300 <p>To understand how to solve the dilemma we must turn to biology. The i… | |
1301 <p>Here's the scoop:​ The key idea behind proof‐of&#x… | |
1302 <p>In Bitcoin all miners are required to solve a puzzle (i.e. the <a hre… | |
1303 <p>This continuous puzzle solving has a cost for the miners: first in te… | |
1304 <p>The Proof of Stake system is an alternative with the advantage, among… | |
1305 <p>That's it folks. If you reached this far, most of the high level… | |
1306 <p>There is one more thing that was promised since the beginning of this… | |
1307 <h4 id="ethereumtheworldcomputer">Ethereum - The world computer</h4> | |
1308 <p>As you may have noticed, our click bait title contains also a referen… | |
1309 <p><img src="https://www.banterly.net/content/images/2016/12/Screen-Shot… | |
1310 Image source <a href="http://www.coindesk.com/7-cool-decentralized-apps-… | |
1311 Ethereum takes blockchain and goes with it to the next level. You don&ap… | |
1312 <ul> | |
1313 <li>Decentralized investment funding (although the most famous one, <a h… | |
1314 <li>Decentralized options exchange</li> | |
1315 <li>Releasing music as a digital contract</li> | |
1316 <li>Decentralized voting system</li> | |
1317 </ul> | |
1318 <p>This all works by introducing the notion of smart contracts. It is su… | |
1319 <p>Before the closing words, if you really want to know more of the tech… | |
1320 <h4 id="tuneinforthenextepisode">Tune in for the next episode</h4> | |
1321 <p>Next time we will get our hands dirty and try to make some Bitcoin tr… | |
1322 <p>If you want more do not forget to subscribe.</p> | |
1323 |