teleren/devto huggingface dataset:
What Problems of Bitcoin Does Ethereum Solve?
Tags: blockchain
Published: 2021-10-16 05:35:39

Ethereum was created by Vitalik and his team as an attempt to improve the features of Bitcoin. This post will discuss the problems that Ethereum solves (this post will not cover PoW and PoS).

**The main difference between Bitcoin and Ethereum is Ethereum's ability to store code that executes programs.** This means that it gives any application built on the blockchain the ability to become decentralized. No super server would be necessary to store all our data but we would instead use everyone's computer to execute apps and programs.

**How does Ethereum make this possible?**
Ethereum uses a feature called a **smart contracts**. It allows anyone to code on the blockchain. Bitcoin also has this feature but its major downfall is that it isn't Turing Complete, meaning that you cannot implement certain types of logic. The main reason Bitcoin Script is not Turing Complete is because it cannot implement loops (e.g. for loop, while loop, etc.). The reason loops were not created in Bitcoin Script was because it could slow down the process tremendously because loops can run forever especially if some malicious user had the motive to do so.

However, Vitalik, the creator of Ethereum, decided that it was necessary for the language to be Turing Complete and went on to create Ethereum and Solidity.

**Problem 1: What if someone creates a virus in the network?**
If a malicious user creates a virus then everyone will have a virus copied on to their network. Ethereum implements something called the **Ethereum Virtual Machine(EVM)**. Whenever someone decides to participate in the Ethereum network you actually participate as an EVM. This basically means that there is another computer(virtual machine) running inside your computer and code that gets executed in the virtual machine runs there only. So any virus that attempts to access your camera or files on your hard drive would be prevented from doing so.

**Problem 2: What if someone creates an infinite loop that slows down the network?**
Ethereum implements something called **Gas**. Gases are a price to every operation that is run on the network. This incentivizes everyone to write really good, efficient code because the more operations you have the more expensive it is to run. Now people may ask whether Ether and Gas are two different things. Yes, they are. The reason Ether is not used as a payment method for smart contracts is because the value of Ether fluctuates a lot. But there is a conversion rate for Gas into Ether which is decided by community consensus.
Three.js พื้นฐาน
Tags: javascript, tutorial, beginners
Published: 2021-10-16 05:31:31

#Introduction เริ่ม

Credit: [https://threejs-journey.com/](https://threejs-journey.com/) ต้อนรับทุกท่านเลยนะครับ สำหรับหัวข้อ Three.js พื้นฐาน ผมจะอธิบายการใช้งานเบื้องต้นของ Three.js จากบทเรียนที่ได้เรียน และรับรู้จากแหล่งอื่นมา โดยจะพูดจากสิ่งที่ผมเข้าใจ (ผมก็ไม่ได้เก่งนะครับ อาจจะมีบางอย่างผิดพลาด) จะพยายามอธิบายแบบเข้าใจง่ายๆนะครับ

##ตัวอย่างโปรเจคที่สร้างด้วย Three.js

* [https://bruno-simon.com](https://bruno-simon.com) `portfolio ของผู้พัฒนา`
* [https://go.pioneer.com/cornrevolution](https://go.pioneer.com/cornrevolution)
* [https://richardmattka.com](https://richardmattka.com)
* [https://lusion.co](https://lusion.co)
* [https://www.oculus.com/medal-of-honor/](https://www.oculus.com/medal-of-honor/)
* [http://letsplay.ouigo.com](http://letsplay.ouigo.com)
* [https://zen.ly](https://zen.ly)
* [https://prior.co.jp/discover](https://prior.co.jp/discover)
* [https://www.midwam.com](https://www.midwam.com)
* [https://heraclosgame.com](https://heraclosgame.com)
* [https://chartogne-taillet.com](https://chartogne-taillet.com)
* [https://live.vanmoof.com/site](https://live.vanmoof.com/site)

`แต่ละโปรเจคอย่างเจ๋งเลยใช่ไหมครับ`

###เขาทำสิ่งต่างๆ เหล่านี้ได้อย่างไร ???

เราอาจจะพอเข้าใจบ้างแล้วว่า Three.js สามารถทำอะไรได้บ้างแล้ว ก่อนเข้าเนื้อหา ผมจะพูดถึง webGL ก่อน

**webGL สั้นๆ**

 WebGL: Web Graphics Library (JavaScript API) เป็นตัวที่สามารถนำกราฟิกส์มาแสดงบนเว็บได้นั้นเอง ทั้งในรูปแบบ 2D และ 3D 

`เจ้า Three.js ใช้คุณสมบัติของ WebGL นี้แหละมาใช้งานในการแสดงผล`
Converting date to relative time format in TypeScript
Tags: typescript, beginners, webdev, tutorial
Published: 2021-10-16 05:31:02

If you are developing an application which has to display timestamp for posts/comments/notifications, you might come across this requirement where you have to format time in "from now" format. This is sometimes called timeago or relative time. 

You can either use a third party library like `dayjs` or `momentjs` for this, but for small projects, it is better to come up with your own utility function. In this tutorial we will write a util function which will accept a javascript Date object/ a string in ISO YYYY-MM-DD format/ or a date timestamp and convert it to relative time.
```javascript
Eg:  2020-10-15 will be converted to "an year ago"
```
JavaScript Date objects represent a single moment in time in a platform-independent format.It is is fundamentally specified as the number of milliseconds that have elapsed since midnight on January 1, 1970, UTC.
 
To convert the an input date to relative format, first we will define our time boundries in unit which we want to keep out least count. I am taking it in seconds, so the smallest difference that my method can return will be in seconds.

```javascript
const units = [
  { label: 'year', seconds: 31536000 },
  { label: 'month', seconds: 2592000 },
  { label: 'week', seconds: 604800 },
  { label: 'day', seconds: 86400 },
  { label: 'hour', seconds: 3600 },
  { label: 'minute', seconds: 60 },
  { label: 'second', seconds: 1 }
];
```
Let's write our util method now. We will input a date and find the difference between the input and the current moment. We can get the current date by using the Date API and calling the valueOf method on a new instance of Date object. The inout date is then subtracted from this value. Now we find the nearest unit to the input date. The method `calculateTimeDifference` will take the milliseconds equivalent of Date for simplifying calculations. The nearest unit will be the one which has the quotient greater than 1 as we have defined our units in decending order. Once we get the quotient greater than 1, we will return that value with the respective unit. That will be used to contruct our string. You can check the snippets below:

```javascript
const timeAgo = (date: string | number | Date) => {
  const time = Math.floor(
    (new Date().valueOf() - new Date(date).valueOf()) / 1000
  );
  const { interval, unit } = calculateTimeDifference(time);
  const suffix = interval === 1 ? '' : 's';
  return `${interval} ${unit}${suffix} ago`;
};
```

```javascript
const calculateTimeDifference = (time: number) => {
  for (let { label, seconds } of units) {
    const interval = Math.floor(time / seconds);
    if (interval >= 1) {
      return {
        interval: interval,
        unit: label
      };
    }
  }
  return {
    interval: 0,
    unit: ''
  };
};
```
Service Status Monitoring Using WhatsApp, Notion, and Python
Tags: python, twilio, monitoring, automation
Published: 2021-10-16 05:02:39

Websites and APIs go down more often than we’d all like. Wouldn’t it be great to get a WhatsApp notification when your favorite or most-used services are experiencing downtime?

So, I wrote this tutorial to help you set up automated monitoring for your favorite services and receive WhatsApp notifications when the status of your services changes. You'll use Notion for the database, Twilio’s WhatsApp Business API for receiving notifications, GitHub actions for running our job on a schedule, and we’ll code everything in Python.

Read the full blog on [Twilio](https://www.twilio.com/blog/service-status-monitoring-whatsapp-notion-python).

Thanks for reading 💜

---

I publish a [monthly newsletter](https://www.ravsam.in/newsletter/) in which I share personal stories, things that I am working on, what is happening in the world of tech, and some interesting dev-related posts which I across while surfing on the web.

Connect with me through [Twitter](https://twitter.com/ravgeetdhillon) • [LinkedIn](https://linkedin.com/in/ravgeetdhillon) • [Github](https://github.com/ravgeetdhillon) or send me an [Email](mailto:ravgeetdhillon@gmail.com).

— [Ravgeet](https://www.ravgeet.in/), *Full Stack Developer and Technical Content Writer*
How to calculate your age on mars
Tags: go, tutorial, beginners
Published: 2021-10-16 04:20:47

Good Morning!,
today i want to make a tutorials about how to calculate your age on mars with Go!, Its very simple and easy but is funny.


Okey let go!



## 1. make Folder and Go file
i make folder to save this tutorials, and make a go file with name **main.go** 

## 2. Then, we start coding!
In file **main.go** , create "package main" in the top **main.go**
![make package main for main.go](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k6j1p450l4tzcsax3gq3.png)
 
## 3. step 3, make the contents the code
After create "Package main", next we make a **import "fmt"** under package main. 
![import fmt package for to be able to print text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5voew4tjf0l1rwn4crp.png)
 
make a function main and variabel with name "age" and with type **int** is for interger, after make variabel we make a output for to tell the user to enter a number 
![func main and declaration variabel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vh0dx26amyndt9db6jk8.png)
 
## 4. Make input for user
Now we make a input field for user with **fmt.Scaln** , which receives the address of the age variable using a pointer 
![make scan ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pvovbvliffn3xna791mw.png)
 
## 5. Make a formula for calculating age on mars
Lest go for make a formula for calculating age on mars, the formula is like this
![Formula calculate age on mars](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oqatw7pquu51hbeqltuo.png)

after make this formula, next we to print of result from formula, this way
![result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c49m2u60ffkgbb447tcn.png)
the parts print the result of the formula, we take the data from mars and then parse it
 
## 5. final result
we run the code with "go run main.go"

 ![result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9t2gun7j35rw66xuwykx.png)

if you want to see my code, this is my code in my repository in  [Github](https://github.com/xvbnm48/go-agemars)

 
## End
and that's my tutorial on how to calculate age on mars, thank you and don't forget to like and share
Madden NFL Game Player's Best Companion | EZMUT
Tags: maddencoins
Published: 2021-10-16 03:18:39

Are you also annoyed that other players have the better MUT 22 team? Then you've come to the right place! It takes an awful lot of time to acquire enough Madden 22 coins. You can buy Madden 22 coins from https://ezmut.com.


Ezmut offers every Hockey Ultimate Team player the possibility to buy cheap Madden 22 Coins for PC, PS4, PS5, Xbox One, and Xbox Series S to have the better team in your next games. We have been selling Madden 22 MUT coins for years without a single complaint. Among 10,000 customers, there is not a single complaint about banned accounts. We think that MUT coins Madden 22 are much more worthwhile. This way, you can decide for yourself which player you invest in. You have the choice. If you also want to have a team like Connor McDavid and Nathan MacKinnon, you can achieve this much cheaper and less stressful by buying MUT coins Madden 22. After all, a few packs can always be opened from the MUT 22 coins that are leftover.
 

EZMUT currently has over 1,393 mostly positive reviews on Trustpilot. Ninety-three percent of users rated coins as "Excellent." The service is praised time and time again for its low prices and fast delivery of coins. If you have any questions, feel free to contact us via our 24/7 live support.
Lab 5 - Improving my code through refactoring
Published: 2021-10-16 03:16:44

Before refactoring, I learned the code structure of other students. I want to improve four features, but I only finished 3 of them before the due time. I have to upload them and the rest I will continue to do it.
1. split the main file.
Before that, all my code was stored in one file. I split it to two files, one store the main function named ssg_main.py. Another is assist file, and it stores all helper functions.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7j8fpdf4nyyzw1vzas6m.png) 
2. merge get file function.
There were two similar functions named get_md_files and get_txt_files. They read two different type files. I merged them into one function, and about 10 lines of statements were saved.![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ps8swaltdw1xv3ggds0i.png) 
3. merge output result function.
There were two similar functions named output_md_result and output_txt_result. I merged them into one function, and about 5 lines of statements were saved.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4y1tenhw1g0q90d2lo4f.png)
4. Try to use pathlib instead of working with path names as strings.
It's not a good idea to work with paths as regular strings because I have to be careful with lots of cross-platform issues, and all of this has been solved with pathlib — Object-oriented filesystem paths. I learned the [pathlib](https://docs.python.org/3/library/pathlib.html), but I didn't modify it successfully before due day. I will continue to do it.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xkywb7cs17ulovcnpzcg.png)
5. How to rebase.
Use $git rebase main -i command, edit 94613fd, 3e7ecc2, 9593d95 from pick to squash. Then use  $git commit --amend to combine four commits to one. The last step is merged refactoring to main and push to origin main.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3h7dkc2jaoqsexwnngvt.png)
6. Reflection.
At the beginning, I don't fully understand rebase command. I use  $ git rebase refactoring -i command, and the terminal can't display all the commit. I should use the main branch to rebase.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g59tscbsihlkf9ebmvks.png)
How to check what font is rendered 👀
Tags: css, webdev, beginners
Published: 2021-10-16 03:07:14

![chrome-devtool](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/05lvz2ukp7n1p0a3dbr3.jpg)

(This is Chrome dev-tool) 
1. Go to "Elements" => "Computed"
2. Check "Rendered Fonts"
Contribution to "Time It"
Published: 2021-10-16 02:37:32

# Overview
The project I contributed to is an ElectronJS app named "Time It". The owner of the project had a problem related to the sidebar. She wanted the sidebar to be toggled (on/off) instead of being static. I found this issue was interesting to me then I asked the owner to take a shot and she assigned it to me. 
Firstly, I came up with an idea to create a burger menu icon to toggle the sidebar. 
Before clicking the menu icon:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jt8x5ajh6kl8udsfumos.PNG)
After clicking the menu icon:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ktjk9tdtmg1d1o5quu7n.PNG)
I did some research about CSS animation and onClick function on React to make the change. Then I created a new branch named <code>burgerMenu</code> and started working on the issue.
Code explanation:
I created a burger menu component to create a burger menu icon
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e5v8g45qkhfsd2wxlnyo.PNG)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cm509tw4xaoze34odrij.PNG)
Then inside the Sidebar.js, I modified the class name of the Sidebar, so when the menu icon is clicked, the class name will add <code>active</code>. Sidebar only shows up when  <code>active</code> is in its class name.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0uj049v4m9qt3n34b2gp.PNG)
After some tests. I decided to send a Pull Request to the owner to merge my <code>burgerMenu</code> to her <code>main</code>. 

Interaction with project owner
For the first time, I faced some problems related to install the project. She helped me a lot in figuring the problem out. I was event added to her private discord group of this project. This made me feel happy since I felt like I was a part of the team. My project was still not merged because of some conflicts and corrections needed, but we still working on it.
# Links:
Issue: https://github.com/time-it-app/time-it-app/issues/3
Pull request: https://github.com/time-it-app/time-it-app/pull/7
Moving to Dev.To - how do I import my existing blog over?
Tags: devto, import, blogging
Published: 2021-10-16 01:57:54

I decided to get with the times a bit and move my old [blog](https://waiholiu.blogspot.com/) from Blogger to dev.to.

I looked at a few choices and it seems [dev.to](https://dev.to/) is the best choice because it's got markdown.

However, it does have that "designed by a dev" UX feel to it though and there are a couple of things it took a while to understand.

Thought I'd make my first post on the platform on how to get started.

#Migrating the content of your existing blog

The first thing I wanted to do was to move everything over. You do this by going to Settings -> Extensions -> Publishing to DEV Community from RSS

![Screenshot of RSS feed screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dljlr9et80zzqksaxov9.png)
 
Enter your RSS from your old blog in, click Fetch feed now and it'll basically retrieve everything and make them Draft posts

#Publishing your Draft posts

If you go to your dashboard, you'll see all of your existing posts from your old blog in Draft mode.

![Draft posts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9dq9cc2k6z2aw5gnu1an.png)

Now at this point, you must be thinking there should just be a button to publish a draft post. 

Nope! You actually need to open up each post and set the published flag to true

![Set published to true](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/doygas56ppao9qlae7od.png)
 
It's not hard once you figure out to do it, but yeah seems like a strange oversight. Plus I can't seem to figure out how to do this all at once - you have to do this for every post.

#Summary

Overall, Dev.to seems pretty cool and I think I'll enjoy blogging here. Obviously a whole lot better experience than Blogger but just a few things to remember getting started.
Represent pair data structure using functions.
Tags: sicp, javascript
Published: 2021-10-16 02:19:04

---
title: Represent pair data structure using functions.
published: true
description: Can we represent pairs in JavaScript by only using functions but not object and array.
tags: sicp, javascript
cover_image: https://media.istockphoto.com/photos/two-oval-white-pebbles-side-by-side-picture-id1187872531?k=20&m=1187872531&s=612x612&w=0&h=qxDjEDRD3cgdyspxhWKLb1l8HedppINdQ3JgyJwV3ks=
---
## Pair
Pair is a data structure which is used to combine two values.
```
(1, 4)
("sreedhar", "pavan")
```

Javascript does not provide this data structure. So let us implement this.

## Represent pairs in JS 
Pairs can be represented using an `object` or an `array`

```js
//Represent pair using object
function pair(a,b){
    return {first: a, second: b};
}
function first(p){
    return p.first;
}
function second(p){
  return p.second;
}

//use the pair
const p = pair(12, 13)

const f = first(p)
console.log(f) // logs 12

const s = second(p)
console.log(s) // logs 13

```

```js
//Represent pair using array.
function pair(a, b) {
  return [a, b];
}
function first(p) {
  return p[0];
}
function second(p) {
  return p[1];
}

//use the pair
const p = pair(12, 13);

const f = first(p);
console.log(f); // logs 12

const s = second(p);
console.log(s); // logs 13
```

But is there a way to represent `pair` in terms of `functions` without using `object` or `array`?

Think for some time before you proceed.
.
.
.
Yes there is a way

## Represent pair using functions
Consider our pair function returns a function.

```js
function pair(a, b) {
  return (value) => (value === 0 ? a : b);
}
```
Now this returned function when called with `0` returns the first element and when called with `1` returns the second element.

so we can implement `first` and `second` functions as 

```js
function first(p) {
  return p(0);
}

function second(p) {
  return p(1);
}
```
Finally with these functions we can represent pair using functions.
```js
function pair(a, b) {
  return (value) => (value === 0 ? a : b);
}
function first(p) {
  return p(0);
}

function second(p) {
  return p(1);
}

//use the pair
const p = pair(12, 13);

const f = first(p);
console.log(f); // logs 12

const s = second(p);
console.log(s); // logs 13
```

##Conclusion
I would never implement pair using functions. But it was fun to realise that I can.
I found this in [a section](https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-14.html#%_sec_2.1.3) in SICP book.
Refactoring?!
Tags: refactorit, javascript, opensource, node
Published: 2021-10-16 02:03:26

My Github project repo: [Repo](https://github.com/juuuuuuun/jun-ssg)
Commit: [Commit](https://github.com/juuuuuuun/jun-ssg/commit/10b5254e98ca6dbbfd4982dc671ec14487164821)

#Overview
In this time's lab, 5 purpose is for students to do refactoring themselves opensource project. When I saw this lab 5, actually I was being happy because honestly after 3 times working with my collaborators the API's code is getting un-efficient and long. It doesn't mean my classmate's work is useless it was enough helpful, but just need to remodeling :)

#What is changed..?
So, after reading this I quickly started to work for it. I separated 3part of to-do things for refactoring each refactoring are..

###added start function to handle promise error
I realized that the try and catch function has a promise error, so I changed it like this
```
async function start() {
	try {
		const { argv } = getParams();
		const {
			input: fileOrDirectory,
			output: outputDir,
			stylesheet: cssUrl,
			config: config,
			lang
		} = argv;
		if(!fileOrDirectory && !config) {
			throw new Error("Please include an input filename or folder");
		  }

		await convertFilesToHTML(fileOrDirectory, cssUrl, lang, outputDir, config);
	} catch (err) {
		console.error(err);
		console.log(chalk.red(err.message));
		process.exit(-1);
	}	
}

start();
```

###organized files
I separated some functions into another file.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/poimflzm0444sgot32jq.png)

###reduced duplicated part
`const convertToHTML` part was duplicated, so I divided them as `await getParamsData` and `await getFileData`
```
exports.convertFilesToHTML = async (filename, cssUrl, lang = "en", outputDir = "dist", config) => {
    const paramsData = await getParamsData(filename, cssUrl, lang = "en", outputDir, config);

    const fileInfos = await getFileData(paramsData.input);

    //function part for generating an index file to go to sample pages.
    await createIndex(paramsData, fileInfos);    
};
```

#Combine all commit to one..
After finishing all refactoring part(currently) I merged all of the commits to one commit from lab 5's instruction(used `squash`)
```
commit 10b5254e98ca6dbbfd4982dc671ec14487164821 (HEAD -> master, refactoring)
Author: jsong89 <jsong89@myseneca.ca>
Date:   Thu Oct 14 20:14:47 2021 -0400

    Refactoring ssg to improve code maintainability:
      * added start function to handle promise error
      * organized files
      * reduced duplicated part
```

#Conclusion
After this lab, I realized how much important that before we are going to commit something should not commit every each of the small things. It will make other developers confuse what is the point of the commit and distracting them because too many lists are there. So, I will not commit every moment will carefully committing the essential part.