teleren/devto huggingface dataset:
合约开发学习
Published: 2022-10-08 04:11:47

## 基本流程

### 基础概念
区块链可以当成某种特殊的数据库，而智能合约本身就只是一个操作该数据库的代码。solidity第一眼看上去可能会觉得有点复杂，但其实非常简单。实际上，区块链不是用来存储和操作普通数据的，区块链是用来操作“价值”的，不需要非常复杂的操作，所以通常智能合约也不需要很长很复杂。

### 开发环境

- openzeppelin: https://www.openzeppelin.com/
- [Hardhat](https://hardhat.org/hardhat-runner/docs/getting-started): compile and run the smart contracts on a local development network
- Waffle: tooling for writing comprehensive smart contract tests
- Solcoverage: code coverage
- Prettier Plugin Solidity: code formatter
- Ethers: renowned Ethereum library and wallet implementation
- Web3: web3.js.

代码实例参考：
- 介绍：https://techblog.geekyants.com/integrating-the-web-frontend-with-smart-contracts
- 代码：https://github.com/GeekyAnts/sample-smart-contract-ethereum


## 合约实例

### 合约部署

### 合约升级
https://docs.openzeppelin.com/learn/upgrading-smart-contracts
change the contract code, while preserving the state, balance, and address.

限制：

- 需要使用特殊插件: `@openzeppelin/hardhat-upgrades`
- 需要使用特定合约模版：`ERC20Upgradeable.sol`:
-- https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/v3.3.0/contracts/token/ERC20/ERC20Upgradeable.sol


### 关键合约
Uniswap： core V2
Compound：governorAlpha
Pancake：MasterChef


## 应用与合约的交互

通过console进行交互，主要用于研发侧快速测试验证

```
npx hardhat console --network localhost
```
通过应用进行交互

通过javascript的前端进行交互，主要用于dapp实际对客
主要方式为`ethers.js`和`web3.js`两种，接口有些许区别：
https://dev.to/lparvinsmith/web3js-vs-ethersjs-a-comparison-of-web3-libraries-2ap5
https://blog.infura.io/post/ethereum-javascript-libraries-web3js-ethersjs-nov2021

数据上web3.js占优一些。
My second tiny game: Asteroid Shooter
Tags: gamedev, indie, gamemaker
Published: 2022-10-08 03:47:01

In my quest to learn and make games I love to build and play, I tried **GameMaker Studio 2.3** and made an Asteroid Shooter game.

GameMaker was fun to try; however, creating UI with GameMaker will take a lot of effort; also, structuring the GML script carelessly could cause quite some bugs later.

~~So, my next plan is to try **Godot 3.5**! I heard Godot 4.0-beta2 has been released; however, let's stick with version 3.5.~~

<u>Update</u>: after toying with Godot, I found that I wouldn't say I liked GDScript much, so I resumed learning with the **Unity** engine.

Anyway, here's the finished game: https://teefan.itch.io/teefans-asteroid-shooter-2

Some screenshots and a gameplay video:

Gameplay video:
{% embed https://www.youtube.com/watch?v=FwfV6N6O17g %}

Screenshots:
![Main menu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fyh3aiwd3axim60yxwh5.png)

![Gameplay shot 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w2ts8awhx7ytitylxe5k.png)

![Gameplay shot 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3yu4pvbrxur6gsjp5ou2.png)
Hacktoberfest week 1
Published: 2022-10-08 01:51:29

This year I'm participating in hacktober fest which is an event where developers are encouraged to make 4 pull requests in the month of October. My goal is to start small and end big with my pull requests.

# Finding an issue

This was the first time i was just looking for random issues. Surprisingly it took a lot of time and effort to find something that I could say would be a good startpoint. I wanted to do something that i felt like i was learning something or improving as a developer. This week i think i spent 4 hours looking for a Issue.

# My Pull Request

[Repo](https://github.com/mcruzdev/free-programming-ebooks)

[Issue](https://github.com/mcruzdev/free-programming-ebooks/issues/7)

[Pull Request](https://github.com/mcruzdev/free-programming-ebooks/pull/8)

[826f217](https://github.com/mcruzdev/free-programming-ebooks/commit/826f21789c574e797e1e6499b6cd117f7747c8ad)

This issue was about making a .scss file for a web application. The file isn't to complicated and was color variables. However i never made a .scss file before so i needed to look into the syntax. It wasn't a difficult first issue but I was struggling to find a good starting point something that wasn't to hard and something that i could start with. My next goal is to try to do a PR on a more populated Repository
Simple Load Balancer With NodeJS & Express JS
Tags: javascript, webdev, beginners, programming
Published: 2022-10-08 01:25:47

 _**With this code you can make a simple load balancer for your website**_

![Load Balancer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jt5lxw9zrqalo9t7w6kh.png)
OSD600 Blog #6 - Lab 4
Tags: opensource, javascript
Published: 2022-10-08 00:47:57

For our 4th lab, we were tasked with partnering up again, and modifying our partner's Static Site Generator project to be able to take "options" from a "configuration" JSON file, instead of having to type them up in the command line. 

This way, the user only has to specify the location of the configuration file, where they can store multiple options, instead of having to manually type the various options in the command line, which can be more prone to errors. 

Coding the logic for the configuration file wasn't too difficult, as it was similar to the logic I already had for file handling. 

But what I found interesting in this week's lab was the use of remotes and Git fetch. We used remotes this week to monitor our partner's progress on modifying our own project, and used fetch to update the remotes. This way we were able to test our partner's progress, without actually modifying our local repo at all. 

Overall, I feel as though I still need to review the concept of remotes/ git fetch as I work towards completing my hacktoberfest release. 

Relevant Links:

1. [Issue URL](https://github.com/gulyapulya/SSGulnur/issues/10)
2. [PR URL](https://github.com/gulyapulya/SSGulnur/pull/11)
3. [Merge Commit URL](https://github.com/gulyapulya/SSGulnur/commit/35ffbee59466f8e3802a876442510107ee610a7a)
What about off-grid programming?
Tags: programming, productivity, reliability, offgrid
Published: 2022-10-08 00:29:10

I find it difficult to deny the benefits of modern IDEs on software development. They've made it easier for us to write code, reducing cognitive load and automating boring tasks, sparing us precious time to be employed on more important activities.

What about NPM or crates.io? Sure they make our lives easier by allowing us to download the right dependencies on-the-fly, but what if we are cut off from the internet? It could be just a short blackout, a temporary problem caused by severe weather or some days spent on the wilderness (some of us would love coding there too). It could also be something worse, say a political crisis or even war. Anyway, whatever the cause is, are we ready to code without internet access?

I can't shake off my head the idea that being without internet is something of the past. It would seem that we walk towards an always connected world. Think Starlink.

On the other hand, what if Enterprise's computer fails? What do we do without our beloved tricorders and databases? Do we have to relearn how to suture by hand?

More than modern IDEs, the availability and possibility to exchange source code (and download it) from the Cloud made coding extremely easier and quicker.

But what if there is no cloud to download from anymore? What if we are cut off the internet? What if the infrastructure we depended upon is no more? 

Is it possible to prepare for such an occurrence? 

I finish this post by pointing you to [devdocs.io](https://devdocs.io). Among all these modern tools - IDEs, search engines, social media -, it made me think that even though we've grown a little too much dependent on modern day connectedness, it is still possible to live without Google or StackOverflow!

PS.: And yes, it is possible to create a local NPM server and I've heard of something similar for crates.io. That's one of my goals in the near future. =]
Possibly The Ultimate Technical Documentation Guide, maybe.
Tags: documentation, engineering, projectmanagement, management
Published: 2022-10-08 00:08:38

*### Note - starting to write articles so any feedback greatly appreciated.*

## Introduction
Managing technical documentation is Haaaard. **Everyone will write it but no one will maintain it**. Confluence, Readme, Gitbook, Read the Docs etc. etc. all serve a great purpose, however, if you really want the latest documentation for your systems and departments then let's dive right in!

> If you haven't got time to read then you can view the results [here](https://cribmove.github.io/mkdocs-example-demo/)

> Or, if you just want to source code with tutorial visit the [github repo](https://github.com/cribmove/mkdocs-example-demo)
  
   
---


## What is it?

docker + [Mkdocs](https://www.mkdocs.org/) + Mkdocs plugins + [draw.io](https://drawio-app.com/)+ [mermaid](https://mermaid-js.github.io/mermaid/#/) + [meta](https://www.npmjs.com/package/meta)

## Show me then

### Install the repository
```bash
git clone git@github.com:cribmove/mkdocs-example-demo.git
cd mkdocs-example.demo
cd docs
docker compose up -d
``` 
Visit [localhost:8124](http://localhost:8124)


## Ok, but what else?

### Multiple Repositories
By simply using a tool such as https://www.npmjs.com/package/meta you can pull many repositories into a central repository = great for observing multiple projects and *centralising* documentation. All you have to do is include the external repository's mkdocs.yaml as seen below:


```yaml
nav:
  - External Repository: '*include ./second-repo/mkdocs.yml'
``` 


### Draw io integration

By using the [VSCode draw.io extension](https://marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio), you can diagram in the code editor and view it in your MKdocs! 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3rb2yrxe2bjwdzish9zu.jpg)



### Mermaid Diagramming

If you have the appetite for it you can diagram in code by using [mermaid](https://mermaid-js.github.io/mermaid/#/) syntax. Although there is a learning curve, the benefits of diagramming next to your code outweighs the learning time. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7cu03wbf2lwo8m1ivq3g.jpg)



### Open api Integration

If you keep true to your api specification and definitions then you can publish your local definitions to your documentation (again useful for poly-repos and contracts).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kk05ne8qszklfbv5bhfy.jpg)



## Conclusion
Mkdocs isn't for everybody but it does satisfy developer requirements. The extensibility, git history and rapid access that Mkdocs gives you will truly make your Dev experience more enjoyable. Not only can you build quickly but you can also publish to Github pages, cloud-front and netlify with ease! 

Give it a go!
I hate vaporware
Tags: estimates, sales, marketing, vaporware
Published: 2022-10-26 14:29:11

---
title: I hate vaporware
published: true
cover_image: https://jhall.io/images/bn-vapor.jpg
date: 2022-10-08 00:00:00 UTC
tags: estimates,sales,marketing,vaporware
canonical_url: https://jhall.io/archive/2022/10/08/i-hate-vaporware/
---

One reason [I didn’t mention yesterday](https://jhall.io/archive/2022/10/07/predictability-is-overrated/) for deadlines in software development is marketing and sales pressure.

I saved this one for a separate post, because I think it deserves its own special attention.

As the argument typically goes, we need to know when features X, Y, and Z will be ready, so that we can promise them to potential clients who may go to a competitor if we don’t make such promises.

Far be it from me to tell every sales and marketing department how to run their business, but in my opinion, it’s just irresponsible to make such claims, and likely unethical (and depending on your industry/production, possibly even immoral).

I have no problem with roadmaps, and transparency with (potential) clients about the order in which we plan to address on their requested feature. But these should not be communicated as promised delivery dates.

Instead of “Feature Y will be released in Q3”, I prefer “We expect to begin working on Feature Y in Q2” or even better: “Feature Y is item two on our roadmap, so we expect to begin working on it in the next 3-6 months.”

And this isn’t just me expressing a preference for flexible roadmaps (although I certainly do prefer that). This is me expressing my belief that reality is such that making such promises cannot be done honestly. [Software development is inherently unpredictable](https://jhall.io/archive/2022/02/18/software-development-is-inherently-unpredictable/), so any promises that ignore this are at best naive, and at worst, dishonest.

This is why I hate vaporware.

As a general rule, I much prefer to sell the product I have, when I have it.

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Solidity Basics
Tags: solidity
Published: 2022-10-07 23:42:59

Let's start with a simple setup.

```
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

contract Fundraiser {
    string public name;

    constructor(string memory _name) {
        name = _name;
    }
}

```

Notice the constructor parameter is labeled `string memory`. What does it mean? Parameters containing **reference data types** such as arrays or strings have two choices.

1. `storage`
2. `memory`

These reference types must tell if they are pointing to persisted data (`storage`) or a local copy of that data (`memory`).

In most cases `memory` is the correct choice.

There is also `calldata` which we can get into later.

Solidity offers two different types for address: 

1. the address type and 
2. the address payable type. 

The distinction is that payable addresses can receive ether, and will have the transfer and send methods available.

```
const FundraiserContract = artifacts.require("Fundraiser");

contract("Fundraiser", accounts => {
    let fundraiser;
    const name = "My Fundraiser";
    const beneficiary = accounts[1];
    const owner = accounts[0];

    describe("initialization", () => {
        beforeEach(async () => {
            fundraiser = await FundraiserContract.new(name, beneficiary, owner);
        });

        it("gets the beneficiary name", async () => {
            const actualName = await fundraiser.name();
            assert.equal(actualName, name);
        });

        it("gets the beneficiary address", async () => {
            const actualBeneficiary = await fundraiser.beneficiary();
            assert.equal(actualBeneficiary, beneficiary);
        });

        it("gets the owner address", async () => {
            const actualOwner = await fundraiser.owner();
            assert.equal(actualOwner, owner);
        });
    });
});
```

```
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

contract Fundraiser {
    string public name;
    address payable public beneficiary;
    address public owner;

    constructor(
        string memory _name,
        address payable _beneficiary,
        address _owner
    ) {
        name = _name;
        beneficiary = _beneficiary;
        owner = _owner;
    }
}
```
First contribution to a project
Tags: opensource
Published: 2022-10-07 23:16:38

Hello!

# Overal 

It's been a great experience to make even a small change in a big project.

For the first issue, I had to replace the link that was leading to the wrong website. For me, the only struggling thing was that, I put a lot of time to understand the project structure, a lot of folders and subfolders, which is confusing at first glance, but as long as you spend some time, you will get used to it.

# Broken build

Yes, not a typo, even though I broke the build with my small-changes PR, which is again I'm sorry for, I enjoyed working on a big project and making little changes to some parts.

There is not much code to share, since the first [PR](https://github.com/Seneca-CDOT/telescope/pull/3678#event-7529810893) has little changes, but more to come !

The thing I was surprised about is how open everyone to new contributors. Project maintainers are very kind and helped me to resolve an issue I had.

# Strong knowledge of git is very important

What I realized is that, you need to know git well. The basics of git branches, remotes, rebase, pull is a must.

Let's keep up, there is more to come :)
How to add CSS to the website?
Tags: css
Published: 2022-10-07 23:10:45

If you want to add CSS to your [website](https://mandslawyers.com.au/), there are a few different ways that you can do it. One way is to edit the HTML code of your website directly. This is generally not recommended unless you are very comfortable with HTML and understand how it works. 

Another way to add CSS to your website is through a text editor like Notepad++. This is a more advanced method, and again, only recommended if you are comfortable with coding and understand how CSS works.
Safely Fetching Scoped Variables (while avoiding Scope Injection)
Tags: coldfusion, cfml
Published: 2022-10-07 23:03:14

I'm testing some ideas. I'm not sure if I'm on the right path or not, but thought I'd share.

I have some UDF & CFC libraries that we've built over the year and I have some checks to determine whether default application variables exist and use them to override default values.  In order to avoid possible "Scope Injection" & errors (when scopes don't exist), I thought I'd attempt to write a function that uses "safe navigation" to verify scope classname, verify key (in the struct keylist) and return the value (w/optional fallback).

I've included a simple example where `application.randomVarName_xxx` is injected into the `URL` & `FORM` scopes on a script that doesn't use an application CFC or CFM file. As a result, dumping the application value actually returns `url.application.randomVarName_xxx` instead of a non-existent application-scoped value.

Another example is the retrieval of a server variable with a default value (if it doesn't exist).

Here's a little bit of my post-CFSummit2022 discussion of this on Twitter. https://twitter.com/gamesover/status/1578154242031767553
- Yeah... I tend to use structKeyExists (or struct.keyExists("keyname")) when the key names are dynamic/random... but yeah, isdefined does reach out to all other scopes if it can't find it. Too bad there's no option to limit searching to within a specific scope. - Me
- Short term that would be an easy UDF to write and share on GitHub. Longer term that would be a nice upgrade to IsDefined() they could implement ala updates to StructNew() - Nolan

Here's the source code proof-of-concept.  Let me know your thoughts.

NOTE: I'd provide a direct link to [TryCF.com](https://www.trycf.com/), but I noticed that gists are permanently cached and never refresh.  If you want to test it there, please copy-and-paste the code.

https://gist.github.com/JamoCA/7e544f1488a703d868cecc2b7ae5c2ed

{% gist https://gist.github.com/JamoCA/7e544f1488a703d868cecc2b7ae5c2ed %}
Another week, another feature for SSG
Published: 2022-10-07 22:55:46

## Overview
Hi, this week I was working on the agg-SSG (https://github.com/anshul137/ag-ssg). It is written with the javascript and was pretty easy to install and use, since it has pretty good documentation. 

## Task
This week the task was to integrate the configuration feature. This feature allows user to run tool with certain json config, which stores different key-values such as output (that describes the output folder), input (that contains the input file/folder) and lang (that has the lang that will be used in html output).

## Implementation
The implementation wasn't difficult. I created the [issue](https://github.com/anshul137/ag-ssg/issues/10), made sure author is okay if I work on it and started making my solution. The repo's code was written in pretty good way so it wasn't difficult to add my functionality. When I was done I created the [PR](https://github.com/anshul137/ag-ssg/pull/11).

## Summary
Because of how well was written documentation and code itself it wasn't difficult to complete this task. I appriciate Anshul for letting me work on his repo and being responsive all the time.
Install nodejs on linux
Tags: linux, node, ubuntu
Published: 2022-10-07 22:52:11

every javascript developer need to use nodejs and npm. if you are using debian distribution, this post can make you happy for installation node js.

i see these example on google but everytime it doesnt work for me. with this way you can install every nodejs version even it doesnt exist on ubutu package manager.



### Step 1: 
```bash
sudo apt update
```
<br/>

### Step 2:
```bash
sudo apt install xz-utils
```
<br/>

### Step 3:
Download your nodejs

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ye7m1rge20267yfu2ooi.png)
<br/>



### Step 4: (Extract file from .tar.xz)
```bash
sudo tar -xvf name_of_file
```

<br/>

### Step 5: (copy extracted folder files to computer root folder)
```bash
sudo cp -r directory_name/{bin,include,lib,share} /usr/

#NOTE: Dont replace anything instead of {bin,include,...}
#NOTE: dicrectory_name is your nodejs extracted folder 
```
Dev Setup for Crypto and AI
Tags: solidity, ethereum
Published: 2022-10-07 22:49:23


## Create an EC-2 Instance for Devbox

* A t2.medium should be fine. It has 2 vCPU and 4 GB memory and costs 0.0464 USD per hour. That is roughly $35 per month. A little steep but worth it.

* For AMI, choose Deep Learning AMI GPU PyTorch 1.12.0 (Ubuntu 20.04) 20220913 (ami-08e2d37b6a0129927)


## Install NodeJS

Source: https://github.com/nodesource/distributions/blob/master/README.md#debinstall

```
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
```

Another option is to first install node version manager.
Source: https://github.com/nvm-sh/nvm
```
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
```

Check for LTS versions and install one of the latest ones.
```
nvm ls-remote
nvm install v16.17.1
nvm use v16.17.1
node -v > .nvmrc
nvm use
```

## Install Truffle

```
npm install -g truffle
truffle -v
```

## A simple project

```
mkdir fundraiser
cd fundraiser
truffle unbox react

Commands:

  Contracts: Compile:         cd truffle && truffle compile
  Contracts: Test:            cd truffle && truffle test
  Contracts: Migrate:         cd truffle && truffle migrate
  Dapp: Run dev server:       cd client && npm start
  Dapp: Test:                 cd client && npm test
  Dapp: Build for production: cd client && npm run build
```

## Remove existing files and create new ones

```
rm truffle/contracts/SimpleStorage.sol
rm truffle/migrations/1_deploy_simple_storage.js
rm -f truffle/test/*

touch truffle/contracts/Fundraiser.sol truffle/test/fundraiser_test.js
```

Create a basic smart contract and a basic test file.

```
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

contract Fundraiser {}
```

```
const FundraiserContract = artifacts.require("Fundraiser");

contract("Fundraiser", accounts => {
    let fundraiser;
    const name = "My Fundraiser";

    describe("initialization", () => {
        beforeEach(async () => {
            fundraiser = await FundraiserContract.new(name);
        });

        it("gets the beneficiary name", async () => {
            const actualName = await fundraiser.name();
            assert.equal(actualName, name);
        });
    });
});
```

This test will fail initially. One can fix the failing test with the following changes.

```
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

contract Fundraiser {
    string public name;

    constructor(string memory _name) {
        name = _name;
    }
}

```

At this point if you want to start a new project you may want to directly use this template: https://github.com/maddyonline/fundraiser. This template does above steps and leaves it at this stage.


If you clone the template, you can try running `truffle test` in truffle directory and you should be off to the races.