teleren/devto huggingface dataset:
Advantage of using const in Kotlin
Tags: kotlin, android
Published: 2022-09-22 11:54:58

---
title: Advantage of using const in Kotlin
published: true
description: In this blog, we are going to learn about the advantage of using const in Kotlin.
tags: kotlin, android
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pdkvqu9dzty8imc6ocea.png
canonical_url: https://amitshekhar.me/blog/const-in-kotlin
---

I am [**Amit Shekhar**](https://amitshekhar.me), a mentor helping developers in getting high-paying tech jobs.

In this blog, we are going to learn about the advantage of using `const` in Kotlin.

It is one of the commonly asked questions during the Android Interview.

**This article was originally published at [amitshekhar.me](https://amitshekhar.me/blog/const-in-kotlin).**

The best way to learn this is by taking an example.

Assume that we have a class `MyClass` in Kotlin.

```kotlin
class MyClass {

    companion object {
        const val FILE_EXTENSION = ".png"
        val fileName:String
            get() = "Img_" + System.currentTimeMillis() + FILE_EXTENSION
    }

}
```

Now, we need to decompile this code. For that, we will have to convert this Kotlin source file to a Java source file.

Steps to convert from Kotlin source file to Java source file and decompile in Android Studio:

- `Tools` > `Kotlin` > `Show Kotlin Bytecode`. You will get the bytecode of your Kotlin file.
- Now click on the `Decompile` button to get your Java code from the bytecode.

We will get the following:

```java
public final String getFileName() {
   return "Img_" + System.currentTimeMillis() + ".png";
}
```

Here, I have kept only the important lines of the code and removed other lines for brevity.

Here, we can see that the variable `FILE_EXTENSION` has been replaced by its value which is `.png`.

As the value has been inlined, there will be **no overhead to access that variable at runtime**. And hence, it will lead to a better performance of the application.

This is the advantage of using `const` in Kotlin.

That's it for now.

Thanks

[**Amit Shekhar**](https://amitshekhar.me)

You can connect with me on:

- [Twitter](https://twitter.com/amitiitbhu)
- [LinkedIn](https://www.linkedin.com/in/amit-shekhar-iitbhu)
- [GitHub](https://github.com/amitshekhariitbhu)
- [Facebook](https://www.facebook.com/amit.shekhar.iitbhu)
Delivering 100% of Webhooks
Tags: reliability, architecture, statemachine
Published: 2022-09-22 11:54:41

If something is important for your customers, you should fix it. Webhooks are one of the core features of Woovi, and even a single webhook failed causes frustration for our customers, and also reduce our trust. For this reason, we build a reliable system to ensure we always deliver at least once every webhook.

## Woovi

[Woovi](https://woovi.com/) is a Startup that enables shoppers to pay as they like. To make this possible, Woovi provides instant payment solutions for merchants to accept orders.
To provide real-time capability for our e-commerce plugins, we send webhooks when a new charge is paid. 

## What is a Webhook/Postback URL

A Webhook/Postback URL is an HTTP endpoint that receives a new request when a new event happens.

## Woovi Charge

A Woovi Charge represents a payment request. It requests a payment of a given amount from a merchant customer. Usually an e-commerce order has 1 charge to receive an instant payment.

## Building a reliable system
To build a more reliable system, we used a state machine in conjunction with a fallback cron job to ensure we always deliver any webhook at least once.

## State Machine to track Webhook Delivery

![Webhook State Machine](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ef0agu4sj5i9q2ggrsuz.png)

For every charge paid, we emit a `charge paid` event.
Then the `chargePaid` event processor will send a webhook for the e-commerce plugin.
We noticed that some webhooks failed, and we decide to use a state machine to keep track of webhook delivering.
The state machine has 4 status:
- PENDING - the webhook was not sent yet
- SUCCESS - the webhook was delivered with success
- FAILED - the webhook tried to deliver 7 times and the e-commerce plugin didn't return a success response
- NOT_APPLY - when the merchant do not have any Webhook setup  at Woovi.

## Fallback cron job
We also added a fallback cron job, that runs every 5 minutes to reprocess charges that did not deliver the webhook yet (PENDING state). Charges in PENDING state.
This fallback also solves the problem when Woovi system is having some problems.

## Conclusion
State machines are a great tool to make sure your system reaches the state that it was supposed to be. And fallback job can fix a wrong system state to a desired one.

------------------------------------------------------------
If you wanna work with us, we are [hiring!](https://gist.github.com/sibelius/fe9bb57a2a00672459fa616523507f73)
AWS Certification Dumps Real Exam
Published: 2022-09-22 11:43:46

[AWS Certification Braindump](https://braindumps4certification.com/amazon-exam-dumps/) It’s remarkable for informed AWS developers who want a brief evaluation for the AWS Certified Solutions Architect Associate Exam. EXAM REVIEW - AWS Certified Solutions Architect Associate Ranga is an AWS Certified Solutions Architect Associate, AWS Certified Developer Associate and AWS Certified Cloud…  That’s all [AWS Certification Dumps](https://braindumps4certification.com/amazon-exam-dumps/) about some of the outstanding mock tests and workout assessments to prepare for the AWS Certified Developer Associate exam with code DVA-C01. These workout questions will now not simplest test your expertise in a timed environment but moreover let you end up privy to your robust and inclined areas. 
Click Here More Info >>>>> https://braindumps4certification.com/amazon-exam-dumps/
Helpful Open Source Programs for Early Career Software Developers
Tags: opensource, career
Published: 2022-09-22 11:34:07

There are various reasons and benefits to contributing to open-source software. In this article, I will cover a few open source programs that are helpful for early career software developers who are looking to work on real-world projects and gain some experience while improving their skills. This list does not exhaust all the programs but the ones that I have been part of or come across. I would also like to point out that some of these programs are not only open to software developers but also designers, and technical writers among other professions in the tech industry, depending on the program. 

All the programs that are mentioned below are virtual and they provide stipends to the participants, as of the day that this article is written.

### [RubyMe Mentorship Program](https://rubyme.org/about.html)
In this program, early career Ruby developers work on open source projects and are paired with experienced Ruby developers for mentorship. The open source contribution ranges from development to documentation, security, etc. Both the mentee and mentor are compensated.

### [Outreachy Internship Program](https://www.outreachy.org/)
This is a virtual program that aims to promote diversity and inclusion in the tech industry. Individuals who are subject to systemic bias and impacted by underrepresentation in the industry are encouraged to apply. The interns work with open-source organizations and their contribution ranges from development, documentation, UI/UX design, and data science, among others. Application for the December 2022 - March 2023 intake is currently open and closes on Aug, 29th 2022 4pm UTC.

### [Google Summer of Code](https://summerofcode.withgoogle.com/)
The program aims to bring new contributors into the world of open-source software development. The participants work with open-source organizations during the period of the program. 

### [Contributhon by She Code Africa](https://shecodeafrica.org/programs/contributhon-1)
This is also a virtual program specific to African women in technology, where they work with open-source organizations. The program aims to create diversity and inclusion in the open-source ecosystem.

### [LFN Mentorship Program](https://wiki.lfnetworking.org/display/LN/LFN+Mentorship+Program)
This program provides an opportunity for early career developers to gain experience in open-source software development. The mentees are also paired with mentors throughout the program.

### Conclusion
The above programs provide an opportunity for early career developers to put their skills into practice and learn while working on real-world projects. They also provide mentors for the participants which is a huge plus. Hoping that this article will be of benefit to you or someone you know.

Happy coding!
Remove Element
Tags: javascript, algorithms, python
Published: 2022-09-22 11:33:04

Today is day 2 of the #I4G10DaysOfCodeChallenge and the challenge for today was to remove a specific element from an array or list.

I solved the challenge using python and JavaScript.
I used the inbuilt remove method for python and the inbuilt splice method for JavaScript.


![Image of the solution using Python3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kf2u64p3uege2od91lit.png)

I looped through each content of the array and did a check to know if the specific number was reached, if it was then it should be removed from the array.

The splice method of JavaScript can be used if you are aware of the value you wish to delete from an array. You must first determine the target item's index. Then, you start by removing one element while using the index as the start element. To avoid skipping the next member in the array when you wish to remove many elements, simply decrement the index variable.


![Image of the solution using JavaScript](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9wikst3eawkwh0o0lfo.png)

Thank you.
Discord's new "member since" feature
Published: 2022-09-22 11:28:45

Discord recently rolled out a new feature to their stable build. The way it works is however a bit strange in my opinion, and shouldn't be on the stable build already. Because of this, it has left users confused. It isn't completely obvious how to enable this feature for your own profile.

To enable this new feature publicly on your own Discord profile, one must go through a few steps. Continue reading to learn how to.

If you want to watch a video about the topic instead, watch this tutorial
{% youtube QCv5TVvu1P0 %}

## How to enable "member since" on your Discord profile

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9pvch0bcszq9s8x8bhum.png)
This is the section you will need to navigate into. Here, you are able to add connections to your Discord account. Examples of such are Spotify, Github & YouTube. Looking through this list, you won't be able to find any setting that looks like it'll toggle the "member since" feature on your profile.

What you need to do is to add a new connection. It doesn't matter which one it is. But what does matter is that it has to be displayed on your profile, and thus cannot be hidden.

I've selected YouTube and authorised Discord to view my YouTube channel. After this, my profile now looks like this.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oi5rd00slg6y8u58p02w.png)
Send Notifications Using Pure Javascript
Published: 2022-09-22 11:23:34

##  Requesting Permission to send notifications

We use **Notification.requestPermission** to ask the user if he/she wants to receive notifications from our website.


```

Notification.requestPermission(function() {
 if (Notification.permission === 'granted') {
 // user approved.
 // use of new Notification(...) syntax will now be successful
 } else if (Notification.permission === 'denied') {
 // user denied.
 } else { // Notification.permission === 'default'
 // user didn’t make a decision.
 // You can’t send notifications until they grant permission.
 }
});


``` 
Since Firefox 47 The *.requestPermission* method can also return a promise when handling the user's decision for granting permission

 
```
Notification.requestPermission().then(function(permission) {
 if (!('permission' in Notification)) {
 Notification.permission = permission;
 }
 // you got permission !
 }, function(rejection) {
 // handle rejection here.
 }
);
```
 

## Sending Notifications


After the user has approved a request for permission to send notifications, we can send a simple notification that
says *Hey *to the user:


```
new Notification('Hey', { body: 'Hello, world!', icon: 'url to an .ico image' });

``` 
This will send a notification like this:

> Hey
> Hello, world!

## Closing a notification

You can close a notification by using the *.close()* method.




```
let notification = new Notification(title, options);
// do some work, then close the notification
notification.close()

``` 
You can utilize the setTimeout function to auto-close the notification sometime in the future.

```
let notification = new Notification(title, options);
setTimeout(() => {
 notification.close()
}, 5000);

``` 
The above code will spawn a notification and close it after 5 seconds

## Notification events

The Notification API specifications support 2 events that can be fired by a Notification.

1. The click event.

This event will run when you click on the notification body (excluding the closing X and the Notifications
configuration button).

Example:
```
notification.onclick = function(event) {
 console.debug("you click me and this is my event object: ", event);
}
```
2. The error event

The notification will fire this event whenever something wrong will happen, like being unable to display

```
notification.onerror = function(event) {
 console.debug("There was an error: ", event);
}
```
Command to publish an app to TestFlight
Tags: flutter, mobile, ios
Published: 2022-09-22 11:13:56

At ente, we are building an [open-source](https://github.com/ente-io/frame) iOS app for backing up and sharing your photos and videos.

In the beginning, we used XCode to create an Archive and then painfully clicked 20 buttons to upload our build to TestFlight.

We then discovered an easy way to do the same from the command line with these steps:

1. Configure [Transporter](https://apps.apple.com/us/app/transporter/id1450874784).
2. Run `{command-to-build} && open -a "Transporter" {path-to-generated-ipa}`.
3. That's it!

![Party](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ulqb98cxcj7oaz0ia414.gif)

In our case, since we are using [Flutter](https://flutter.dev), the single line command to build and publish to TestFlight is:

```bash
flutter build ipa && open -a "Transporter" build/ios/ipa/*.ipa
```

---

Hope this will save you a few clicks! If you'd like to know more of our adventures with Flutter and AppStore, follow us on [Twitter](https://twitter.com/enteio), or come hang out on our lovely [Discord](https://ente.io/discord)!
How to transfer the Octopus Card from an Old iPhone to a new iPhone
Published: 2022-09-22 11:07:51

1. From your **OLD ** iPhone, open the `Wallet` App

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2iwlyezywrigvybucbok.jpeg)


2. Click the Octopus card and make it selected,
- Click the `...` button
- Click the `Card Details` button
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3uwnuwm7dwa8wnh7zie0.png)

- Scroll down to the bottom, and click `Remove Card` button
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxwnxasj4cdl1mva2okx.png)

3. On your **NEW** iPhone, open the `Wallet` App
- Click the "+" button

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1527ig26g2j50d11wkf4.png)

- Click the button `Previous cards`

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


- Follow the step-by-step instructions, done!
Simple JavaScript Number formatting Method
Tags: javascript, beginners, webdev, programming
Published: 2022-09-22 10:54:38

Every big social media sites format their numbers the same way like 93.1K followers 1M subscribers or 2.5B views, they do this because it’s much easier to design a UI with a compact number.

To format numbers like this you might think you need to write a function with a bunch of conditional logic or find a package on npm to do it for you. But actually you can do it natively in javascript with the intel or internationalization api it has excellent browser support.


![Compatibility](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/81hegyd4xf25z6yhow6c.png)

Create a number formatter that first takes the locale language (“en”) then an object with a bunch of options like notation compact which will round the number and replace the last digits with a K M B or T to easily giving you the social media style format

![Code Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3cn07ygrv859bmzje3tj.png)

There’s even experimental support for different rounding modes the bottom line is that if you’re ever formatting numbers on a website the internationalization api is likely the tool you’re looking for.

If you found this article useful make sure to follow me for more interesting small programming hacks.

Twitter Handle : [AmSorry](https://twitter.com/amsorry_offl)
Unique challenges for women in crypto
Tags: blockchain, womenintech, career
Published: 2022-09-22 10:47:30

Unique challenges: (let’s make this list, then let's make a list on how to combat them!)

**The trad tech shade / hatred thrown at crypto.**
This is tough to handle for anyone - but I’d posit it’s potentially even harder for women and minorities that may already feel like their voice is not heard or valued.


**Lack of a safe space and culture**
The crypto world has a lot of cryptobros (but also increasingly a lot of awesome women and minority supporters - after all this is the place we are trying to make things fairer - we are in a unique position to understand what it’s like to be marginalised.

**Lack of mentors**
I put this one down to people being utterly time poor with one million different things on their plate at any one time! How do we solve this?
#14G10DaysCodeChallenge(Day2: Remove Element)
Tags: javascript, programming, leetcode, challenge
Published: 2022-09-22 10:44:51

## **REMOVE OCCURRENES OF ELEMENT IN A GIVEN ARRAY**
 An array of nums and value was given to remove all instances of that value in-place, to return the new length. An instruction was given to allocate extra space for another array by modifying the input array in-place with 0(1) extra memory.
For example in input, nums = [4, 1, 2, 4] and val = 4;
 expected output: nums = [1,2].

**PROCEDURE**

-Create indicator variable starting at zero (0) to keep track.

- Iterate through every element in the array using the 'for loop'. If the current value is not equal 'val'; we set nums[indicator] to nums[i] and increment indicator.

For instance, in the given example above where we have the input, nums = [4, 1, 2, 4]. If we iterate through this, nums[0] = val, it is been skipped while we move to nums[1] which is not equal to 'val' making it to be qualified to what we want, it's been moved to the front because our indicator started with zero (0). Same is applicable to nums[2], it will also be shifted forward.

- Return indicator.
Data Security Platform: Explained
Tags: security, cybersecurity
Published: 2022-09-22 10:33:57


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

As the world increasingly moves online, the need for data security grows. Many businesses have taken steps to secure their data, but without a comprehensive platform, they are only as secure as their weakest link.

A Data Security Platform is a must-have for any business that wants to protect its data. It is a holistic solution that covers all aspects of data security, from infrastructure to applications.
In this guide, we will cover everything you need to know about Data Security Platforms, including how they work, their benefits, and how to choose the right one for your business.

## What is Data Security Platform?

A data security platform is a software or tool that helps organizations secure their data. It typically provides a set of tools and features that can be used to help businesses protect their data from unauthorized access, leaks, and other threats.

Data security platforms usually offer a variety of features, such as data encryption, activity monitoring, and user access control. Some platforms may also offer additional features, such as data loss prevention and incident response.

## What are the main elements of Data Security?

- Confidentiality
- Integrity
- Availability

## What is the importance of a Data Security Platform?

- Cyber attacks
- Protects your company’s reputation
- Automated attacks
- Avoid unnecessary expenses

## What are the benefits of the Data Security Platform?

- Enhanced data management
- Protects your business’s goodwill
- Better security
- Shields your business from external and internal threats

If you're looking for an in-depth guide then click below link to learn more...

https://www.newevol.io/resources/blog/data-security-platform/what-is-a-data-security-platform/
Welcome Haitian Qiqi to join the openGauss community
Published: 2022-09-22 07:30:14

Haitian Qiqi signed CLA (Contribution License Agreement, Contribution License Agreement) and officially joined the openGauss community.

Haitian Qiqi is committed to helping users optimize IT infrastructure, oriented by market-leading products and services, and accurately grasping the development trend of the industry. 
Big data platform, intelligent database operation and maintenance platform, database private cloud, IT infrastructure operation and maintenance and other product and service solutions are committed to ensuring the stability, efficiency and security of user IT systems, and ultimately enhancing the value of IT systems. Haitian Qiqi adheres to the corporate development approach of "listening to customers, respecting technology, and honoring the ecology", focusing on the subdivision of database infrastructure platforms, and continuing to evolve and develop.

Joining the openGauss community this time, Haitian Qiqi will use the openGauss high-performance, high-reliability, high-security, and easy-to-operate open source relational database management system to join forces to build and operate a nationally leading database infrastructure one-stop product/solution The solution/service is the strategic goal, serving tens of millions of corporate customers, gathering ecological partners, empowering the industry, and at the same time promoting the commercialization and promotion of openGauss.
Free Online Python Compiler and Interpreter
Tags: python, computerscience, webdev, programming
Published: 2022-09-22 10:28:16

In this tutorial, I am going to explain how to use the free online python compiler, and you will understand how the python interpreter works.

Let's get started

## An Overview
The [online python compiler](https://codedtag.com/python/free-online-python-compiler-interpreter/) is depending on virtual private server.

Fast and integrated with a live session on the VPS. They are trying to include some libraries and modules.

It is completely free and including many features to allow you trying your python code with the web browser.

The free online python compiler is designed by [CodedTag](https://codedtag.com) developers which are working on famous applications as freelancers on themeforest, upwork, and so many others.

Python is a high level language that written in C programming language. It designed to do web applications, desktop apps, machine learning, and som many else

In the following paragraph, I will explain how to use the online python compiler.

## How to use the online python compiler
It is so easy you have to write your python code in the left editor but make sure for the indentation rules.

Once you finish your code, you have to click on the “Run” button to see the results on the right preview screen.