Alexis Wilke
https://www.alexiswilke.me
enC++: Why should I breakup my expressions?
https://www.alexiswilke.me/blog/c-why-should-i-breakup-my-expressions
<h3>
One Line Expressions</h3>
<p>There has been and I'm sure there still are many talks about whether to write it all on one line or break up expressions on many lines.</p>
<h3>
One Line Pros</h3>
<p>The only pro I can think of for having everything on the same line is conciseness. For example:</p>
<pre>
*dst++ = *src++;</pre>
<p>This is a very clear statement for most every C/C++ programmer.</p>
<p>I have to agree with this fact and I at times use such lines of code too...</p>
<h3>
One Line Cons</h3>
<p>Now, I write very large libraries and programs (thousands when not ten of thousands or even hundreds of thousand lines of code....) and it ...</p>
<p><a href="https://www.alexiswilke.me/blog/c-why-should-i-breakup-my-expressions" target="_blank">read more</a></p>https://www.alexiswilke.me/blog/c-why-should-i-breakup-my-expressions#commentsThu, 11 Jul 2019 21:03:07 +0000Alexis Wilke60 at https://www.alexiswilke.meMeta-programming, promoting a type without changing the sign
https://www.alexiswilke.me/blog/meta-programming-promoting-type-without-changing-sign
<p>Today I found that one of my functions would overflow. Here is a simplified version of it:</p>
<pre class="lang-cpp prettyprint prettyprinted" style="">
<span class="kwd">template</span><span class="pun"><</span><span class="kwd">typename</span><span class="pln"> T</span><span class="pun">></span><span class="pln">
T scale</span><span class="pun">(</span><span class="pln">T value</span><span class="pun">,</span><span class="pln"> T position</span><span class="pun">,</span><span class="pln"> T count</span><span class="pun">)</span><span class="pln">
</span><span class="pun">{</span><span class="pln">
</span><span class="kwd">return</span><span class="pln"> </span><span class="pun">(</span><span class="pln">value </span><span class="pun">*</span><span class="pln"> position</span><span class="pun">)</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> count</span><span class="pun">;</span><span class="pln">
</span><span class="pun">}</span>
</pre>
<p>As we can see, all variables are of type T. So if the multiplication overflows, the function returns an invalid result. To fix this, I wanted to promote all the variables to the latest possible integer (keeping the sign) or <strong>double</strong> (in my case the support for floating points was just for the type <strong>float</strong> so no need for <strong>long double</strong>.)</p>
<p>As a result I wrote a structure using meta-programming as ...</p>
<p><a href="https://www.alexiswilke.me/blog/meta-programming-promoting-type-without-changing-sign" target="_blank">read more</a></p>https://www.alexiswilke.me/blog/meta-programming-promoting-type-without-changing-sign#commentsTue, 02 Jul 2019 23:32:42 +0000Alexis Wilke59 at https://www.alexiswilke.meCreating a Gantt Chart for your Project for Free
https://www.alexiswilke.me/blog/creating-gantt-chart-your-project-free
<p><a href="/sites/alexiswilke.me/files/images/projectlibre-screenshot-957x369.png" target="_blank"><img alt="ProjectLibre Screenshot" src="/sites/alexiswilke.me/files/images/projectlibre-screenshot-957x369.png" style="max-width: 100%;" title="ProjectLibre — Click to Enlarge" /></a></p>
<p>Today I wanted to work on the schedule of a project with the proper dependencies. More or less, I had the project tasks laid out as a long list (As I would if I were the only one to work on said project) and I needed to answer two main questions:</p>
<ul>
<li>
How much will it cost?</li>
<li>
How many resources do we need?</li>
</ul>
<p>The other question, which is always really hard to answer as a software developer, was: <em><strong>Can you make it happen in 6 months?</strong></em> But you know the answer to that one: <em><strong>Of Course!</strong></em> (and 6 months later: <strong><em>Not</em></strong>!)</p>
<p>So, I remembedered seeing a manager using MS Project which is what it is. In ...</p>
<p><a href="https://www.alexiswilke.me/blog/creating-gantt-chart-your-project-free" target="_blank">read more</a></p>https://www.alexiswilke.me/blog/creating-gantt-chart-your-project-free#commentsFri, 12 Apr 2019 23:52:24 +0000Alexis Wilke58 at https://www.alexiswilke.meASCII Art Pony
https://www.alexiswilke.me/pony
<p>Isn't that cool?</p>
<p>I just find it really facinating that some people have an eye to draw anything with anything (in this case, a little pony with wings using just ASCII characters.)</p>
<p>Have you ever tried to come up with a drawing of your own that would look as good as this one?</p>
<pre>
,;;*;;;;,
.-'``;-');;.
/' .-. /*;;
.' \d \;; .;;;,
/ o ` \; ,__. ,;*;;;*;,
\__, _.__,' \_.-') __)--.;;;;;*;;;;,
`""`;;;\ /-')_) __) `\' ';;;;;;
;*;;; -') `)_) |\ | ;;;;*;
...</pre>
<p><a href="https://www.alexiswilke.me/pony" target="_blank">read more</a></p>https://www.alexiswilke.me/pony#commentsSun, 10 Feb 2019 23:29:46 +0000Alexis Wilke40 at https://www.alexiswilke.meGetting a Proper Random Number on a Computer
https://www.alexiswilke.me/blog/getting-proper-random-number-computer
<p><a href="https://www.turnwatcher.com/blog/alexis-wilke/how-do-you-choose-your-dice-for-dungeons-and-dragons-games" target="_blank" title="Dungeons & Dragons dice have all the possible shapes that exist!"><img alt="Dungeons & Dragons dice have all the possible shapes that exist!" src="/sites/turnwatcher.com/files/images/dice-fiull-set-assortment-480x221.jpg" style="max-width: 100%;" /></a></p>
<p>99.9% of the time, I see people using random number generator in their software.</p>
<p>Say you have a random function <strong>b()</strong> that generates random bits. Each time you call <strong>b()</strong>, you either get 0 or 1.</p>
<p>Now, in most cases people are going to get a larger number, say you write a function <strong>r()</strong> which returns 8 such bits. You could write it like this:</p>
<pre>
int r()
{
return (b() << 7)
| (b() << 6)
| (b() << 5)
| (b() << 4)
| (b() << 3)
| (b() << 2)
| (b() << 1)
| (b() << 0);
}</pre>
<p>Assuming you have a ...</p>
<p><a href="https://www.alexiswilke.me/blog/getting-proper-random-number-computer" target="_blank">read more</a></p>https://www.alexiswilke.me/blog/getting-proper-random-number-computer#commentsThu, 13 Sep 2018 17:27:13 +0000Alexis Wilke57 at https://www.alexiswilke.meSome Math
https://www.alexiswilke.me/blog/some-math
<p><a href="https://en.wikipedia.org/wiki/Mean">Mean</a></p>
<p>The mean of a set of values [math](x_1, x_2, ..., x_n)[/math] is often represented by [math]\overline{x}[/math]. The calculation of the mean is:</p>
<p>[display]\overline{x} = \mu = {\sum_{i=1}^n x_i \over n}[/display]</p>
<p>The mean may make use of weights (p):</p>
<p>[display]\overline{x} = \mu = {\sum_{i=1}^n x_i p_i \over \sum_{i=1}^n p_i}[/display]</p>
<p>You may want to normalize your weights, which means that their sum will equal 1, with the following:</p>
<p>[display]w_i = {p_i \over {\sum_{j=1}^n p_j}}[/display]</p>
<p>With normalized weights, you can simplify with the following:</p>
<p>[display]\overline{x} = \mu = ...</p>
<p><a href="https://www.alexiswilke.me/blog/some-math" target="_blank">read more</a></p>https://www.alexiswilke.me/blog/some-math#commentsSun, 26 Aug 2018 06:08:43 +0000Admin56 at https://www.alexiswilke.meVery Difficult Game of Shinsen-Sho
https://www.alexiswilke.me/blog/very-difficult-game-shinsen-sho
<p>I like a game of Shisen-Sho once in a while. Usually, it's pretty easy. I may have to try 2 or 3 times, but I finish those games fast.</p>
<p>This one, though, it was way harder and it took me many tries before succeeding. But it worked. After a while and many attempts, I finally resolved it.</p>
<p>Unfortunately, the game does not allow us to save the game, I'm wondering whether the author would be willing to offer such an option at some point. I guess I have to post an issue asking such if it's not already available in the latest version.</p>
<p>There is the game as a screenshot (Click to ...</p>
<p><a href="https://www.alexiswilke.me/blog/very-difficult-game-shinsen-sho" target="_blank">read more</a></p>https://www.alexiswilke.me/blog/very-difficult-game-shinsen-sho#commentsThu, 31 May 2018 10:22:11 +0000Alexis Wilke55 at https://www.alexiswilke.meSolve a in a power n equal b
https://www.alexiswilke.me/blog/solve-power-n-equal-b
<p><img alt="Class room blackboard with mathematics equations written in chalk." src="/sites/alexiswilke.me/files/images/classroom-blackboard-with-equations-1500x1000.jpg" style="width: 100%;" /></p>
<p>Finding the value of <strong>a</strong> in equation (1):</p>
<table border="0" cellpadding="1" cellspacing="1" style="width: 100%;">
<tbody>
<tr>
<td class="rtecenter">
a<sup>n</sup> = b</td>
<td class="rteright" style="width: 50px;">
(1)</td>
</tr>
</tbody>
</table>
<p>can be resolved using logarithms.</p>
<p> </p>
<p>First, transform equation (1) to equation (2):</p>
<table border="0" cellpadding="1" cellspacing="1" style="width: 100%;">
<tbody>
<tr>
<td class="rtecenter">
ln(a<sup>n</sup>) = ln(b)</td>
<td class="rteright" style="width: 50px;">
(2)</td>
</tr>
</tbody>
</table>
<p> </p>
<p>Now we can easily extract the power (n) by changing it into a multiplication:</p>
<table border="0" cellpadding="1" cellspacing="1" style="width: 100%;">
<tbody>
<tr>
<td class="rtecenter">
n × ln(a) = ln(b)</td>
<td class="rteright" style="width: 50px;">
(3)</td>
</tr>
</tbody>
</table>
<p> </p>
<p>From equation (3), we know what the logarithm of a is equal to:</p>
<table border="0" cellpadding="1" cellspacing="1" style="width: 100%;">
<tbody>
<tr>
<td class="rtecenter">
<img alt="ln(a) = ln(b) over n" src="/sites/alexiswilke.me/files/images/equation_lna_equal_lnb_over_n.png" style="width: 135px; height: 68px;" /></td>
<td class="rteright" style="width: 50px;">
(4)</td>
</tr>
</tbody>
</table>
<p> </p>
<p>Finally, we can write an equation as a = <em>something</em>.</p>
<table border="0" cellpadding="1" cellspacing="1" style="width: 100%;">
<tbody>
<tr>
<td class="rtecenter">
<img alt="a equal e power ln(b) over n" src="/sites/alexiswilke.me/files/images/equation_a_equal_e_power_lnb_over_n.png" style="width: 125px; height: 76px;" /></td>
<td class="rteright" style="width: 50px;"> ...</td></tr></tbody></table>
<p><a href="https://www.alexiswilke.me/blog/solve-power-n-equal-b" target="_blank">read more</a></p>https://www.alexiswilke.me/blog/solve-power-n-equal-b#commentsSat, 26 May 2018 02:32:26 +0000Alexis Wilke54 at https://www.alexiswilke.meAbout Radon Gas
https://www.alexiswilke.me/blog/about-radon-gas
<p>I learned about Radon gas as I'm now working in Real Estate at <a href="https://diverserealty.team/" target="_blank" title="Diverse Realty">Diverse Realty</a>.</p>
<p>The gas reacts quickly and when that happens it emits some radio active energy. If you are close by, you will therefore be radiated.</p>
<p>We have found, over time, that a small amount of radiation is good for us. Not only that, we actually emit radiation ourselves. More than what Radon gas in our homes generates.</p>
<p>Actually, a smoke alarm system makes use of a decaying bit of radio active material. Those rays go in all directions for a long time.We channel a certain amount in two specific tubes, one of which is ...</p>
<p><a href="https://www.alexiswilke.me/blog/about-radon-gas" target="_blank">read more</a></p>https://www.alexiswilke.me/blog/about-radon-gas#commentsSun, 05 Nov 2017 20:09:50 +0000Alexis Wilke53 at https://www.alexiswilke.meI visited your website...
https://www.alexiswilke.me/blog/i-visited-your-website
<p>Every single day I receive an email that tells me they visited my website. There is the one for today:</p>
<p class="rteindent1"><em>« I recently visited your website and wanted to comment on how nice it looks. »</em></p>
<p>What I find really interesting is that I manage something like 20 websites and they NEVER tell me which website has a problem. It's like those telemarketers who call you telling you they can fix your credit credit card and immediately tell you there is nothing wrong with it... (you bet, they are always $0 since otherwise you pay a whooping 27%+ interest, who in their right mind would accept such ...</p>
<p><a href="https://www.alexiswilke.me/blog/i-visited-your-website" target="_blank">read more</a></p>https://www.alexiswilke.me/blog/i-visited-your-website#commentsFri, 03 Nov 2017 05:55:49 +0000Alexis Wilke52 at https://www.alexiswilke.me