teleren/devto huggingface dataset:
Excel Number Formats (Code Example)
Tags: csharp, codenewbie, programming, visualstudio
Published: 2022-02-14 06:43:57

---
canonical_url: https://ironsoftware.com/csharp/excel/examples/excel-number-formats
---

**C#:**
```
using System.Linq;
using IronXL;
 
//Open an existing WorkSheet
WorkBook workbook = WorkBook.Load("test.xls");
WorkSheet sheet = workbook.WorkSheets.First();
 
//We should set cell value and then specify the format to represent data
//The cell value will look like 12300%
sheet["a2"].First().Value = 123;
sheet["a2"].First().FormatString = "0.0%";
 
//The cell value will look like  123.0000
sheet["a2"].First().FormatString = "0.0000";
 
DateTime dateValue = new DateTime(2020, 1, 1, 12, 12, 12);
sheet["A3"].First().Value = dateValue;
 
//The cell value will look like 01.01.2020  12:12:12
sheet["A3"].First().FormatString = "MM/dd/yy h:mm:ss";
 
workbook.SaveAs("CsvToExcelConversion.xls");
```

**VB:**
```
Imports System.Linq
Imports IronXL
 
'Open an existing WorkSheet
Private workbook As WorkBook = WorkBook.Load("test.xls")
Private sheet As WorkSheet = workbook.WorkSheets.First()
 
'We should set cell value and then specify the format to represent data
'The cell value will look like 12300%
sheet("a2").First().Value = 123
sheet("a2").First().FormatString = "0.0%"
 
'The cell value will look like  123.0000
sheet("a2").First().FormatString = "0.0000"
 
Dim dateValue As New DateTime(2020, 1, 1, 12, 12, 12)
sheet("A3").First().Value = dateValue
 
'The cell value will look like 01.01.2020  12:12:12
sheet("A3").First().FormatString = "MM/dd/yy h:mm:ss"
 
workbook.SaveAs("CsvToExcelConversion.xls")
```

We can use `FormatString` to format the display value of any Excel `Cell` or `Range` in C# with IronXL.

Read more about Excel number formats at [https://www.ablebits.com/office-addins-blog/2016/07/07/custom-excel-number-format/](https://www.ablebits.com/office-addins-blog/2016/07/07/custom-excel-number-format/)

You can download a file project from this [link](https://ironsoftware.com/csharp/excel/downloads/excel-number-formats.zip).
Typescript - (ReadOnly)NotEmptyArray
Tags: typescript, javascript, webdev, help
Published: 2022-02-14 06:40:37

Arrays are already well described in typescript, but sometimes we need to be more strict with our types. For instance, we need to have a not empty array.
This type doesn't exist in the typescript definitions, but we can create it in this way.
```ts
type NotEmptyArray<T> = [T, ...T[]];
```
This type inherits all the characteristics of the array type and it adds another rule to it. This array must have at least one item.
It can be used thus
```ts
const array: NotEmptyArray<number> = [1];
```
If you try to use it without any elements, typescript gives you an error, and it says us that a NotEmptyArray must have at least one element.

![NotEmptyArray](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bfwofxpmp236luvv9c17.png)

But this type could create some problems. If you use the arrays' methods that remove elements, you could have errors, because the arrays could become empty. To avoid this issue, we can work with read-only arrays that can be defined thus.
```ts
type ReadOnlyNotEmptyArray<T> = Readonly<NotEmptyArray<T>>;
```
This type prevents all the arrays' mutations so we can work with arrays with confidence.

The last point that I want to let you is how to convert an Array to a NotEmptyArray. To do that we need to create a [type guard](https://dev.to/this-is-learning/typescript-tips-tricks-type-guard-50e5) function. This function can be done in this way.
```ts
function isNotEmptyArray<T>(as: T[]): as is NotEmptyArray<T> {
  return as.length > 0;
}
```
Therefore you can check if an array has at least an element and if it respects this rule it's a NotEmptyArray.

_I created a [GitHub Gist](https://gist.github.com/Puppo/bc5287d32dbfeeba9f14862654cece9d) with this code if you need it._

{% gist https://gist.github.com/Puppo/bc5287d32dbfeeba9f14862654cece9d %}

That's all, I hope it can be helpful in your daily work.

Bye Bye Guys 👋
ULN2003A vs ULN2803A？
Who is better?
Tags: electronics, product, semiconductor, beginners
Published: 2022-02-14 06:25:53

[ULN2803](https://www.utmel.com/components/uln2803a-array-8-npn-darlington-50v-18-dip-pinout-datasheet-and-uln2003a-vs-uln2803a?id=1245) and [ULN2003](https://www.utmel.com/components/uln2003a-semiconductor-500ma-16-dip-pinout-datasheet-and-uln2003a-vs-uln2803a?id=1244) are Darlington array ICs used to interface Logic circuits, such as microcontroller circuits, to high power devices. During the early days of your electronics tour, you may not understand the difference between these two ICs. This blog is to give you an idea about the major difference between these two ICs.

[ULN2003A](https://www.utmel.com/productdetail/stmicroelectronics-uln2003a-6269665) is a seven-channel Darlington array used to interface microcontrollers to high voltage, high current devices such as solenoids, lamps, relays, etc. It has the capacity to drive  500mA into a single channel, up to 250mA per channel if four of the seven channels are active and 125 mA per channel if all the seven channels are active. Its output has clamp diodes for transient suppression to protect the low-power microcontroller circuits.
The ULN2003 is the replacement for the ULN2803 when using the Prop-1 Trainer Board or when using P7 (Prop-1) or P15 (Prop-2 and Prop-SX) for serial communications with devices like the AP-8, DC-16, FC-4, and RC-4.

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

[ULN2803](https://www.utmel.com/productdetail/stmicroelectronics-uln2803a-6266710) is an eight-channel Darlington array used to interface microcontrollers to high voltage, high current devices such as solenoids, lamps, relays, etc. It has the capacity to drive  500mA into a single channel, up to 250mA per channel if four of the eight channels are active and 125 mA per channel if all the eight channels are active. Its output has clamp diodes for transient suppression to protect the low-power microcontroller circuits. ULN2803 is commonly used for controlling large seven-segment displays.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h1eutjjkogr55hvgt2x5.jpg)
Get the integers within a range (x, y) using recursion
Tags: javascript, algorithms, programming, recursion
Published: 2022-02-14 06:15:05

Problem Statement

```
Get the integers within a range (x, y) 

input: (2,9)
output: [3,4,5,6,7,8] 

var range = function(x, y) {
   // start here
};

```

Solution
```
var range = function (x, y) {
  if (y === x + 1) return [x];
  return [x].concat(range(x + 1, y));
};

```
Watch and Testing Cronjob using PHP
Tags: linux, php, webdev, tooling
Published: 2022-02-14 06:10:15

At one point, when I was suddenly stupid (often), I asked myself _"How can I see and test a cronjob?"_

![Google Results](https://i.imgur.com/64KPl6z.png)

Of course I will not open all the answers given by google, because as a lazy internet user like me it is impossible to see Google search results until the last page!

On the first page I found most of them give explanation about _"How to use cronjob"_ and _"How to see running cronjob"_ as well as _"How to view log of cronjob"_.

> But... what I need is to create it temporarily and not have to edit the cronjob template. How to do it?

![How do i do that?](https://media0.giphy.com/media/yaS1cezhrce2HS4h8h/giphy.gif?cid=ecf05e47rr9bzv99u6ez066ioxk5uospdu45s3qj4fl59cza&rid=giphy.gif&ct=g)

A few months ago I came across an interesting library on Github made by [walkor](https://github.com/walkor) called [crontab](https://github.com/walkor/crontab)

[Walkor](https://github.com/walkor) made it very easy, thanks a lot [walkor](https://github.com/walkor).

Let's try to make it more real, first we install the library via composer

```bash
composer require workerman/crontab
```

After installing the library, create a file in the folder that you used for testing during the development process.

```php
<?php
use Workerman\Worker;
require __DIR__ . '/../vendor/autoload.php';

use Workerman\Crontab\Crontab;
$worker = new Worker();

$worker->onWorkerStart = function () {
    // Execute the function in the first second of every minute.
    new Crontab('1 * * * * *', function(){
        echo date('Y-m-d H:i:s')."\n"; // your script here!!!
    });
};

Worker::runAll();
```

See what will happen in the terminal below

[![asciicast](https://asciinema.org/a/d5yZmUjDM50Q9m9GTu8Ek2wOx.svg)](https://asciinema.org/a/d5yZmUjDM50Q9m9GTu8Ek2wOx)

> With this library we can use cronjob expressions as usual.

Thanks to [walkor](https://github.com/walkor) 🥳
Check whether a number is in an array or not using recursion
Published: 2022-02-14 05:55:32

```
public class Check_Number {

	
	public static boolean checkNumber(int i , int find, int []arr) {
		
		if(i==arr.length) {
			return false;
		}
		else {
			if( arr[i] == find ) {
				
				return true;
				
			}
			else {
				
				return checkNumber(i+1,find,arr); 
				
			}
		}
		
	}
	
	public static void main(String ... args) {
	
		int [] arr = {1,2,3,4,5,6,7};
		System.out.println(checkNumber(0,10,arr));
		
	}
}
```
Cardinality In Database
Published: 2022-02-14 05:34:25

A source of confusion may be the use of the word in two different contexts - data modelling and database query optimization.

In data modelling terms, cardinality is how one table relates to another.


1-1 (one row in table A relates to one row in tableB)
1-Many (one row in table A relates to many rows in tableB)
Many-Many (Many rows in table A relate to many rows in tableB)


There are also optional participation conditions to the above (where a row in one table doesn't have to relate to the other table at all).



When talking about database query optimization, cardinality refers to the data in a column of a table, specifically how many unique values are in it. This statistic helps with planning queries and optimizing the execution plans.
Database: DDL, DML, DCL, TCL
Tags: sql, database, beginners
Published: 2022-02-14 05:25:57

![Gambar DDL, DML, DCL, TCL](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fexykijxsdy323uf501k.png)
 
Syntax database management berbasis SQL terbagi menjadi beberapa definisi yaitu: DDL, DML, DCL, TCL.
Berikut ini fungsi keempat definisi tersebut

## 1. DDL (Data Definition Language) :
Data Definition Language digunakan untuk membuat struktur database. 
Contoh syntax dari DDL: 
```
CREATE : to create objects in database
ALTER : alters the structure of database
DROP : delete objects from database
RENAME : rename an objects
```
Berikut ini adalah DDL yang membuat table bernama department: 
```
create table department
(dept_name  char(20),
  building   char(15),
  budget     numeric(12,2));
```

## 2. DML (Data Manipulation Language) :
Data Manipulation Language digunakan untuk memanipulasi data yang ada pada database
Contoh perintah DML:
```
SELECT: retrieve data from the database
INSERT: insert data into a table
UPDATE: update existing data within a table
DELETE: deletes all records from a table, space for the records remain
```

Contoh SQL query untuk menemukan nama semua instructors di dalam history department:
```
select instructor.name
 from instructor
 where instructor.dept_name = 'History';
```

 

## 3. TCL (Transaction Control Language) :'
Transaction Control Language digunakan untuk mengatur transaksi pada database. TCL nantinya digunakan untuk memanage perubahan pada DML. Dengan kata lain, TCL digunakan bersamaan dengan DML.

Contoh perintah TCL: 
 ```
COMMIT: Commit command is used to permanently save any transaction
            into the database.
ROLLBACK: This command restores the database to last committed state.
            It is also used with savepoint command to jump to a savepoint
            in a transaction.
SAVEPOINT: Savepoint command is used to temporarily save a transaction so
            that you can rollback to that point whenever necessary.
 ```

## DCL (Data Control Language) :
Data Control Language adalah syntax yang digunakan untuk memanajemen akses pada database.

Contoh perintah DCL : 
 
```
GRANT: allow specified users to perform specified tasks.
REVOKE: cancel previously granted or denied permissions.
The operations for which privileges may be granted to or revoked from a user or role apply to both the Data definition language (DDL) and the Data manipulation language (DML), and may include CONNECT, SELECT, INSERT, UPDATE, DELETE, EXECUTE and USAGE. 
```
Upgrade Debian to Parrot
Tags: tutorial, linux, beginners, cybersecurity
Published: 2022-02-14 05:22:03

## Tutorial Convert Your Debian Into Parrot Security OS Pentesting.

**Do you want to turn your debian into a distro that is widely used by cyber security experts?**

then it's time to change your old impression with debian into something interesting to use.

**So what exactly is Parrot Security OS?**

**[Parrot Security](https://parrotsec.org/)** (Parrot OS, Parrot) is a Free and Open source GNU/Linux distribution based on Debian Testing designed for security experts, developers and privacy aware people.

It includes a full portable arsenal for IT security and digital forensics operations. It also includes everything you need to develop your own programs or protect your privacy while surfing the net.

## **How to upgrade?**

**there are several criteria to upgrade your debian to parrot security,**

```
1. You must be Root privileges or an Administrator
2. The Debian used is the bullseye version (or Latest)
3. Enough Storage Around 15 GB
```

**step to upgrade,**

```
git clone https://github.com/Urghyrex/parrotfromdebian ~/parrot
cd ~/parrot
chmod +x ./parrotfromdebian
sudo ./parrotfromdebian
```

**Available Options for upgrading**

1. Core Only (parrot repository only)
2. Headless Edition
3. Standard Edition
4. Full Edition
5. Home Edition
6. Embedded Edition

## Congratulations, you have successfully upgraded

_\#Salam_SatuData._

> **Follow Instructions** - Should be around 12GB and don't forget to do ``sudo apt update && sudo apt full-upgrade -y`` then reboot.
> Welcome to your Parrot Security OS Pentesting Machine!
> Written by [@ditohd](https://instagram.com/dito.hd)
Check if a number is even using recursion
Tags: javascript, programming, algorithms, recursion
Published: 2022-02-14 05:12:28

Problem statement

```
Check if a number is even.

input: 8
output: true

var isEven = function(n) {
   // start here
};
```

Solution:

```
var isEven = function (n) {
  if (n === 0) return true;
  else if (n === 1) return false;
  else {
    return isEven(n - 2);
  }
};
```
Setting Android Emulator in an AMD Powered Computer using Visual Studio 2022
Tags: xamarin, maui, vs2022, android
Published: 2022-02-14 05:09:33

If you are a xamarin mobile app developer and currently setting up android emulator on a windows 10 or windows 11 machine running on AMD Processor, then this article can help you to save some time and efforts while setting up the android emulator.

In a normal installation process we need to select tools for xamarin app development and install it. For launching the emulator create a project for android mobile app and go to 
**Tools->Android->Android Device Manager**
Click on New Button and Create a Google Pixel Device with latest android version and Click Start.

If you don't get any errors and the Emulator runs smoothly then congratulations you have made it else don't worry this article can help you with few workarounds to keep emulator up and running.

First step is to check if Windows Hypervisor Platform option is checked in the **Turn Windows Features on or off** screen in control panel.

![Enable Windows Hypervisor Platform](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/djt8g2eal3zrnb5wlnb9.png)

Now we need to enable Hardware acceleration for AMD Processor. Go to Android SDK Manager(Tools->Android->Android SDK Manager)
Click on Tools Tab and Extras Menu. Check Android Emulator Hypervisor Driver for AMD Processors(installer) and install it.

![Enable Hardware acceleration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eianuq4a3sqm0perb1gy.png)

Restart the System and Try to launch the Android Emulator it should start smoothly. But in case you did not get success keep exploring further and create another article describing the fix.

Happy Coding!
Fix Vue 3 "Failed to resolve component" warnings
Tags: vue
Published: 2022-02-14 05:03:46

I am experimenting with an interesting UI Tookit that I found for Vue by Microsoft : [https://docs.microsoft.com/en-us/fluent-ui/web-components/integrations/vue](https://docs.microsoft.com/en-us/fluent-ui/web-components/integrations/vue).

I started a stock Vue3 Project using the Getting started instructions.  I then followed the setup instructions for the Fluent UI components.  They worked right away.

Unfortunately, there was an annoying set of errors in the JS console like this:

**Failed to resolve component: fluent-button**

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

It took a ton of searching to find the solution.  I wound up having to tweak [vite.config.ts to be like this](https://github.com/aaronblondeau/cube-solver/commit/0ad32687e5ff0b222c76171bfc5e26914e517c4d#diff-6a3b01ba97829c9566ef2d8dc466ffcffb4bdac08706d3d6319e42e0aa6890dd) :

```
import { fileURLToPath, URL } from "url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    // Fixes warnings like : Failed to resolve component: fluent-button
    vue({
      template: {
        compilerOptions: {
          // treat all tags with a dash as custom elements
          isCustomElement: (tag) => tag.startsWith("fluent-"),
        },
      },
    }),
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
});
```

I also had a super annoying problem where every ".vue" import made VSCode angry:

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

The level of complexity in Vue has been making me more and more concerned lately.  **Why can't a brand new project work without errors?**

For this one I had to add a file called [shims-vue.d.ts](
https://github.com/aaronblondeau/cube-solver/commit/0ad32687e5ff0b222c76171bfc5e26914e517c4d#diff-b49c3ba01a8e9b82736bae15527e3fff1bf647f7946ada6b39e836cd1db65332):

```
declare module "*.vue";
```
How to Develop a mobile app in Android
Published: 2022-02-14 05:02:18

With the rise of smartphones, tablets, online commerce, and a host of industries such as healthcare, education, and financial services being disrupted by the advent of new technology, mobile applications are gaining popularity at an unprecedented rate.

Looking to hire android app developers with expertise in Android SDK, Android Studio, and material design? Developing Android applications requires a strong knowledge of programming and design.

**There are three main types of Developer:**

- **Native developers -** These developers build apps for a particular operating system (iOS, Android, and Windows). When building native apps, the coding language used is usually Java for Android, Swift for iOS, and .NET Framework for Windows.


- **Cross-platform developers -** These are developers who can build an app that runs on multiple operating systems. Some of the most popular cross-platform frameworks include Cordova/PhoneGap, Appcelerator Titanium, Xamarin, React Native, Ionic, and Sencha Touch.


- **Web-based application developers -** These are programmers who can build mobile apps using JavaScript and HTML5. By using these technologies, the app will be able to run on all types of devices including desktops and smart TVs. Hire a dedicated android developer for your app and uplift your business and growth.

I hope this post helps you in developing a mobile app on android.
Sum all numbers in an array containing nested arrays using recursion
Tags: algorithms, javascript, programming, recursion
Published: 2022-02-14 05:01:17

Problem statement
```
Sum all numbers in an array containing nested arrays.

input: [1,[2,3],[[4]],5]
output: 15

var arraySum = function(array) {
   // start here
};

```

Solution:
```

var arraySum = function (array) {
  let sum = 0;
  for (let i = 0; i < array.length; i++) {
    if (Array.isArray(array[i])) sum += arraySum(array[i]);
    else sum += array[i];
  }
  return sum;
};

```
Compute the sum of an array of integers using Recursion
Tags: algorithms, javascript, recursion, programming
Published: 2022-02-14 04:51:39

Problem statement: 
```
Compute the sum of an array of integers.
sum([1,2,3,4,5,6]); // 21

var sum = function(array) {
    // start here
};
```

solution:
```
var sum = function (array) {
  if (array.length === 1) return array[0];
  return array[0] + sum(array.slice(1));
};
```
Introduction to Modern Python
Tags: python, beginners
Published: 2022-02-14 04:34:56

Python is an interpreted, high-level language created by Guido van Rossum and released in 1991. It is one of the easier programming languages and can be used in various situations such as making web applications, data analysis etc.

## Insight
Before you begin the journey of learning python remember it is a new language and with new languages come new terminologies and new rules on how you use the language. Its similar to how one’s native language and the English language differ. Keep that in mind. Python is a relatively easy language to learn.

## PYTHON INTERPRETERS AND ANACONDA
First step is to decide how you are going to be writing your code, you can choose either a **<u>python interpreter</u>** with a text editor of your choice or **<u>anaconda</u>** with **<u>jupyter notebook</u>**. Personally I’ve found anaconda to be really helpful as it is easier to learn various functions independently and save them. 
For the interpreter you can use: https://www.python.org/downloads/release/python-380/
For anaconda use:https://www.anaconda.com/products/individual

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z1f5wqwf0kh9dno98x2m.jpg)
For text editor, (VS code) use: https://code.visualstudio.com/

## GIT AND GITHUB

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g7049uqkds81lb2mz34c.jpg)
Next important thing as an upcoming developer is knowing how to use git and github. These are essential tools in coding as it enables one to store the code remotely and access it at any time.
Repository
This where your code is stored online. Similar to how one may store a pdf file on google drive or one drive, git hub provides one with a place to put your code and allows for collaboration with other coders to make your program. 
Best video I found to learn was this: https://youtu.be/DVRQoVRzMIY.

## First code
All one needs to do is to create your first Hello, World is just type 'print("Hello, World")' and voila you will have made your first step  towards becoming a python developer.

```
print("Hello, World")
```
As you do this remember to check on PEP8 rules. This is where the python rules for writing the code are located and usually updated. It is great to keep up with it so as to not encounter syntax errors often. 

Happy coding!