RSSAmplifier

Blog

geekAbyte

geekabyte.ioRSS feed ↗25 posts

Latest posts

Blockchain Protocol Development Guide

I recently moved my Blockchain Protocol Development Guide to its own site: Blockchain Protocol Development Guide . The guide is for developers coming from a traditional web application development background who are interested in blockchain protocol development. The aim is to present the core concepts such a developer should understand before getting into the details of a particular blockchain…

FuturesOrdered: Keeping Concurrency in Order In Rust

The use case is as follows: You have some tasks you want to execute concurrently, but you want the results to be returned in the same order the tasks were defined to be executed. As an example, let's say you have some records returned from the database, as specified by some query. But before returning the records, some transformation needs to be done, and these transformations can be done…

Fixing "Failed to get Recent Blockhash" Error in Solana Development with Anchor Framework

I took a break from exploring development in Solana, and the first thing I hit when I recently resumed again was failing tests when using the Anchor framework. Running anchor run test leads to this error: 1) calculator Is initialized!: Error: failed to get recent blockhash: FetchError: request to http://localhost:8899/ failed, reason: connect ECONNREFUSED ::1:8899 at Connection.getLatestBlockhash…

A Short Note on Types in Rust

Types, loosely defined, are about capabilities. What are the capabilities available on a value of a certain type? Programmers experienced with strong and statically typed languages will probably have a more visceral appreciation of this, but even programmers of weakly and dynamically typed languages like JavaScript, encounter the reality of types and their capabilities; only that they do so at…

Introduction to Declarative Macros in Rust

This post will give a quick overview of declarative macros in Rust. If you are not familiar with the concepts of macros in Rust, then read Introduction to Macros in Rust first. Declarative macros work similar to how pattern matching works. It involves taking inputs, then pattern matching to determine what logic to execute. The macros definition for creating declarative macros, then contains rules…

Introduction to Macros In Rust

This guide will present an overview of the fundamentals a new developer approaching macros in Rust needs to know. If you have read other materials online and you still find the concept of macros in Rust vague, then this post is for you. The guide will be broken into 4 series of posts. The first post, which is this post, will be a quick overview of macros in Rust. The following 3 posts will then…

How to query account balance on Solana using Rust.

This post shows how to query Solana's cluster rpc endpoint using Rust. Most of the examples of how to perform this task that I ran to uses Javascript/Typescript via the Solana Web3js library , so I decided to do a quick post showing how to do same but in Rust. It uses querying for the sol balance of a Solana account as the main example of interaction with the rpc endpoint. The task is simple:…

IntoIterator and the for ... in Syntax in Rust

In Rust Iterator pattern with iter(), into_iter() and iter_mut() methods I explained why attempting to use a variable holding a Vec after iterating through it using the for … in syntax leads to a compilation error. The post explains why the following code won't compile: fn main () { let some_ints = vec! [ 1 , 2 , 3 , 4 , 5 ]; // iterating through a vec for i in some_ints { dbg!(i); } // attempting…

Rust Iterator pattern with iter(), into_iter() and iter_mut() methods

Let's create a vec of integers, iterate through and print the individual values, and then afterward, print out the whole vec . Here is the code: fn main () { let some_ints = vec! [ 1 , 2 , 3 , 4 , 5 ]; for i in some_ints { dbg!(i); } dbg!(some_ints); } Simple right? Well nope. Trying to compile the above code will fail with the following errors: error[E0382]: use of moved value: `some_ints` -->…

Introduction to Digital Signature for the Working Developer

In this post, we would be looking at digital signatures. It will be a quick, straight-to-the-point overview of some of the essential things a developer should know about digital signatures. How to think about them and what problems they solve. It is targeted at the working developer who needs to be familiar enough with digital signatures to use them, but who does not need to know the gory details…

Introduction to Asymmetric Encryption for the Working Developer

In this post, we are going to look at asymmetric encryption. As mentioned in the previous post on symmetric encryption , encryption is the cryptographic primitive that guarantees confidentiality, by which we mean the ability for two or more authorized parties to communicate, without an unauthorized person being able to decipher the messages being communicated. In symmetric encryption, both parties…

A Neophyte's Introduction to the async/await landscape in Rust

The truth of the matter is, the async/await features in other programming languages seem to be more straightforward than it is in Rust. For example in JavaScript, you have the syntax that you use, and that is about it. But in Rust, there seem to be more moving parts. Tokio? Future? There is a futures crate? Runtimes? How do all these fit into the async/await picture in Rust? This is a short post…

Introduction to Key Exchange for the Working Developer

In Introduction to Symmetric Encryption for the Working Developer , we saw how to encrypt and decrypt data. Being symmetric encryption, both the process of encryption and decryption needed the same key. This poses a challenge, which was not addressed in the post: How do one get across the same key to both parties who want to engage in encrypted communication? Basically how do we perform key…

Introduction to Authenticated Encryption for the Working Developer

In Introduction to Symmetric Encryption for the Working Developer , I presented an overview of symmetric encryption. Which as explained in the post, is a process for establishing confidentiality during communication between two parties. The only problem is that just encrypting data using symmetric encryption does not provide all the security requirements needed during secure communication. The…

Introduction to Symmetric Encryption for the Working Developer

Encryption is all about establishing confidentiality. That is, making sure only authorised parties have access to specific data. It involves transforming data into a form that is inscrutable to unauthorised parties but with the ability for authorised parties to transform the data back into its legible form. Think about two parties communicating without wanting other persons privy to the messages.…

Hash Function in Action: Message Authentication Codes

In Introduction to Cryptographic Hash Functions for the Working Developer , I presented a straight to the point, overview of some essential things a developer should know about cryptographic hash functions. This post continues in the theme around hash functions, by taking a look at another cryptographic construction hash functions make possible, that is: Message Authentication Codes (MACs). It is…

Introduction to Cryptographic Hash Functions for the Working Developer

Much more than encryption algorithms, one-way hash functions are the workhouses of modern cryptography - Bruce schneier This post would be a quick, straight to the point, overview of some essential things a developer should know about cryptographic hash functions. It is targeted at the working developer who needs to be familiar enough with cryptographic hash functions in order to use them, but who…

NFTs are not to blame

T206 Honus Wagner baseball card sold for $6.606 million just this August 2021, Pikachu Illustrator, a pokeman card sold for $195,000 in 2019. You can get different Micheal Jordan's basketball card on e-bay ranging from couple of thousands to couple of millions . Sentimental and collectible items have always been part of the human experience. NFTs are not to blame. Why should pieces of cards with…

Why I am offering NFTs as a crowdfunding perk

Non-equity funding campaigns are always based on promises: "Back us now, and we promise you early access to the product when we launch, or we promise you a discount, digital shout-out or swags". I am currently running an Indiegogo campaign where the promise will also include an NFT: Non Fungible Token, which is a digital artifact that can be used to prove things like ownership. This, as far as I…

Understanding the Magic behind Utility Types in TypeScript

This post will be the conlcuding post in the Introduction to Advanced Types in TypeScript series. It looks at some of the utility Types in TypeScript, explain how it works while pointing out the features within the TypeScript type system that makes it possible. Why TypeScript? TypeScript comes with a powerful and expressive type system. Its expressiveness makes it a joy to work with while its…

First impressions with Deno from building PlanetTypeScript.com

PlanetTypeScript.com is a content aggregator for all things TypeScript. It regularly polls RSS feeds for TypeScript related content, which it then list on the site, send out as a tweet via @planetypescript , and also as a weekly digest to subscribers. Back when I used to write a lot of Java-related content on this blog, I found out that my blog ended up on www.topjavablogs.com/ , which is a site…

3 Ways to Name Types in Typescript

TypeScript type's system is structural and hence, it allows for the easy creation of types based on the shape of data. These types can be created and used without having a name. For example: let john: {name: string, age: number} = { name: "John Doe", age: 30 } Where {name: string, age: number} is the type defined. But there is a problem with using the type definition this way. If we want to create…

How to implement sleep function in JavaScript

Most popular mainstream languages have a sleep functionality that allows for the pausing of code execution for a specified amount of time. Not surprising this functionality is often implemented via a function usually named sleep . For example: // ruby sleep(time_secs) // python import time time.sleep(time_secs) // Java Thread.sleep(time_milli_secs) // Perl sleep(time_secs) JavaScript does not have…

Callback, Promise and Async/Await by Example in JavaScript

This post is going to show, by way of code examples, how to take a callback based API, modify it to use Promises and then use the Async/Await syntax. This post won't go into a detailed explanation of callbacks, promises or the Async/Await syntax. For such a detailed explanation of these concepts please check Asynchronous JavaScript , which is a section of MDN Web Docs, that explains asynchronicity…

ip-num v1.3.2 has been released

ip-num is A TypeScript/JavaScript library for working with ASN, IPv4, and IPv6 numbers. It provides representations of these internet protocol numbers with the ability to perform various IP related operations like parsing, validating etc, on them. A new version of ip-num , version 1.3.2 is now available. This release contains one new feature and a bug fix. Add method to split range into smaller…