<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[hendi's blog]]></title><description><![CDATA[Doing things. Differently.]]></description><link>https://hendi.io/</link><image><url>https://hendi.io/favicon.png</url><title>hendi&apos;s blog</title><link>https://hendi.io/</link></image><generator>Ghost 3.21</generator><lastBuildDate>Sun, 12 May 2024 18:14:22 GMT</lastBuildDate><atom:link href="https://hendi.io/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Haskell Data.Time: Basic Examples]]></title><description><![CDATA[This post gives some basic examples for the usage of Haskell's Data.Time library.]]></description><link>https://hendi.io/haskell-data-time-basic-examples/</link><guid isPermaLink="false">5ef2f63ea9d5415dc5e4991f</guid><category><![CDATA[Haskell]]></category><dc:creator><![CDATA[Hendrik Richter]]></dc:creator><pubDate>Wed, 24 Jun 2020 07:02:33 GMT</pubDate><media:content url="https://hendi.io/content/images/2020/06/clock-1461689_1920.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://hendi.io/content/images/2020/06/clock-1461689_1920.jpg" alt="Haskell Data.Time: Basic Examples"><p>This post gives some basic examples for the usage of Haskell's <strong>Data.Time</strong> library. Import it with <code>import Data.Time</code> in ghci to follow along.</p>
<p>For further information have a look at <a href="https://two-wrongs.com/haskell-time-library-tutorial.html">A Haskell Time Library Tutorial</a> and time's documentation on <a href="https://hackage.haskell.org/package/time">Hackage</a>.</p>
<h2 id="howgetthecurrentdatetodayandthecurrenttimenow">How get the current date (today) and the current time (now)</h2>
<pre><code class="language-haskell">&gt; now &lt;- getCurrentTime
now :: UTCTime

&gt; now
2020-06-24 06:53:01.183008039 UTC

&gt; today = utctDay now
today :: Day

&gt; today
2020-06-24
</code></pre>
<h2 id="howtocreateaspecificday">How to create a specific Day</h2>
<p>There are two methods, <code>fromGregorian</code> and <code>fromGregorianValid</code>. The former returns a valid day close to what you asked it to do, the latter returns either <code>Just day</code>, or <code>Nothing</code>. The difference becomes obvious when you ask it to create e.g. February 31st:</p>
<pre><code class="language-haskell">-- some invalid examples
&gt; fromGregorian 2020 2 31
2020-02-29
it :: Day

&gt; fromGregorianValid 2020 2 31
Nothing
it :: Maybe Day

-- some valid examples
&gt; fromGregorian 2016 9 27
2016-09-27
it :: Day

&gt; fromGregorianValid 2019 10 7
Just 2019-10-07
it :: Maybe Day
</code></pre>
<h2 id="howtoformatdateandtime">How to format date and time</h2>
<pre><code class="language-haskell">&gt; now &lt;- getCurrentTime
&gt; formatTime defaultTimeLocale &quot;%d.%m.%Y, %H:%M&quot; now
&quot;24.06.2020, 13:48&quot;
it :: String
</code></pre>
<h2 id="checkwhichdayitis">Check which day it is</h2>
<pre><code class="language-haskell">&gt; now &lt;- getCurrentTime
&gt; today = utctDay now

&gt; dayOfWeek today
Wednesday
it :: DayOfWeek
</code></pre>
<h2 id="dateandtimecalculations">Date and Time calculations</h2>
<p>You can add (or substract) seconds to a time</p>
<pre><code class="language-haskell">&gt; now &lt;- getCurrentTime
&gt; workFinished = addUTCTime (60*60*8) now -- add 8 hours
</code></pre>
<p>and add days to a date</p>
<pre><code class="language-haskell">&gt; today = utctDay now
&gt; tomorrow = addDays 1 today
&gt; yesterday = addDays (-1) today
</code></pre>
<p>You can handle durations expressed in months as well:</p>
<pre><code class="language-haskell">&gt; jan6 = fromGregorian 2020 1 6

&gt; addGregorianMonthsRollOver 1 jan6
2020-02-06
it :: day

&gt; addGregorianMonthsClip 1 jan6
2020-02-06
it :: day
</code></pre>
<p>When do you need <code>addGregorianMonthsRollOver</code> and when <code>addGregorianMonthsClip</code>? Depends on your business case! Imagine a customer buys something for &quot;a month&quot;, what does that mean exactly for you? It could mean &quot;30 days&quot;, then use <code>addDays</code>. It could mean &quot;increment month (and year if necessary) by one&quot;, but what happens on January 31st? There's no Februar 31st, so should the result be Februar 28th (or 29th in a leap year) (<code>addGregorianMonthsClip</code>) or March 3rd (or 2nd in a leap year) -- use <code>addGregorianMonthsRollOver</code> in that case.</p>
<pre><code class="language-haskell">&gt; jan31 = fromGregorian 2020 1 31
&gt; addGregorianMonthsRollOver 1 jan31
2020-03-02
&gt; addGregorianMonthsClip 1 jan31
2020-02-29
</code></pre>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[February 2019: Our first donation to Grin]]></title><description><![CDATA[<p>On February 8th I've introduced <a href="https://hendi.io/community-funding-for-cryptocurrenies-and-mining-pools/">voluntary donations</a> on <a href="https://grin-pool.org">grin-pool.org</a>. Users have the choice of giving a small (or larger) percentage of their mining proceeds to the Grin development fund and/or the pool. Many users decided to set their donations on the first day and many more did so</p>]]></description><link>https://hendi.io/february-2019-our-first-donation-to-grin/</link><guid isPermaLink="false">5c78c79b95776a539e6a8d93</guid><dc:creator><![CDATA[Hendrik Richter]]></dc:creator><pubDate>Fri, 01 Mar 2019 06:32:28 GMT</pubDate><media:content url="https://hendi.io/content/images/2019/03/chipmunk-3959206_1920.jpg" medium="image"/><content:encoded><![CDATA[<img src="https://hendi.io/content/images/2019/03/chipmunk-3959206_1920.jpg" alt="February 2019: Our first donation to Grin"><p>On February 8th I've introduced <a href="https://hendi.io/community-funding-for-cryptocurrenies-and-mining-pools/">voluntary donations</a> on <a href="https://grin-pool.org">grin-pool.org</a>. Users have the choice of giving a small (or larger) percentage of their mining proceeds to the Grin development fund and/or the pool. Many users decided to set their donations on the first day and many more did so in the next days.</p><p>Now that the month is over and I'm happy to do the first transfer of funds to the Grin team.</p><p>But let's do some stats first:</p><p>In total, <strong>272 users</strong> decided to donate to grin and/or the pool (246 donate just to grin, 263 to just the pool).</p><p>The minimum donations someone set are 0.01% (looks like someone wanted to get rid of the sad smileys that appear if you don't donate at all), and the maximum donations are 2% to the pool, and a whopping <strong>20% to grin</strong>! The median donation to grin and the pool is 0.5% each, the average donation is 0.85% to grin, and 0.62% to the pool.</p><p>I'm happy to see that so many users decided to give back, and that they follow the pool's recommendation to give more to grin than to the pool.</p><p>From February 8th to 28th, our users in total generated the following donations:</p><ul><li>17.087656585ツ to the grin developer fund</li><li>15.927721009ツ for running grin-pool.org</li></ul><p>(For those who care about FIAT: at today's exchange rate (3.27$/ツ) that equals <strong>55.88USD for grin</strong>, and <strong>52.08USD for the pool</strong>)</p><figure class="kg-card kg-image-card kg-width-full"><img src="https://hendi.io/content/images/2019/03/image-5.png" class="kg-image" alt="February 2019: Our first donation to Grin"></figure><p>It's not a lot, but little strokes fell big oaks, and it shows that at least a small percentage of miners cares about the project, mines on non-50%-pools and gives back. Thanks a lot guys and girls!</p><p>Here's to many more donations for the developer team to come!</p><figure class="kg-card kg-image-card"><img src="https://hendi.io/content/images/2019/03/image-6.png" class="kg-image" alt="February 2019: Our first donation to Grin"></figure>]]></content:encoded></item><item><title><![CDATA[Cryptocurrencies, Mining Pools, and Grassroots Community Funding]]></title><description><![CDATA[<p>A couple of weeks ago, on <a href="https://github.com/mimblewimble/grin/commit/8fc489a80868fcf12fcdbc0551528bb73fc891a0">Jan. 15th 2019</a>, a new cryptocurrency has been launched: <a href="https://grin-tech.org">Grin</a>.</p><p>Grin is an open source implementation of the <a href="https://github.com/mimblewimble/grin/blob/master/doc/intro.md">MimbleWimble</a> algorithm which is thought to provide both private and scalable transactions (unlike Bitcoin, which is not private and hardly scalable; and unlike Monero, which is</p>]]></description><link>https://hendi.io/community-funding-for-cryptocurrenies-and-mining-pools/</link><guid isPermaLink="false">5c5d5e945f64a14fa2b431c3</guid><dc:creator><![CDATA[Hendrik Richter]]></dc:creator><pubDate>Fri, 08 Feb 2019 16:27:00 GMT</pubDate><media:content url="https://hendi.io/content/images/2019/02/team-386673_1920-3.jpg" medium="image"/><content:encoded><![CDATA[<img src="https://hendi.io/content/images/2019/02/team-386673_1920-3.jpg" alt="Cryptocurrencies, Mining Pools, and Grassroots Community Funding"><p>A couple of weeks ago, on <a href="https://github.com/mimblewimble/grin/commit/8fc489a80868fcf12fcdbc0551528bb73fc891a0">Jan. 15th 2019</a>, a new cryptocurrency has been launched: <a href="https://grin-tech.org">Grin</a>.</p><p>Grin is an open source implementation of the <a href="https://github.com/mimblewimble/grin/blob/master/doc/intro.md">MimbleWimble</a> algorithm which is thought to provide both private and scalable transactions (unlike Bitcoin, which is not private and hardly scalable; and unlike Monero, which is private but not scalable.) In many areas Grin respectively MimbleWimble work different than all other blockchains and thus have a different set of advantages and disadvantages. Time will tell which of these outweigh the others, but from a purely technical point of view (which is what I'm doing) Grin definitely has merit and is at least an interesting experiment with a chance of success higher than zero.</p><p>I've been following the Grin project since the end of 2017, developed an open-source <a href="https://grinexplorer.net/">Grin blockchain explorer</a> back then and launched a <a href="https://www.grin-pool.org/">Grin mining pool</a> minutes after their blockchain launched a couple of weeks ago. I feel very lucky to have come across the project that early, and have (online) met many incredibly smart, humble, and honest people. I'm not a fanboi though.</p><!--kg-card-begin: markdown--><h2 id="fundingmodels">Funding models</h2>
<!--kg-card-end: markdown--><p>Another project implementing MimbleWimble is <a href="https://www.beam.mw/">Beam</a> which released a few weeks prior to Grin. One central difference between Grin and Beam is their funding model: whereas Grin relies on the open source community to improve their code and to donate money to their developers through a development fund, Beam is developed by a company that takes a percentage of each mined block (similar to the way ZCash is funded).</p><p>Grin lauded itself for a fair launch: the genesis block included information from the latest Bitcoin block, making a pre-mine impossible. The initial difficulty was set insanely high to avoid early miners (read: the dev team) getting a head-start and mining the first blocks with little competition. This worked perfectly, Grin had a perfectly fair launch in the sense that <em>the developers didn't get anything</em>.</p><p>So, if the developers haven't gotten anything out of Grin, who did?</p><!--kg-card-begin: markdown--><h2 id="poolsminers">Pools &amp; Miners</h2>
<!--kg-card-end: markdown--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://hendi.io/content/images/2019/02/image-2.png" class="kg-image" alt="Cryptocurrencies, Mining Pools, and Grassroots Community Funding"><figcaption>A screenshot of <a href="https://miningpoolstats.stream/grin-c29">Miningpoolstats</a> as of 2019-08-12, 15:16 UTC</figcaption></figure><p>Uh-oh. That looks an awful lot like mining centralization. The three top pools account for 95% of hashing power. F2Pool owns about 1.2% of all Grin, Sparkpool about 4‰. </p><p>Roughly 180-300 USD worth of Grin get mined every minute (Grin was at 5 USD the last days, today it's around 3 USD). Mining difficulty has risen to obscene numbers, so surely there's some money to be made for the miners. A quick back-off-the-envelope calculation shows that the two top pools alone made about 17,000 USD per day, or double and triple that amount in the first week when the price was higher.</p><p>Now, remember how I wrote that Grin relies on donations? Surely people who profit from the mining craze would give back, right?</p><p>Let me quote Igno Peverell, but read his whole post <a href="https://www.grin-forum.org/t/solved-early-disappointments/3682">here</a>:</p><blockquote>After just over 2 weeks of grin being live, I’m disappointed by the  way the industry around Grin is shaping up. Of course it’s early, but  I’d rather not this be an indication of future direction.<br><br>Grin was started with as fair of a launch as possible for what’s  under our control. We did this for good reason: we believe in Grin’s  mission. I think I made pretty clear that to continue forward, the  project would still need help. And yet <a href="https://grin-tech.org/yeastplume" rel="nofollow noopener">yeastplume’s campaign</a> is still very far from being even 10% funded.</blockquote><p>Shortly after his post donations came in and the funding for the next months was secured. But the bulk of that amount came from Qtum, another cryptocurrency unrelated to Grin, and just an (in <em>my</em> opinion) laughable amount from the big pools.</p><p>That raises some questions:</p><ul><li>Should we hope for and rely on big donations from saviors like Qtum in the future? <strong>Probably not!</strong></li><li>Can we rely on the big corporate pools to pay for the foundations they're built upon? <strong>Apparently not!</strong></li></ul><!--kg-card-begin: markdown--><h2 id="communitytotherescue">Community to the rescue?</h2>
<!--kg-card-end: markdown--><p>It looks like we, the community, are on our own. </p><p>A few days ago BlockCypher, the company behind Grinmint (currently the third largest pool) announced that they take a 2.5% fee, of which they denote 20% to the Grin developer fund. Personally I would've hoped for more, but I know that I can't extrapolate the tiny numbers from <a href="https://www.grin-pool.org/">my tiny pool</a> to their scale, so I assume that's as much as they can give. Further, they support the Grin development directly by employing people like Quentin Le Sceller (who works on the Grin code), so they are definitely a valuable and vital part of the community.</p><p>There are many smaller pools, each with less than even just 1% of Grin's total hash rate. One of them is <a href="https://mwgrinpool.com/">MWGrinPool</a> by Blade Doyle, who not just open-sourced his code but also pledged some percentage of the (yet to be introduced) fees to the Grin developers.</p><p>And then there's my pool, <a href="https://www.grin-pool.org">grin-pool.org</a>. I've committed to keep it running without a fee, forever, even at a loss. I did so since I believe that an independent, free pool, is vital for the Grin ecosystem as a whole. The 179 users who are at this moment mining on my pool appear to agree, and I'm thankful for their support. The majority of people who keep mining on pools that could start a 51% attack unfortunately does not.</p><p>I've given countless hours of my time to Grin, donated some thousand dollars (either directly or through incurred server costs) to its cause, and will continue to do so. In order to give more, yesterday I added support for donations to my pool:</p><figure class="kg-card kg-image-card kg-width-wide"><img src="https://hendi.io/content/images/2019/02/image-3.png" class="kg-image" alt="Cryptocurrencies, Mining Pools, and Grassroots Community Funding"></figure><p>These are of course optional, people can mine forever without donating anything to either the pool or to Grin.  Since launching the feature roughly 24h ago, 80 people have already decided to support either the pool, or Grin, or both. On average they give 0.54% to the pool, and 1.27% to Grin, though these numbers don't take their respective graph rates into account.</p><p>At the end of the month I'll send the money to the Grin developer fund, and will post an analysis here. I know that it won't be much, but it sets an example and I hope that other miners and pools will follow.</p><!--kg-card-begin: markdown--><h2 id="whatcanyoudo">What can <em>you</em> do?</h2>
<!--kg-card-end: markdown--><p>If you can donate some money, please consider giving to the <a href="https://grin-tech.org/funding">Grin Developer Fund</a>. Even if it's just a bit (or satoshi), it counts!</p><p>If you're a miner, please consider mining on a smaller pool to lessen the mining centralization. Ideally, chose one that gives back to the community (Grinmint, MWGrinpool, grin-pool.org).</p><p></p>]]></content:encoded></item></channel></rss>