update posts

This commit is contained in:
jetstream0
2023-08-02 15:03:09 -07:00
parent 50b9797612
commit d8bfe2c5ed
7 changed files with 87 additions and 3 deletions

25
posts/190k_faucet.md Normal file
View File

@@ -0,0 +1,25 @@
My Banano faucet, [faucet.prussia.dev](https://faucet.prussia.dev) recently reached an incredible 190k claims. I want to thank everyone who donated to the faucet or used it, and of course the people who contributed to the code: HalfBakedBread, SaltyWalty and KaffinPX.
![190k, yay!](/images/190kyay.png)
## Version 1
Around 2 and a half years ago (wow...), I first launched my Banano faucet. It was my first experience programming in cryptocurrency. After struggling with the libraries for Banano on Python (a problem I fixed a few months ago by writing [bananopie](https://github.com/jetstream0/bananopie)), I switched to using Node.js and Banano.js.
The original faucet... I was not very good at CSS back then:
![Picture of the original faucet](/images/og_faucet.png)
I launched the faucet sometime in October, and it was a great success thanks to everyone in the Banano community. Soon after, SaltyWalty opened an awesome PR that got the faucet looking a lot better. Later, Nano and xDai support was also added to the faucet.
For the next 2 years or so, the faucet was sustained by the generosity of many donors, and I was able to help dozens of others to launch their own Banano faucet, or faucets for other currencies.
It's great to see the Banano faucet scene now thriving, and along the way I've also been commissioned to make faucets to help first time users with gas fees on other chains, like Polygon and Arbitrum Nova.
## Version 2
A couple months ago, I decided I was not satisfied with the code quality of the [original faucet](https://github.com/jetstream0/Banano-Faucet), and started rewriting the code from scratch. The new goal was not just better code, but also a config file that people with just a little, or no technical experience, could modify and easily, quickly start their own faucets.
HalfBakedBread and I finally finished Faucet v2, and the current version of faucet.prussia.dev is using it! I also added Vite support with the help of KaffinPX. Of course, it is open source on [Github](https://github.com/jetstream0/Faucet-v2).
Since the faucet was having problems with Replit (specifically connecting to the mongodb database), the host was also migrated from Replit to Render, which will hopefully work better.
## Future Plans
Currently, there are plans to add Algorand support, and also change the xDai faucet to support any EVM chain.

View File

@@ -5,7 +5,23 @@
"filename": "meta", "filename": "meta",
"date": "01/08/2023", "date": "01/08/2023",
"author": "jetstream0/Prussia", "author": "jetstream0/Prussia",
"tags": ["code", "project", "web", "markdown"] "tags": ["code", "project", "web", "markdown", "typescript/javascript", "css"]
},
"adding-commas": {
"title": "Adding Commas to Numbers",
"slug": "adding-commas",
"filename": "adding_commas",
"date": "15/11/2022",
"author": "jetstream0/Prussia",
"tags": ["code", "typescript/javascript"]
},
"190k-faucet": {
"title": "190000 Payouts!",
"slug": "190-faucet",
"filename": "190k_faucet",
"date": "12/02/2023",
"author": "jetstream0/Prussia",
"tags": ["project", "web", "milestone", "crypto"]
}, },
"ryuji-docs": { "ryuji-docs": {
"title": "Ryuji Documentation", "title": "Ryuji Documentation",
@@ -13,7 +29,7 @@
"filename": "ryuji_docs", "filename": "ryuji_docs",
"date": "02/08/2023", "date": "02/08/2023",
"author": "jetstream0/Prussia", "author": "jetstream0/Prussia",
"tags": ["code", "project", "web", "docs"] "tags": ["code", "project", "web", "docs", "typescript/javascript"]
}, },
"saki-docs": { "saki-docs": {
"title": "Saki Documentation", "title": "Saki Documentation",
@@ -21,6 +37,6 @@
"filename": "saki_docs", "filename": "saki_docs",
"date": "02/08/2023", "date": "02/08/2023",
"author": "jetstream0/Prussia", "author": "jetstream0/Prussia",
"tags": ["code", "project", "web", "build", "docs"] "tags": ["code", "project", "web", "build", "docs", "typescript/javascript"]
} }
} }

42
posts/adding_commas.md Normal file
View File

@@ -0,0 +1,42 @@
I had to add commas to a number in Javascript today. I thought it was kinda interesting, and here is what I came up with:
```js
function format_commas(amount) {
let amount_mod = String(amount);
//iterate the amount of commas there are
for (let i=0; i < Math.floor((String(amount).length-1)/3); i++) {
let position = amount_mod.length-3*(i+1)-i;
amount_mod = amount_mod.substring(0, position)+","+amount_mod.substring(position, amount_mod.length);
}
return amount_mod;
}
```
Basically, we calculate how many commas we will need to add (`Math.floor((String(amount).length-1)/3)`). If the `amount` is 3 digits, we need 0 commas, since `floor((3-1)/3) = floor(2/3) = 0`. If the `amount` is 7 digits, we need 2 commas, since `floor((7-1)/3) = floor(6/3) = 2`. And so on.
Then, we do a for loop with that number, and insert our commas, *starting from the back*. We find the position where we need to split the string in half, and then insert a comma in between the two halves of the string.
I think the most interesting part of this code was the 5th line (`let position = amount_mod.length-3*(i+1)-i;`). You might be wondering with the `-i` at the end is necessary. That's there because we are increasing the string's length by adding a comma, so we need to offset it. Remember, we are inserting commas starting from the back of the string, so we are subtracting to offset, not adding.
![Demo](/images/commas.gif)
Here is a version that can handle decimals and invalid inputs:
```js
function format_commas(amount) {
if (isNaN(Number(amount))) {
return amount;
}
let before_dec = String(amount).split('.')[0];
let amount_mod = before_dec;
//iterate the amount of commas there are
for (let i=0; i < Math.floor((before_dec.length-1)/3); i++) {
let position = amount_mod.length-3*(i+1)-i;
amount_mod = amount_mod.substring(0, position)+","+amount_mod.substring(position, amount_mod.length);
}
if (String(amount).split('.')[1]) {
amount_mod = amount_mod+"."+String(amount).split('.')[1];
}
return amount_mod;
}
```

View File

@@ -14,6 +14,7 @@ Anyways, once I decided to start completely rewriting the blog, I established so
- Use Typescript - Use Typescript
- No Javascript running client side - the web pages should be pure HTML and CSS - No Javascript running client side - the web pages should be pure HTML and CSS
- Style-wise, should be minimalistic, nothing fancy - Style-wise, should be minimalistic, nothing fancy
- Load quickly and be small in size
## Non-Technical Goals ## Non-Technical Goals
- Make two things I can call "Ryuji" and "Saki" to go along with "Makoto" (those are the three main characters of one of the best manga series ever) - Make two things I can call "Ryuji" and "Saki" to go along with "Makoto" (those are the three main characters of one of the best manga series ever)

BIN
static/images/190kyay.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
static/images/commas.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
static/images/og_faucet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB