<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by 0xc22b on Medium]]></title>
        <description><![CDATA[Stories by 0xc22b on Medium]]></description>
        <link>https://medium.com/@0xc22b?source=rss-33dcc1de74b0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fI5DD8ieHIlPUQiH9u237w.png</url>
            <title>Stories by 0xc22b on Medium</title>
            <link>https://medium.com/@0xc22b?source=rss-33dcc1de74b0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 19:58:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@0xc22b/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[sBTC will be adopted, esp. by Bitcoin treasury companies]]></title>
            <link>https://medium.com/@0xc22b/sbtc-will-be-adopted-esp-by-bitcoin-treasury-companies-0a3ef0e4a75d?source=rss-33dcc1de74b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a3ef0e4a75d</guid>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[btc]]></category>
            <category><![CDATA[stack]]></category>
            <dc:creator><![CDATA[0xc22b]]></dc:creator>
            <pubDate>Fri, 22 Aug 2025 06:49:42 GMT</pubDate>
            <atom:updated>2025-08-24T04:10:06.708Z</atom:updated>
            <content:encoded><![CDATA[<p>Just imagine when Bitcoin treasury companies start using sBTC to justify a premium to NAV to earn yield and pay off debt. It seems inevitable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VZ7rQau-OTap1b8BQrvvpg.png" /></figure><p>Institutions own the asset; they’ll need the rails to use it. They are increasingly interested in making Bitcoin productive rather than just holding it passively. This includes leveraging decentralized finance (DeFi) protocols built on Bitcoin or Bitcoin-backed assets like sBTC (a 1:1 Bitcoin-backed, programmable asset on the Stacks layer 2 network) to generate yield, trade, lend, and borrow.</p><p>Some institutions are also using leverage and tactical debt financing to acquire more BTC and boost their Bitcoin-per-share growth. This approach can create a premium to NAV, justified by the company’s ability to generate yield and grow the underlying Bitcoin holdings per share over time.</p><p>The NAV premium for such companies reflects investor confidence that these treasury firms will continue to grow Bitcoin per share by efficiently deploying capital. This premium enables companies to raise capital more effectively, thereby accumulating more BTC or managing liabilities, which creates a self-reinforcing cycle. The concept aligns with the claim that Bitcoin treasury companies may use sBTC or similar Bitcoin yield strategies to justify a premium and pay off debt.</p><p>Major custodians like BitGo have launched institutional support and infrastructure for sBTC, enabling institutions to securely custody, convert, and integrate sBTC with Bitcoin for DeFi purposes. This institutional-grade access to programmable Bitcoin-based assets makes the described scenario increasingly likely.</p><p>In summary, Bitcoin DeFi is poised to significantly involve institutions through assets like sBTC. This is particularly evident in Bitcoin treasury companies utilizing these tools to justify premium valuations and manage yield and debt, aligning with current industry trends and developments. The scenario described seems imminent and quite plausible given the accelerating institutional adoption and new Bitcoin DeFi infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a3ef0e4a75d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[We Need Decentralized Social Media]]></title>
            <link>https://medium.com/@0xc22b/we-need-decentralized-social-media-fdbffe867774?source=rss-33dcc1de74b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdbffe867774</guid>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[social-media]]></category>
            <dc:creator><![CDATA[0xc22b]]></dc:creator>
            <pubDate>Wed, 20 Aug 2025 06:24:02 GMT</pubDate>
            <atom:updated>2025-08-20T06:24:02.319Z</atom:updated>
            <content:encoded><![CDATA[<p>For decades, we’ve lived on the internet as guests. We log into our favorite social media platforms, post our thoughts, share our photos, and connect with friends, all while operating under a tacit agreement: the platform owns the land, and we are merely tenants. Our data is their asset, our attention is their commodity, and our creative output serves their business model. This is the world of Web2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XU2UUZzlXzqlhzfY" /><figcaption>Photo by <a href="https://unsplash.com/@maria_shalabaieva?utm_source=medium&amp;utm_medium=referral">Mariia Shalabaieva</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>But a quiet revolution is underway. It’s not just about a new app or a different algorithm. It’s about a fundamental shift in ownership and control, driven by the principles of Web3. The narrative of decentralized social media isn’t just a buzzword; it’s a return to the internet’s original promise of a free and open exchange of information.</p><h4>From Tenants to Owners: The Core Shift</h4><p>Think about a traditional social media platform. When you sign up, you create an account tied to their centralized database. Your username, your posts, and your social graph all live on their servers. If the company decides to shut down, change its policies, or ban you, you lose everything. You don’t own your identity or your content — you are borrowing it.</p><p>Decentralized social media platforms, built on blockchain technology, flip this model on its head. Your identity is a self-sovereign, cryptographic account. Your content is often stored on decentralized file systems, not a company’s server. When you post a message, it’s not being sent to a centralized database; it’s being broadcast to a network of independent nodes.</p><p>This changes everything. Your data is no longer a centralized honeypot for hackers or a tool for platforms to monetize without your explicit consent. Your digital identity is portable, allowing you to move from one application to another without starting from scratch.</p><h4>Privacy is the Killer Feature</h4><p>The Web3 space has seen many narratives come and go, from DeFi to NFTs and beyond. But the one that resonates most deeply with the original promise of the internet is privacy. Centralized platforms have made us comfortable with a trade-off: convenience for our personal data. We hand over our digital lives in exchange for a free service.</p><p>With decentralized social, privacy isn’t an afterthought — it’s a foundational building block. Technologies like zero-knowledge proofs (ZKP) are enabling new forms of social interaction where you can prove something about yourself without revealing the underlying data. Imagine being able to verify you are over 18 without revealing your birthday, or confirming you are a member of a community without exposing your wallet address. This is the future of privacy on the internet, and it’s being built on a decentralized stack.</p><h4>The Challenges and the Road Ahead</h4><p>Of course, the road to mass adoption is not without its hurdles. User experience can be more complex than Web2 counterparts, and the ecosystem is still nascent. But as we’ve seen with other Web3 narratives, a passionate community of builders and early adopters is already paving the way. Projects like Farcaster, Lens, and others are demonstrating that a better, more user-centric internet is not just possible — it’s already being built.</p><p>The transition from a centralized to a decentralized internet will be a gradual one. It won’t happen overnight, and it won’t be a one-size-fits-all solution. But as long as we continue to value ownership, privacy, and true decentralization, the quiet revolution will continue to grow, one user at a time. It’s time to stop renting and start owning our digital lives.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdbffe867774" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a Stacks app connecting to a Leather or Xverse wallet, alternatively]]></title>
            <link>https://medium.com/@0xc22b/build-a-dapp-connecting-to-leather-or-xverse-alternatively-c5e40c925884?source=rss-33dcc1de74b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5e40c925884</guid>
            <category><![CDATA[stack]]></category>
            <dc:creator><![CDATA[0xc22b]]></dc:creator>
            <pubDate>Wed, 04 Jun 2025 05:12:33 GMT</pubDate>
            <atom:updated>2025-06-05T05:55:06.614Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://github.com/hirosystems/connect">Stacks Connect</a> is the standard way. Don’t get me wrong. For almost every circumstance, using Stacks Connect is the best approach. But if you want to go wild or play around, this post is for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nMOhUTZATg3KOkCr" /><figcaption>Photo by <a href="https://unsplash.com/@maria_shalabaieva?utm_source=medium&amp;utm_medium=referral">Mariia Shalabaieva</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The real reason was that at the time I developed my app, Stacks Connect had an issue. I believe the Hiro team has resolved it. <a href="https://leather.gitbook.io/developers">Leather</a> and <a href="https://docs.xverse.app/sats-connect">Xverse</a> have their own API. Sometimes, they release a breaking change. There is a gap before Stacks Connect applies the change. Additionally, they’re transitioning from the old way to the new standard API.</p><p><a href="https://augurrank.com/">AugurRank</a> needs to connect to a wallet for three purposes: to retrieve the user’s Stacks address, to sign a message using the user’s private key, and to call a smart contract.</p><p>The first two purposes are easier to use the new API, but calling a smart contract still sticks to the old one. For Xverse, the new API is provided by their “sats-connect” library. If I understand correctly, the library converts the new API to the old way internally.</p><p>Without further ado, let’s dive into each purpose.</p><h4>Retrieve the user’s Stacks address.</h4><p>For the Leather wallet, we use the wallet’s request function with ‘getAddresses’ as a parameter.</p><pre>const connectLeather = async () =&gt; {<br>  const wallet = getWallet(ID_LEATHER);<br>  if (!isObject(wallet)) throw new Error(ERR_NOT_FOUND);<br><br>  const res = await wallet.request(&#39;getAddresses&#39;);<br>  const stxRes = res.result.addresses.find(obj =&gt; obj.symbol === &#39;STX&#39;);<br>  putWalletId(ID_LEATHER);<br><br>  return { stxAddr: stxRes.address, stxPubKey: stxRes.publicKey };<br>};</pre><p>For the Xverse wallet, similarly, we use its request function with ‘wallet_connect’ as a parameter.</p><pre>const connectXverse = async () =&gt; {<br>  const wallet = getWallet(ID_XVERSE);<br>  if (!isObject(wallet)) throw new Error(ERR_NOT_FOUND);<br><br>  const res = await xRequest(&#39;wallet_connect&#39;, { addresses: [AddressPurpose.Stacks] });<br>  if (res.status !== &#39;success&#39;) throw res;<br><br>  const stxRes = res.result.addresses.find(obj =&gt; obj.addressType === &#39;stacks&#39;);<br>  putWalletId(ID_XVERSE);<br><br>  return { stxAddr: stxRes.address, stxPubKey: stxRes.publicKey };<br>};</pre><h4>Sign a message</h4><p>For the Leather wallet:</p><pre>const signMessageLeather = async (msg, networkName) =&gt; {<br>  const wallet = getWallet(ID_LEATHER);<br>  if (!isObject(wallet)) throw new Error(ERR_NOT_FOUND);<br><br>  const res = await wallet.request(&#39;stx_signMessage&#39;, {<br>    message: msg, messageType: &#39;utf8&#39;, network: networkName,<br>  });<br>  return { stxSigStr: res.result.signature };<br>};</pre><p>For the Xverse wallet:</p><pre>const signMessageXverse = async (stxPubKey, msg) =&gt; {<br>  const wallet = getWallet(ID_XVERSE);<br>  if (!isObject(wallet)) throw new Error(ERR_NOT_FOUND);<br><br>  const res = await xRequest(&#39;stx_signMessage&#39;, { publicKey: stxPubKey, message: msg });<br>  if (res.status !== &#39;success&#39;) throw res;<br><br>  return { stxSigStr: res.result.signature };<br>};</pre><h4>Call a smart contract</h4><p>For both wallets, we call the wallet’s transactionRequest function with several parameters, such as a contract address, network, and post-conditions.</p><pre>const contractCallLeather = async (opts) =&gt; {<br>  const wallet = getWallet(ID_LEATHER);<br>  if (!isObject(wallet)) throw new Error(ERR_NOT_FOUND);<br><br>  const { functionArgs, postConditions, network, ...restOpts } = opts;<br>  const args = functionArgs.map(arg =&gt; {<br>    if (typeof arg === &#39;string&#39;) return arg;<br>    return serializeCV(arg);<br>  });<br>  const pcs = postConditions.map(postConditionToHex);<br>  const ntw = networkFrom(network);<br><br>  const payload = {<br>    ...restOpts,<br>    functionArgs: args,<br>    postConditions: pcs,<br>    network: ntw,<br>    txType: &#39;contract_call&#39;,<br>  };<br>  const token = createUnsecuredToken(payload);<br>  const res = await wallet.transactionRequest(token);<br><br>  let txId = res.txId;<br>  if (!txId.startsWith(&#39;0x&#39;)) txId = &#39;0x&#39; + txId;<br>  return { txId };<br>};</pre><p>There are old and new ways to accomplish the same thing. While Leather and Xverse share some similarities, they also have notable differences. That’s where Stacks Connect comes in. Unless absolutely necessary, Stacks Connect is the best choice. I recommend starting with Stacks Connect first.</p><p>For the complete code, please visit <a href="https://github.com/stxapps/augurrank-firebase/blob/main/src/apis/wallet.ts">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5e40c925884" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Possible errors when calling a Stacks smart contract function]]></title>
            <link>https://medium.com/@0xc22b/possible-errors-when-calling-a-stacks-smart-contract-function-6d960229bc97?source=rss-33dcc1de74b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d960229bc97</guid>
            <category><![CDATA[clarity]]></category>
            <category><![CDATA[stack]]></category>
            <dc:creator><![CDATA[0xc22b]]></dc:creator>
            <pubDate>Tue, 22 Apr 2025 04:50:14 GMT</pubDate>
            <atom:updated>2025-04-22T04:50:14.383Z</atom:updated>
            <content:encoded><![CDATA[<p>When you call a Stacks smart contract function from your application or backend, it’s crucial to thoroughly list and handle all potential errors that may arise to ensure that your application works smoothly and can gracefully manage these scenarios. For example, provide clear feedback to users when an error occurs, log error details for troubleshooting, and consider fallback mechanisms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4wUhpofzBcYxnmS7mdRqng.png" /></figure><p>Some possible errors are:</p><ul><li>Invalid Nonce: The nonce provided in the transaction doesn’t match the expected next nonce for the sending account. It could be too low (already used) or too high (skipping expected nonces).</li><li>Insufficient Fee: The fee is lower than the minimum the node requires or the current network congestion demands.</li><li>Insufficient STX Balance for Fees: Even if the specified fee amount is okay, the sending account doesn’t have enough liquid STX to pay that fee.</li><li>Invalid Signature: The transaction’s cryptographic signature doesn’t verify against the sender’s public key, meaning it wasn’t signed correctly or the transaction data was tampered with after signing.</li><li>Incorrect Network ID: The transaction specifies a different network ID (e.g., mainnet vs. testnet) than the node it’s submitted to is operating on.</li><li>Insufficient Asset Balance (FT/NFT/STX): This happens inside the function logic when trying to transfer an asset the tx-sender (or an account the contract controls) doesn’t own or doesn’t have enough of.<br>- stx-transfer?: Not enough liquid STX.<br>- ft-transfer?: Not enough fungible tokens of the specified type.<br>- nft-transfer?: The sender does not own the specific NFT being transferred.</li></ul><p>The list provided is not exhaustive but is a good starting point for identifying common issues. A thorough understanding of these errors and effective strategies for handling them are essential for creating a reliable and seamless user experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d960229bc97" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to exp() and ln() in Clarity language for Stacks smart contracts]]></title>
            <link>https://medium.com/@0xc22b/how-to-exp-and-ln-in-clarity-language-for-stacks-smart-contracts-8caa105787cd?source=rss-33dcc1de74b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8caa105787cd</guid>
            <category><![CDATA[arithmetic]]></category>
            <category><![CDATA[clarity]]></category>
            <category><![CDATA[defi]]></category>
            <dc:creator><![CDATA[0xc22b]]></dc:creator>
            <pubDate>Thu, 10 Apr 2025 12:00:39 GMT</pubDate>
            <atom:updated>2025-04-10T12:00:39.641Z</atom:updated>
            <content:encoded><![CDATA[<p>Clarity’s design prioritizes security and decidability, which is why it sticks to integers (int and uint) and no floating-point arithmetic. This makes sense — floating-point operations can introduce rounding errors and unpredictability, which are risky in smart contracts handling real-world value. But it leaves us without direct access to functions like exp() and ln(), which are staples in financial calculations, probability models, and more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*CubwD0o2RUAPk5b29GqupQ.png" /></figure><p>For example, imagine you’re building a DeFi contract on Stacks that needs to compute compound interest using e^(rt) or determine a logarithmic decay rate with ln(). Without floating-point support or built-in functions, you’re stuck — unless you get creative.</p><p>In this post, I’ll share a practical workaround using fixed-point integers (with the last six digits as decimals), lookup tables, and linear interpolation to approximate these functions in Clarity.</p><h4>Fixed-point Integer as floating-point representative</h4><p>Treat the last six digits of an integer as the decimal part. For instance:</p><ul><li>1.234567 becomes 1234567</li><li>e≈2.718281 becomes 2718281</li><li>0.5 becomes 500000</li></ul><p>This gives us decent precision while staying within Clarity’s integer limits (int ranges from -2¹²⁷ to 2¹²⁷-1, and uint from 0 to 2¹²⁸ — 1).</p><p>Clarity’s arithmetic operations (+, -, *, /) work fine with these integers, but we need to adjust for scaling during multiplication and division. For example:</p><ul><li>Multiplication: (a * b)/10⁶ because multiplying two scaled numbers doubles the scale. We need to divide it by 10⁶ to scale it back.</li><li>Division: (a * 10⁶) / b because dividing two scaled numbers cancels the scale. We need to multiply it with 10⁶ to scale it back, and we do it first to avoid losing precision.</li></ul><h4>Lookup tables</h4><p>Precompute exp() and ln() values for a range of inputs and store them as integers in the contract. These tables act as our reference points. For example:</p><pre>(define-map exp-lookup { x: uint } { value: uint })<br>(begin<br>  (map-insert exp-lookup { x: u0 } { value: u1000000 })<br>  (map-insert exp-lookup { x: u10000000 } { value: u22026465794 })<br>  (map-insert exp-lookup { x: u20000000 } { value: u485165195409790 })<br>  (map-insert exp-lookup { x: u30000000 } { value: u10686474581524463000 })<br>)</pre><p>Here, x is the input (scaled by 10⁶), and y is the output (also scaled). The granularity depends on your use case — more entries mean better accuracy but higher storage costs.</p><h4>Linear Interpolation</h4><p>For inputs between table entries, estimate the result by interpolating between the nearest known values. This keeps our approximations fast and simple, aligning with Clarity’s decidable nature.</p><p>The formula for linear interpolation between points (x0,y0) and (x1,y1) for an input (x) is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*ILbuGy3b2fxocJkyElUpFw.png" /></figure><p>In Clarity, this becomes:</p><pre>(define-read-only (exp (x uint))<br>  (let<br>    (<br>      (lower-x (get-exp-lower x))<br>      (upper-x (get-exp-upper x))<br>      (lower-val (get value (unwrap-panic (map-get? exp-lookup { x: lower-x }))))<br>      (upper-val (get value (unwrap-panic (map-get? exp-lookup { x: upper-x }))))<br>      (diff-x (- upper-x lower-x))<br>      (val (if (is-eq diff-x u0)<br>        u0<br>        (/ (* (- upper-val lower-val) (- x lower-x)) diff-x)<br>      ))<br>    )<br>    (+ lower-val val)<br>  )<br>)</pre><p>For full implementation on both exp() and ln(), please look at <a href="https://augurrank.com/">AugurRank</a>’s prediction markets <a href="https://github.com/stxapps/augurrank-smart-contracts/blob/main/contracts/augur-markets.clar">smart contract</a>.</p><h4>Trade-Offs and Considerations</h4><ul><li>Precision: Six decimal places work for many applications, but you can adjust the scale (e.g., 10⁸) for more precision, mindful of integer limits.</li><li>Storage: Larger lookup tables improve accuracy but increase contract size and deployment costs.</li><li>Performance: Linear interpolation is fast and fits Clarity’s decidable model, but for higher accuracy, we need more sophisticated methods (e.g., Taylor series), which are trickier without loops and a lot heavier computation.</li></ul><p>Approximating exp() and ln() opens the door to advanced financial logic on Stacks — like interest calculations, option pricing, or logarithmic scaling — while staying within Clarity’s secure, integer-only world. It’s a testament to how creative workarounds can extend a language’s capabilities without compromising its core principles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8caa105787cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debugging through newly written source code at least once is underrated]]></title>
            <link>https://medium.com/@0xc22b/debugging-through-newly-written-source-code-at-least-once-is-underrated-77b2e3a971a3?source=rss-33dcc1de74b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/77b2e3a971a3</guid>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[0xc22b]]></dc:creator>
            <pubDate>Thu, 30 Jan 2025 11:39:32 GMT</pubDate>
            <atom:updated>2025-01-30T11:39:32.392Z</atom:updated>
            <content:encoded><![CDATA[<p>Based on my 10+ years of experience in programming, I always get some benefits when I debug line by line on my newly written source code. Not only do I often find a bug, but I also find my misunderstandings or learn new things.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gno5Yyse9_CrvDa1" /><figcaption>Photo by <a href="https://unsplash.com/@cdr6934?utm_source=medium&amp;utm_medium=referral">Chris Ried</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As development tools are getting better, debugging is easier than ever. One of my rules of thumb is to debug through all my newly written source code line by line at least once. I start a debugger tool and set breakpoints at every start of newly written chunks of source code or functions. Then, I debug step by step from each breakpoint. I delete breakpoints only if they have been executed. I do this until there are no breakpoints left.</p><p>The apparent benefit is to find and fix bugs. The not-so-obvious benefit is to reevaluate whether what is in my mind matches what happens in the real world. From time to time, I find something I misunderstand or something I don’t know or haven’t thought about before.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77b2e3a971a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Search for a Status Page Service]]></title>
            <link>https://medium.com/@0xc22b/my-search-for-a-status-page-service-fcdf2d11158a?source=rss-33dcc1de74b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcdf2d11158a</guid>
            <category><![CDATA[status-page]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[saas-tools]]></category>
            <dc:creator><![CDATA[0xc22b]]></dc:creator>
            <pubDate>Wed, 20 Nov 2024 08:20:56 GMT</pubDate>
            <atom:updated>2024-11-20T08:20:56.818Z</atom:updated>
            <content:encoded><![CDATA[<p>I wanted a simple status page to check my website’s availability and show it to my users so they would know if something was wrong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*gg0fJwPEiwtCaZ_EmqmtjA.png" /></figure><p>As a new trend, I started searching for a status page service by asking AI bots — Perplexity, Gemini, and ChatGPT — what the best status page service is. They all gave similar answers, so I compiled them into a list and looked into them individually.</p><p>I tried <a href="https://instatus.com/">Instatus</a> first. After finishing all the setup, I discovered that it’s just a status page, and I need a third-party monitoring tool to integrate with it. I just knew that it’s not a one-stop shop. There are two separate services — a status page and a monitoring tool. Some brands provide both, and some give only one.</p><p><a href="https://www.atlassian.com/software/statuspage">Atlassian StatusPage</a> doesn’t come with monitoring tools, either. My search needed to continue.</p><p>Next on my list are <a href="https://status.io/">Status.io</a> and <a href="https://www.statuspal.io/">StatusPal</a>. Sadly, they don’t have a free plan. My requirement was simple, and having it for free now would be great.</p><p>I checked <a href="https://cachethq.io/">Cachet</a>. It’s open-source, but self-hosting is too much work for me.</p><p>Finally, my search was completed after I tried <a href="https://betterstack.com/">Better Stack</a>. Its free plan is sufficient, and surprisingly, it also includes a custom domain feature! We can have up to 10 monitors for free, and its default status page is excellent without needing customization. My two status pages for <a href="https://status.brace.to/">Brace.to</a> and <a href="https://status.justnote.cc/">Justnote</a> were up in less than 15 minutes. Impressive!</p><p>PS. <a href="https://uptimerobot.com/">UptimeRobot</a> was left on my list, and I thought it was a good candidate, but I didn’t try it because my search was already done.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcdf2d11158a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Should your URL path end with a trailing slash?]]></title>
            <link>https://medium.com/@0xc22b/should-your-url-path-end-with-a-trailing-slash-cf6e85d0b147?source=rss-33dcc1de74b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf6e85d0b147</guid>
            <category><![CDATA[static-websites]]></category>
            <category><![CDATA[cloudfront-functions]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[0xc22b]]></dc:creator>
            <pubDate>Fri, 01 Nov 2024 03:55:03 GMT</pubDate>
            <atom:updated>2024-11-01T03:55:03.338Z</atom:updated>
            <content:encoded><![CDATA[<p>URL paths can end with or without a trailing slash. From a user perspective, this might be the same. However, on cloud storage like AWS S3, a URL path without a trailing slash refers to a file, and with a trailing slash, it refers to a directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1VbJy2lXU4TAE_3S" /><figcaption>Photo by <a href="https://unsplash.com/@firmbee?utm_source=medium&amp;utm_medium=referral">Firmbee.com</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A file can be without a file extension, so a URL path without a trailing slash can refer to it. However, it’s not easy to work with; for example, Next.js generates files with the HTML extension by default for a static website. We need a custom script to remove the extension and manually set the content type when uploading. Syncing files between a local device and cloud storage is more complicated.</p><p>Next.js can generate directories instead (In next.config.js, trailingSlash: true). This is to work with AWS S3 by requiring every URL path to end with a slash to retrieve a default file inside that directory. ASW S3 will automatically redirect a URL from without a trailing slash to a trailing slash. However, redirecting hurts performance as it ends up with two requests.</p><p>With all that said, let’s choose a URL without a trailing slash just for a more straightforward URL structure. More importantly, we must be consistent for the best UX and SEO. And to not work with files without a file extension, only AWS S3 is not enough; we need AWS CloudFront and AWS CloudFront Function, too.</p><p>The combination of AWS S3 and CloudFront is excellent, and adding CloudFront Function makes it perfect for a static website. It’s cheap, globally content-distributed, feature-rich (predefined performance/redirect/security options), and customizable.</p><p>We can use the AWS CloudFront Function to:</p><ul><li>Redirect a URL with a trailing slash to without while preserving its query string.</li><li>Append ‘.html’ to a URL that refers to an HTML file if it’s missing</li></ul><pre>function objectToQueryString(querystring) {<br>  const str = [];<br>  for (const param in querystring) {<br>    const query = querystring[param];<br>    if (query.multiValue) {<br>      // Handle multi-value parameters<br>      const mvStr = query.multiValue.map(item =&gt; {<br>        return encodeURIComponent(param) + &#39;=&#39; + encodeURIComponent(item.value);<br>      });<br>      str.push(mvStr.join(&#39;&amp;&#39;));<br>    } else if (query.value === &#39;&#39;) {<br>      // Handle empty parameters<br>      str.push(encodeURIComponent(param));<br>    } else {<br>      // Handle single-value parameters<br>      str.push(encodeURIComponent(param) + &#39;=&#39; + encodeURIComponent(query.value));<br>    }<br>  }<br>  return str.join(&#39;&amp;&#39;);<br>}<br><br>function handler(event) {<br>  // NOTE: This function is for a viewer request event trigger.<br>  // Choose viewer request for event trigger when you associate<br>  //   this function with a distribution.<br>  const request = event.request;<br>  const uri = request.uri;<br><br>  if (uri === &#39;&#39; || uri === &#39;/&#39;) return request;<br>  if (uri.endsWith(&#39;/&#39;)) {<br>    let redirectUrl = uri.slice(0, -1);<br><br>    const qss = objectToQueryString(request.querystring);<br>    if (qss) redirectUrl += &#39;?&#39; + qss;<br><br>    return {<br>      statusCode: 301,<br>      statusDescription: &#39;Moved Permanently&#39;,<br>      headers: {<br>        location: { value: redirectUrl },<br>      },<br>    };<br>  }<br>  if (uri.split(&#39;/&#39;).pop().includes(&#39;.&#39;)) return request;<br><br>  request.uri += &#39;.html&#39;;<br>  return request;<br>}</pre><p>URL paths can end with or without a trailing slash. Consistency is critical for the best UX and SEO. You can customize a static website generated by Next.js, deployed to AWS S3, and distributed on AWS CloudFront to your preference.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf6e85d0b147" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Force use of NPM or Yarn with a ~/.bashrc file]]></title>
            <link>https://medium.com/@0xc22b/force-use-of-npm-or-yarn-with-a-bashrc-file-bbb9840fea83?source=rss-33dcc1de74b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbb9840fea83</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[0xc22b]]></dc:creator>
            <pubDate>Wed, 04 Sep 2024 05:22:31 GMT</pubDate>
            <atom:updated>2024-09-04T05:22:31.886Z</atom:updated>
            <content:encoded><![CDATA[<p>After using Create React App with yarn v.1 for most of my projects for over four years, it’s time to move on, as there has been no update to CRA for years, and there is something newer than Webpack. I’ve decided to try Next.js with npm for more capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nXvjEjWKuq6BfdgF" /><figcaption>Photo by <a href="https://unsplash.com/@6heinz3r?utm_source=medium&amp;utm_medium=referral">Gabriel Heinzer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>From now on, I must find a way to live with npm and yarn. I am concerned that I will mix up using yarn on npm projects and vice versa.</p><p>I’ve found two ways to prevent it. We can specify which to use and not in package.json. But I don’t want to repeat myself too much as I have several projects, and it seems we can force only with the install command. Another way is to do it in a ~/.bashrc file. The drawback is that it has the potential for confusion as it shadows the actual commands and can only force me, not others.</p><p>Nonetheless, here I am. Let’s go to ~/.bashrc file and put the script below.</p><pre>npm () {<br>  NPM_PATH=$(which npm)<br>  if [ -e yarn.lock ]; then<br>    echo &quot;Please use yarn with this project&quot;<br>  else<br>    $NPM_PATH &quot;$@&quot;<br>  fi<br>}<br>yarn () {<br>  YARN_PATH=$(which yarn)<br>  if [ -e package-lock.json ]; then<br>    echo &quot;Please use npm with this project&quot;<br>  else<br>    $YARN_PATH &quot;$@&quot;<br>  fi<br>}</pre><p>reference:<br> • <a href="https://www.freecodecamp.org/news/how-to-force-use-yarn-or-npm">https://www.freecodecamp.org/news/how-to-force-use-yarn-or-npm</a><br> • <a href="https://stackoverflow.com/questions/41076172/force-yarn-install-instead-of-npm-install-for-node-module">https://stackoverflow.com/questions/41076172/force-yarn-install-instead-of-npm-install-for-node-module</a><br> • <a href="https://stackoverflow.com/questions/71459020/preventing-npm-commands-in-favor-of-pnpm">https://stackoverflow.com/questions/71459020/preventing-npm-commands-in-favor-of-pnpm</a><br> • <a href="https://medium.com/@chantastic/p-525e68f17e56">https://medium.com/@chantastic/p-525e68f17e56</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbb9840fea83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Justnote — An underrated app]]></title>
            <link>https://medium.com/@0xc22b/justnote-an-underrated-app-1f17e9bf5c8e?source=rss-33dcc1de74b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f17e9bf5c8e</guid>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[note-taking-app]]></category>
            <dc:creator><![CDATA[0xc22b]]></dc:creator>
            <pubDate>Tue, 06 Aug 2024 04:33:23 GMT</pubDate>
            <atom:updated>2024-08-06T04:33:23.346Z</atom:updated>
            <content:encoded><![CDATA[<h3>Justnote — An underrated app</h3><p>I’ve used it as my go-to app for brain dumps for years and never look back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PeuUxNSr9k-F14icEO09aw.png" /></figure><p>Despite the many note-taking apps, <a href="https://justnote.cc/">Justnote</a> is the best for me. I’ve tried everything from Google Keep to Notion, but only like the simple Justnote.</p><p>I don’t need a fancy notes app. I keep a few notes, so I don’t need anything fancy here. All I need are some basic formatting options and the ability to pin notes to the top and organize them into some basic folders — both of which Justnote provides.</p><p>What is most important to me is privacy. I need end-to-end encryption, with only me knowing the Secret Key, so that only I can decrypt, access, view, and edit my notes. This way, it guarantees that I truly own my data. No one else can access and view it without my permission, not even the service owner.</p><p>Justnote has everything I mentioned above. Plus, it is <a href="https://github.com/stxapps/justnote-client">open source</a> for transparency and reasonably priced to unlock all the extra features. Everyone can inspect and validate that it is doing the right thing as it claims. Everyone can enjoy the benefits at a minimum cost while the business is sustainable.</p><p>With simplicity, privacy, and reasonable price, Justnote is my best notes app. It’s an underrated app waiting for more people to find and <a href="https://justnote.cc/">check it out</a> to see whether what I say is true.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f17e9bf5c8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>