teleren/devto huggingface dataset:
How To Call Other Contracts In Solidity
Tags: smartcontract, solidity, blockchain, ethereum
Published: 2022-04-25 14:32:15

This blog post will show how to call the functions of a smart contract from another smart contract. Assuming we have two smart contracts defined below:

```js
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;

contract CallContractOne {
  function setValueX() {

  }

}

contract ContractOne {
  uint public x;
 
 function setX() external {
  //we will want to set the value of x from CallContractOne
 }
  
}

```
The first thing to know is, we need to mark the visibility of any function we want to call from outside the contract as `external` .

To call the smart contract `ContractOne` from the smart contract `CallContractOne`. We can decided to initialize the contract we want to call. Let see how this is done :

```js
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;

contract CallContractOne {
  
function setValueXByInitializing( address _contractOneAddress, uint _x ) public {
     ContractOne(_contractOneAddress).setX(_x);
  }

function setValueXByType(ContractOne _contract, uint _x ) public {
     _contract.setX(_x);
  }

function setValueXByPassingValue(ContractOne _contract, uint _x ) public payable {
     _contract.setXAndReceiveEther{value: msg.value }(_x);
  }
}

contract ContractOne {
  uint public x;
  uint public value;
 
 function setX(uint _x ) external {
  //we will want to set the value of x from CallContractOne
  x = _x;
 }

function setXAndReceiveEther(uint _x ) external payable {
  //we will want to set the value of x from CallContractOne
   x = _x;
   value = msg.value;
 }
  
}

```
Looking at the function above `setValueXByInitializing` we used the address that `ContractOne` is deployed to initialize the contract. Once we have initialize `ContractOne`, we can then call the external methods defined on it.

Another way we can also call external function of another contract is by using the contract we want to call as a type. Take a look at the function above `setValueXByType`. We are passing `ContractOne` as a type. This is the address in which `ContractOne` is deployed.

## Passing value to an external contract call
We can pass ether when we call an external contract. Take a look at the function `setValueXByPassingValue`. This function calls the function `setXAndReceiveEther` inside `ContractOne` and forwards ether to it. 

You can copy the code and try out on Remix. Deploy both of the contracts and copy the address of `ContractOne` to use inside the smart contract `CallContractOne`. 

Thanks for reading.
Umbraco 10 - Azure Cache for Redis
Tags: umbraco, dotnet, azure, redis
Published: 2022-04-25 14:28:51

I've recently needed to use Azure Cache for Redis on an Umbraco  9 website for user sessions to store information.  

After some research, I went with the following approach: 


##  Install Nuget Package
Install the following nuget package from Microsoft: 

```
Install-Package Microsoft.Extensions.Caching.StackExchangeRedis
```

## Create an "AzureCacheConfig" Model 

Create a configuration model, so I can bind to my appsettings section:

```csharp
public class AzureCacheConfig
{
    public string ConnectionString { get; set; } 
    public string InstanceName {get; set; }
}
```

## Add settings into appsettings.json

Add the following into my appsettings.json and replace the ConnectionString value with my secret one from Azure:

```json 
"AzureCache": {
    "ConnectionString": "XXXX.redis.cache.windows.net:YYYY,password=ZZZZ,ssl=True,abortConnect=False",
    "InstanceName": "Session_"
  }
```

You can get your ConnectionString for "Azure Cache for Redis", within the [Azure Portal](https://portal.azure.com/). 

*example*: 
![Azure Cache For Redis Settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wtphkrm5nuimnn67sh9r.png)
 

## Add Redis to Startup.cs

Then within the **Startup.cs** file found in the root of the web project, add the following code under ConfigureServices method above the services.AddUmbraco() line:

```csharp
services.AddStackExchangeRedisCache(o =>
{
    AzureCacheConfig azureCacheConfig = new();
    _config.GetSection("AzureCache").Bind(azureCacheConfig);

    if (!string.IsNullOrWhiteSpace(azureCacheConfig.ConnectionString))
        o.Configuration = azureCacheConfig.ConnectionString;

    if (!string.IsNullOrWhiteSpace(azureCacheConfig.InstanceName))
        o.InstanceName = azureCacheConfig.InstanceName;
});
```

For the basic setup, that's it!

Restart your application and now Umbraco will be Redis for user sessions. 

This only works for IDistributedCache, which I believe Umbraco doesn't use for the backoffice. However user sessions will now be scalable through Redis, which is what's needed on a scalable frontend solution. 

A handy tool that I used to view my Redis cache keys to make sure it was working correct: [RedisInsight-v2](https://redis.com/blog/introducing-redisinsight-2/)

If you need any help, give me a shout on [twitter](https://twitter.com/garpunkal)
Want to be my mentor?
Tags: beginners, reactnative
Published: 2022-04-25 14:27:46

I'm a newly graduated boot camper who just landed my first developer job. I'm working on an App in React Native and I'm trying to understand other people's code. 

**I'm wondering if there is anyone out there who's interested in being my mentor?** 
What I'm looking for is a bit of guidance in React Native and some advice on how to structure React Native projects. If you have knowledge in Redux that would be great.
Can I be a 90's developer in 2022?
Tags: retro, gamedev, retrogames, challenge
Published: 2022-04-25 14:22:09

This morning I found this **Amiga 500+** in my uncle loft, my first thought was "Wow! I have to try it"

Since I was a child I ever a passion of computers (specially old!), videogames and development and I have a very creative mind (sometimes too much!!). Today don't have much time to spend on the amiga (I have to do some boring job stuff for tomorrow!) but an idea growth in my mind...

**Can be interesting develop a 90's videogame for the amiga in 2022? Maybe copy some videogame of this era. How about GTAV for amiga? Or maybe Farming simulator for amiga? Or Terraria maybe?**

I don't know the answer so I decided to write a post here, and ask you developers if it is a good idea! 

I don't know if it is interesting or maybe someone do that yet, please share your thought, maybe I can do a series of videos of this adventure, maybe there is someone 90's game developer that read this post and can share advise for this.

_It's a crazy idea maybe_, but **I like to learn somethings new**!
Paracetamol.js💊| #108: Explica este código JavaScript
Tags: javascript, beginners, spanish, webdev
Published: 2022-04-25 14:16:14

## **<center>Explica este código JavaScript</center>**
#### <center>**Dificultad:** <mark>Intermedio</mark></center>

```js
const set = new Set();
set.add(1);
set.add(8);
set.add("3");

console.log(set.has(8));
console.log(set.has(3));
```

A. `true`, `false`
B. `false`, `false`
C. `false`, `true`
D. `true`, `true`

Respuesta en el primer comentario.

---
CAPP - Realtime Chat App
Tags: appwritehack
Published: 2022-04-25 14:14:31

### Overview of My Submission

CAPP App is a web based realtime chat application. It has some features like realtime chat, add friend, search people, search chat, protected route, and login using google account.

This application is built using React.js for the frontend library, Boostrap for the CSS framework, Appwrite for data storage, authentication and realtime features and express.js for custom servers as needed.

The inspiration behind the making of this application is whatsapp so that it looks similar to whatsapp.

### Submission Category: 

Wacky Wildcards


### Link to Code

{% embed https://github.com/h8-exploration/capp-appwrite %}


### Additional Resources / Info

#### Screenshots

Login Page
![Login Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/687mdtbawmuaqm8n0nmq.png)

Home Page
![Home Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hp66fm99ppgrdaa71g4n.png)

Find People
![Find People](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sg8624g578nyjammu13d.png)

Chat Room
![Chat Room](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5d6xfzrslz5qc0i3wfi4.png)

#### Project Contributor
Ajat Darojat: https://github.com/ajatdarojat45
What can go wrong while negotiating with an agency?
Published: 2022-04-25 14:13:24

---
canonical_url: https://www.linkedin.com/pulse/what-can-go-wrong-while-negotiating-agency-sanjay-pandey/
---

Most of us have the habit of negotiating the initial price of the product or service and getting it at a cheaper price, which puts us on the winning side.

While negotiating, if you are getting everything at a dirt-cheap price, then there are high chances of your project getting compromised. An agency’s quotation is based on two components ( **Resource Cost** + **Profit Margins** ).

Process of Creating Quotations — Based on the initial discussions with the client, we choose the resources from our pool suiting best to the requirements. Combinations may comprise a **Project Manager** , **Product Designer** , **Tech Lead, Senior Developers, Mid-level Developers** and, in some cases, **Junior Developers** as well. Based on their engagement time Resource Cost is calculated. After this calculation, we add Profit Margins to this cost (which varies from agency to agency).

When we lower the cost (taking my [company’s](https://www.terasoltechnologies.com/) example), it’s from the **Profit Margin’s** part, not the **Resource Cost** because it may directly impact your project quality. And when an agency offers you an unbelievably discounted price, it compromises on the **Resource part** and that is where bad time starts for the future of your project.

![](https://cdn-images-1.medium.com/max/560/0*4Rh2SR77m5QT8IJj)

Below are a few complaints that we hear after choosing the wrong agency:-

1. “My application is crashing again and again”.
2. “It doesn’t look like the designs we agreed upon”.
3. “The agency is avoiding communication and making the same mistakes again and again”.
4. “The code quality is poor”.

And the list goes on…

### Common mistakes during a negotiation

1. Negotiating without domain knowledge.
2. Taking a competitive approach rather than collaborating. Don’t negotiate only to win, but rather to develop a relationship of trust.
3. Even after getting a quotation, constantly pushing the agency for a lower number based on other quotations without any logical reasoning.
4. Money isn’t everything, and the price isn’t the only thing that you can negotiate. You can leverage the deal with add-on benefits like maintenance services or branding etc.
5. Letting your emotions impact your judgement which keeps you away from making a rational decision.

Here I would like to emphasise on choosing a **tech partner** rather than choosing an **agency**. The right partner will understand your business goals and your client’s needs, which will significantly impact your business.

> Remember, smart negotiators, are those who always look for win-win solutions.
The Cloud Resume Challenge with React
Tags: aws, challenge, react, serverless
Published: 2022-04-25 14:05:48


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/24cjr79kjmmnzt6kotm8.PNG)
**tldr**: Completed the cloud resume challenge using a little bit of react. I really enjoyed the experience overall. Here is the finished website.

The experience can be fairly well split into the front end portion and the backend portion. In which you have the two stacks with the infrastructure associated with each, and there is a small connection between the two.

The first iteration I used HTML/CSS/JavaScript for the frontend portion, but upon further reading the book and seeing mention about making it my own I decided to use react afterwards completing the challenge. I am thankful that I didn’t have to design my resume from scratch, and instead used an existing LaTeX one that I had worked with a career advisor at university. Because of that, it was fairly straightforward to set up the outline and use CSS to get it to look right. I stored it on S3, and restricted/gave access using bucket policies.

The JavaScript was fairly straight forward. I decided to use the ipify api so that I could log who was accessing the resume, and potentially make a project using said data for geospatial visualization. The CORS portion was fairly straightforward, by far the hardest part of the front end application though. Just kept on bouncing back and forth from the frontend JavaScript to the backend API. Went ahead and created the CloudFront distribution as well.

I purchased a domain name, and used it for the CloudFront distribution. Steps 8 through 11 were kind of subsumed under 12(IaC). Once again fairly straight forward, except for the tests. I ended up testing the infrastructure to see if it was there and deployed appropriately. Finally, I slapped together two GitHub repos with some GitHub actions, and that was it.

I think the experience taught me quite a few things, especially with regards to hands-on application of concepts. For example, I thought I knew Route53 like the back of my hand conceptually, but the implementation using Route53 alongside the CloudFront distribution was the hardest part of the challenge for me.
Sealed secrets - backup, recovery, miscellaneous
Tags: kubernetes, addon, secret
Published: 2022-04-25 13:36:39

##### Recovering public key used by the controller
```bash
❯ kubeseal \
      --controller-name=ss-app-sealed-secrets \
      --controller-namespace=sealed-secrets \
      --fetch-cert > publickey.pem
```

##### Recovering the private key
```
❯ kubectl get secrets acme-keys -n sealed-secrets -o json | jq ".data | map_values(@base64d)"
{
  "tls.crt": "-----BEGIN CERTIFICATE-----\nMIIE3DCCAsQCCQCgdNszn/dUUTANBgkqhkiG9w0BAQsFADAwMRYwFA...\n-----END CERTIFICATE-----\n",
  "tls.key": "-----BEGIN PRIVATE KEY-----\nMIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQDAFYgUZStmW6Zo\n...\n-----END PRIVATE KEY-----\n"
}
```

##### Re-encrypting sealed-secret files when keys change (rotated)
```bash
❯ kubeseal --controller-name=ss-app-sealed-secrets --controller-namespace=sealed-secrets --re-encrypt -o yaml < ss.yaml  > new-ss.yaml
```

##### Useful annotations
- `sealedsecrets.bitnami.com/managed: "true"` to make a kubernetes secret be managed by Bitnami SS controller
- `sealedsecrets.bitnami.com/namespace-wide: "true"` to make the scope to `namespace-wide`
- `sealedsecrets.bitnami.com/cluster-wide: "true"` to make the scope to `cluster-wide`

##### FAQ
- https://github.com/bitnami-labs/sealed-secrets#faq
Day 17-19: Markdown Previewer
Tags: 100daysofcode, javascript, beginners, react
Published: 2022-04-25 13:31:08

*This post is about the Markdown Previewer project on FreeCodeCamp. This is how I started the project.*

## The essentials

I decided to not use Redux yet, because I only need to maintain one state inside the whole app. Redux would be such an overkill.

I got to use Prism.js and marked.js library for this project. Although I had to drop Prism.js cause it's not working and it's not necessary anyway unless if I need to implement syntax highlighting in a site.

This is a React site, with almost no static element. It is styled using SASS as a preprocesser for CSS.

## marked.js

`marked.js` is a very simple library to use. You can include the CDN link to get started:
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.2/marked.min.js" integrity="sha512-hzyXu3u+VDu/7vpPjRKFp9w33Idx7pWWNazPm+aCMRu26yZXFCby1gn1JxevVv3LDwnSbyKrvLo3JNdi4Qx1ww==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
```
To parse pure Markdown, use the `parse` method:
```js
let textBox = document.getElementById("text");
textBox.innerHTML = marked.parse("*This is italic*");
```
`marked.js` also offers a ton of options, and I'm going to talk about one here.

To treat line breaks in text as an actual line break, set the necessary options to `true` with `marked.setOptions()`:
```js
marked.setOptions({
  breaks: true,
  gfm: true
});
```
You can also pass them as the second argument when parsing Markdown text:
```js
let markdownText = "# This is a heading";
let mainDiv = document.getElementById("main-part");
mainDiv.innerHTML = marked.parse(markdownText, 
  {
    breaks: true,
    gfm: true
});
```
A big warning when using this library: you MUST implement a HTML filter before rendering them into the DOM. `marked.js` don't have a supported built-in, so it is recommended to use DOMPurify or other HTML filter.

You don't want an [XSS](https://owasp.org/www-community/attacks/xss/) on your site, do you?

## Afterwords

This project is not really that challenging, apart from visual design (and I'm bad at designs). The next challenge though would be a jump in complexity, so I need to work harder.

Anyway, have fun everyone!

Fullo me on [Github](http://github.com/Kemystra)!
Also on [Twitter](https://twitter.com/kemystra)!
Class vs Struct in Swift
Published: 2022-04-25 13:29:36

Class and struct are general-purpose of a template to defines bellow characteristics.
- Property
- Method/functions
- Initializers
- Protocol
- Extension

Class and struct looks similar except the keyword used to define.
eg:
```swift
struct A{
var name = "Ajith"
var age = 10
var run(){...}
}
```
```swift
class B {
var name = "Ajith"
var age = 10
var run(){...}
}
```
##What is common in both?
- Both has property,methods,Initializers,Protocol,Extension
- Provides Subscripts to access their values
- failable init can be used in both
- Properties and method in both are accessed using **.(dot)** syntax.

##Things Available Only in Class:
- deinit can be used only with class.
- Classes can inherit the characteristics of another class. Struct can’t inherit from other struct.
- Reference counting allows more than one references.
- Type of class instance can be checked at runtime.

##Things Available Only in Struct:
- Struct has default member wise initializer. For class we need to define explicitly.
- Struct have the benefit of mutation safety that behind its hood no other thing can mutate its value which may prone to many bugs that are hard to debug.

##Difference between struct and class:
- Class uses keyword "class" and Struct uses keyword "struct" .
- For modifying the self property in struct from a function you need to define mutating at the beginning of function. Class doesn’t required anything.
- **One of the most difference is value vs reference type.**
- If you create struct instance with let property, you can’t modify its properties. If you create a class instance with let property, you can modify its properties.

##Value vs reference types:

- Classes are reference type : which means reference to a location in the memory where class instance is stored.
- Struct and enumeration are value type: which means each reference has it’s own copy of data
- If you share/assign instance of class to different references, all these references will have a single shared data. That means any changes in that class instance will be available to every reference
- If you share/assign instance of struct to different references, every reference will creates its own memory to store the data. Any changes in struct in one reference will not affect in other reference.
- Memory allocation for both class and struct is different. Because of this difference, class and struct behaves differently while sharing its instances.

> **Value types are stored in stack memory and reference type are stored in heap memory.**
Quick look into the new Ceph Quincy release
Published: 2022-04-25 13:27:51

---
title: Quick look into the new Ceph Quincy release
published: true
description: We look at the new features in the Ceph Quincy release. Talk about changes and important improvements. Looking forward to starting using this on my clusters.
tags:
cover_image: https://i.ytimg.com/vi/C7HC4kRTNJk/maxresdefault.jpg
---

{% youtube C7HC4kRTNJk %}

We look at the new features in the Ceph Quincy release. Talk about changes and important improvements. Looking forward to starting using this on my clusters.
Mashroom Server v2 released
Published: 2022-04-25 13:24:02

Today, we've released the second major version of the Microfrontend Integration Platform _Mashroom Server_. 

With this version we've added hybrid rendering capabilities (support for SPAs/Microfrontends with server-side rendering) and performance and SEO optimisations. This makes the platform more suitable for websites. 

Check out the details here: https://medium.com/mashroom-server/mashroom-server-2-0-released-3b62d2e1011e
Starting to learn HTML and CSS all over again
Tags: html, css, php
Published: 2022-04-25 13:09:27

I have been studying and learning HTML and CSS for sometime now, but due to some family issues I run into, I was far away from coding, now I am back and I am learning all the basics again from zero. I hope I still have that coding spirit in me. this is the hardest things about coding is that you have to stay consistent and code everyday or else you will forget a ton of information.
瀏覽器連到VNC Server
Tags: websocketif, novnc
Published: 2022-04-25 13:05:40

- 訂閱patreon即可看到更多文章 https://www.patreon.com/wade3c
- Youtube頻道 https://www.youtube.com/c/增廣建文

---

noVNC實際上也是透過Websockify連線到VNC sever

![image.png](https://res.craft.do/user/full/71bea674-0503-893e-0a7a-91e236797ff9/doc/d1e81824-3b57-4b65-93c2-94b60a3c2efa/9afd3f12-7c80-4b75-bec0-872f234af563)

以前他們兩個是一起包在同一個GitHub repo下，後來分開維護了

但是安裝noVNC時還是會自動去裝Websockify

## Insatll

如果要自行手動安裝的話

```shell
apt-get install websockify
```

## Usage

以前websockify和noVNC還沒分家時的用法

```shell
websockify -D \
    --web /usr/share/novnc/ \
    6080 \
    localhost:5900
```

現在新版的noVNC會自己去call websockify

```shell
novnc --listen 6080 --vnc localhost:5901
```

## Nginx Proxy

加上reverse proxy可以讓我們直接call網址/ ip，而不用去指定6080 port

`nginx.conf`

```plaintext
user www-data;
daemon off;

events {
}

http {
  server {
    listen 80 default_server;
    
    location / {
      root /www/data;
      try_files $uri $uri/ /index.html;
    }
    
    location /novnc/ {
      proxy_pass http://127.0.0.1:6080/;
    }
    
    location /novnc/websockify {
      proxy_pass http://127.0.0.1:6080/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_set_header Host $host;
    }
  }
}
```

----

## Reference

[Websockify & noVNC behind an NGINX Proxy](https://datawookie.dev/blog/2021/08/websockify-novnc-behind-an-nginx-proxy/)