teleren/devto huggingface dataset:
Angular Alertifyjs Configuration
Tags: angular, alertifyjs, congfiguration
Published: 2022-09-20 07:50:13

### 1- install alertifyjs: 

`npm install alertifyjs --save`



### 2- Add to _style.css_:



`@import "../node_modules/alertifyjs/build/css/alertify.css";`
`@import "../node_modules/alertifyjs/build/css/themes/bootstrap.min.css";`
`@import "../node_modules/alertifyjs//build/css/themes/default.min.css";`




### 3- Create _alertifytype.d.ts_ file in src directory 
and add in the file:



`declare module 'alertifyjs';`




### 4- Add to _tsconfig.json_ file:

`"typeRoots": ["node_modules/@types","src/alertifytype.d.ts"],`

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


### 5- import alertifyjs to _componentName.component.ts_ file you want to use: 


`import * as alertifyjs from 'alertifyjs';`


### 6- show alertify message:

success:
`alertifyjs.success('message');`

or error:
`alertifyjs.error('message')`
Django with cloud sql auth proxy locally and in Cloud Run
Tags: python, django, googlecloud, devops
Published: 2022-09-20 07:40:12


Google's Cloud SQL Auth Proxy [3] allows you to set up a connection to a GCP SQL server from wherever you are via a secured tunnel. You can then point your application to a local address SQL proxy listens on and use it like local db. At least the DB "feel" like local. 

The same proxy is used in many GCP services like Google Cloud Run and GKE (if you configure it as a sidecar). 

Running SQL proxy is pretty easy (example is for pre 2.0.0 version):

`./cloud_sql_proxy -instances=my-gcp-project:europe-north1:mydbinstancename=tcp:127.0.0.1:20000`

Where

* `my-gcp-project:europe-north1:mydbinstancename` is the "connection" name of your managed SQL server. 
* tcp: directive tells the proxy where to listen locally

Now the trick is that when you run your proxy on your dev machine, or in a Docker compose for local development, you are fine with TCP. Yet, when you use Cloud Run, it expects you to connect to a UNIX socket, typically residing in this path: 

```bash
/cloudsql/my-gcp-project:europe-north1:mydbinstancename/.s.PGSQL.5432
```

This is pretty different than our TCP connection - would that mean we have to have a sepoarate Django config for local development and deployment? Not necessarily. 

If you look at a typical Django (postgres in this case) settings, you will notice it seems like it is expecting TCP connections. However, by convention when HOST starts with `/` the engine will treat it as a UNIX socket. One thing you need to remember is to set the PORT to empty value. 

```python
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.environ.get('DB_NAME', 'some db '),
        'USER': os.environ.get('DB_USER', 'my user'),
        'PASSWORD': os.environ.get('DB_PASS'),
        'HOST': os.environ.get('DB_HOST', '127.0.0.1'),
        'PORT': os.environ.get('DB_PORT', '20000'),
    },
}
```

In Cloud Run what you need to do is to set an enviromental variable DB_HOST to `/cloudsql/my-gcp-project:europe-north1:mydbinstancename`


This is it. Now locally you use SQL connection with TCP and with UNIX on Cloud Run. All just by changing env variables just as the Twelve Factor App [1] pattern teaches us to:) 


* [1] https://12factor.net 
* [2] https://cloud.google.com/sql/docs/postgres/connect-instance-cloud-run 
* [3] https://cloud.google.com/sql/docs/postgres/connect-admin-proxy#unix-sockets
Learning how to learn JS
Tags: codenewbie, javascript, beginners, productivity
Published: 2022-09-20 06:51:54

**Just a quick vent session after hitting my first(of many) wall with JavaScript**

Rewind two weeks ago, I started taking a highly rated js course on Udemy. This is my first programming language so everything covered has been 100% new information. Initially I was able to retain information, and logic quickly(see previous post) When a coding challenge came up I felt prepared. I knew what to do step by step without assistance. After solving the challenge, I was even able to expand on it, or find a more efficient way of doing it, etc.....

**until now**
Section 2 covering the basics was going pretty smooth, or so it seemed... It tackled basic function declarations, expressions & arrows, how to call a function within a function, arrays, objects, for/ while loops. I could still internalize and understand the lessons. I could practice the methods afterwards and get things to work. however, when facing my challenge at the end of the section I became humbled beyond expectation. I realized quickly that I could not do any of the things I had just "learned".

**I suppose there is a difference between learning and recalling**
When faced with so much information, its hard to decide when to move on, and when to double down on a concept. I think back on learning CSS and time wasted memorizing things that I can look up in 5 seconds. It also seems apparent that Professional developers are constantly looking things up.  It also seems to be true that people who are great at anything have a seep understanding of the fundamentals of what they do. That being said I'll probably just go back over anything in the lesson that I don't recall, hammer them down to the point of execution without assistance, and move on. It's just difficult because the desire to move on to the next thing is beckoning. 

**The best way to learn for me**
The moment I began rapidly learning CSS was when I began building things of my own with it. The relentless will to try over and over to make something work has been my most powerful learning tool. The rub with JS is lacking enough knowledge to really build anything. I have only spent brief periods in dreaded _tutorial hell_, only to resurface unscathed. Now walking a plank over the flames, the desire to move on to a phase when I can build is growing by the day. Tutorials don't bore me per se. However, there's just another level of excitement when bringing an idea from my brain into code, struggling, and the sweet reward of seeing it work in real time.
Maximum Number of Words Found in Sentences
Tags: node, javascript, leetcode, tutorial
Published: 2022-09-20 07:13:18


**Maximum Number of Words Found in Sentences**

A sentence is a list of words that are separated by a single space with no leading or trailing spaces.

You are given an array of strings sentences, where each sentences[i] represents a single sentence.

Return the maximum number of words that appear in a single sentence.

**Example 1:**
```

Input: sentences = ["alice and bob love leetcode", "i think so too", "this is great thanks very much"]
Output: 6
Explanation: 
- The first sentence, "alice and bob love leetcode", has 5 words in total.
- The second sentence, "i think so too", has 4 words in total.
- The third sentence, "this is great thanks very much", has 6 words in total.
Thus, the maximum number of words in a single sentence comes from the third sentence, which has 6 words.

```

**Example 2:**
```
Input: sentences = ["please wait", "continue to fight", "continue to win"]
Output: 3
Explanation: It is possible that multiple sentences contain the same number of words. 
In this example, the second and third sentences (underlined) have the same number of words.

```

**Constraints:**

- `1 <= sentences.length <= 100`.
- `1 <= sentences[i].length <= 100`
- `sentences[i]` consists only of lowercase English letters and 
`' '` only.
- `sentences[i]` does not have leading or trailing spaces.
- All the words in `sentences[i]` are separated by a single space.

The approach I have used here is the simplest, first I splice() it user forEach loop to fetch a sentence and spit it to count the words in it. Then compare it with temp.
If sentence length is greater than the temp then I keep swiping the value until the maximum word is found.

**The code is given below :**

```
var mostWordsFound = function(sentences) {
     const splitedArray = sentences.splice(',');
    let temp = 0;
    splitedArray.forEach((sentance, i) => {
        if(sentance.split(' ').length > temp){
              temp = sentance.split(' ').length;
        }
    });
    
    return temp;
};
```
**Time Complexity: O(n)**

**Space Complexity: O(1)**

**Following is my code runtime and memory usage**.

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





**Runtime And Memory Usage**

Hope this post is helpful. I share my knowledge and teach people about programming and we have more than 12k [@codewithyahi ](https://www.instagram.com/codewithyaji/)Instagram family.

Since you enjoyed reading my blog, why not buy me a coffee and support my work here!! [https://www.buymeacoffee.com/yajindra☕](https://www.buymeacoffee.com/yajindra)
What is KaiOS?
Tags: webdev, javascript, webapps, pwa
Published: 2022-09-20 06:44:22

<h2 id="heading-helloooo-folks">Helloooo folks 👋</h2>
<p>I hope you are doing well!  and this will be helpful for you.</p>
<p>Before moving forward, Tell me one thing when you hear <strong>KAIOS</strong> what is the first thing you remember in your mind, of course, <strong>iOS</strong> will click in your mind but there is no relation between KaiOS and IOS. </p>
<h2 id="heading-what-is-kaios">What is KaiOS</h2>
<p>KaiOS is forked from B2G OS (Boot to Gecko OS), an open-source community-driven fork of <a target="_blank" href="https://en.wikipedia.org/wiki/Firefox_OS">Firefox OS</a>, which was started in 2011 and discontinued by Mozilla in 2016</p>
<p>Basically, KaiOS is an Operating system - <strong>Kai  ( 开 )</strong> is a Chinese word that means OPEN, so it's an 
open-source mobile operating system, based on Linux, for keypad feature phones made with low-power hardware and low power consumption (and therefore longer battery life).</p>
<p>Today Kaios enables a new category of lite phones and other IoT devices that require limited memory</p>
<p>KaiOS supports modern connectivity technologies like 4G LTE E, VoLTE, GPS, and Wi-Fi. in low cost cheapest smart feature phone, and this feature makes KaiOS Different in the World of the mobile operating systems. </p>
<p>It runs web-based applications built with ( HTML5 ) HTML,CSS, and Javascript.</p>
<p><strong>KaiOS is written in HTML, CSS, JavaScript, C++.
</strong></p>
<p>The user interface of the KaiOS operating system is fully developed with HTML, CSS, and Javascript.</p>
<h3 id="heading-kaios-is-the-winner-of-red-dot-award-2021">KaiOS is the Winner of Red Dot Award 2021.</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1651822478740/oU_ZpcqH8.png" alt="RedDot_KaiOS_cover_img_website_05-1.png" /></p>
<h3 id="heading-learn-more-in-kaios">Learn more in KaiOS :</h3>
<ul>
<li><a target="_blank" href="https://www.kaiostech.com/">KaiOS</a></li>
<li><a target="_blank" href="https://en.m.wikipedia.org/wiki/KaiOS">Wikipedia</a></li>
<li><a target="_blank" href="https://gerda.tech/">Gereda OS Custom ROM v13 - KaiOS Jailbreak</a>  </li>
<li><a target="_blank" href="https://sites.google.com/view/bananahackers/home">Banana 🍌 Hackers a KaiOs Development Cummunity</a>  </li>
<li><a target="_blank" href="https://developer.kaiostech.com/docs/getting-started/env-setup/simulator/">Kaiosrt - KaiOS Development and Testing Environment</a>  </li>
<li><a target="_blank" href="https://blog.codersalman.me/series/kaios">My Article Series</a>  </li>
</ul>
<hr />

<p>Thank you for Reading this article,💚🙃 I hope this an helpful article for you ! </p>
<p>Stay tuned and follow me for the next article it will be on the KaiOS architecture 🦈🙃📱</p>
</br>
Laravel 8 Datatables Keeping Selected Page Number
Tags: laravel, datatable, jquery, php
Published: 2022-09-20 06:16:04

In this article, we will see laravel 8 datatables keeping selected page numbers after the callback. In the datatable page, the number is not saved when you reload the page. 

So, we need to keep or get the current page in datatable after the page reloads to save the state of datatable.

Enable or disable state saving. Datatables stores state information such as pagination position, display length, filtering, and sorting. 

When this initialization option is active and the end user reloads the page the table's state will be altered to match what they had previously set up.

So, we need these kinds of requirements like refresh datatable without refreshing page number in laravel 8, laravel 8 datatable refresh the current page, refresh the page without losing active pagination in datatable using jquery, how to refresh datatable without reloading the page in laravel 6/7/8.
Tired of code tests
Published: 2022-09-20 06:10:36

---
title: Tired of code tests
published: true
description: this might not be your standard complain post against code tests
---


This is my first post on Dev.to, I haven't been able to tie my coding work with my professional work, I've worked at a big telecom company in Japan for 10 years, so they own all of my code.

You'd think, having a title like "Tech Lead" or "Engineering lead" and making presentations, mentoring new employees who just joined with almost no knowledge would weigh in when looking for new jobs.

I always feel an like imposter everyday, but just this week,  we ran into a problem that seriously last year me made a backup, made a policy and documented it.

So, I don't know where I'm going with this, I have a new boss who only cares how many commits or pull requests, or code reviews I have. So, I want to change my job. But so many companies want to see if I can balance a btree(isn't that solved already?)  

And, I can't share my source code over the years, which is just basically cutting me off. 

Sorry My first and maybe only post here is ending sad and negative.

This industry, we work to solve problems but don't usually have a way to carry the proof we did anything, and then we're tested with random questions that almost never have any relation to our work.

sorry, not sorry, things need to change. (but I'm going to leetcode right now for an interview)
Create a Notes APP using ASP.NET Web API and Javascript
Tags: javascript, webdev, tutorial, api
Published: 2022-09-20 06:02:18

This is part 1 of the video series in which we will create a notes application using ASP.NET Web API as our backend and we will use Entity Framework to save our data to a SQL server database.

We will cover the CRUD operations in our app.

{% youtube 5nw6zmGkNvo%}


Here's the step by step operations as covered in the video:

1. Create a new ASP.NET Web API
2. Install Nuget packages for Entity Framework Core
3. Create Domain models for our Notes application
4. Create DbContext class
5. Create Connection String in Appsettings.Json
6. Inject the DbContext in the services collection
7. Run Entity framework migrations.
8. Create new controller
9. Create and test CRUD Operations
Getting my groove Back
Published: 2022-09-20 05:35:48

Finding my groove back to coding after a long break has been one of the toughest challenges I have faced in my tech journey. However, thanks to self-discipline and adopting positive habits. Gradually coming along & pulling myself together. 

Here is how I do it

       Planning for your day – You can not be a master of all. Planning helps you approach your tasks in succession. You achieve greatness when you allocate time and effort to accomplish the task you had a plan on achieving.
-         Work Out – When you exercise, your body releases chemicals called endorphins. Endorphins trigger a positive feeling in the body and elevate your morale to tackle your day bugs. Go crush it and if possible work out in the morning.
 
-         Set Realistic Goal – The landscape of web development is ever-changing. It is therefore important that you discern between learning new frameworks vs having strategic career goals, for example, Technical goals, job goals, or community goals.
 
-         Take breaks – It's very important to take breaks when coding. In my case, I can focus on a certain thing for about 30-40 minutes.
 
-         Meditate - Reflect on your coding journey. This is important in setting realistic goals and achievable targets. Remember this is your future, you have to see yourself in the future if the practices you are doing now will eventually get you to it.
 
-         Work on projects you are comfortable doing – Start that side project that you never did earlier, contribute to open-source projects or build that portfolio you never did, but start working with what you are okay with
Tools and Skills required for Product Management
Tags: product, management
Published: 2022-09-20 05:25:12

I am listing down some tools and skills I came across while in a search for Product Management roles over the years.

**Tools**
1. Jira
2. Trello
3. Any flow-chart tool? (Visio etc)
4. Any Design tool (Figma/Adobe XD)

**Skills**
1. Time Management
2. Ability to write technical documents
3. Basic Understanding of UX
4. Communication! Communication! Communication!
5. Prioritizing the right task

Feel free to suggest more tools/skills
5 Quick Steps Transpiling SCSS to CSS Using Node (with watch & minify mode)
Tags: scss, sass, node, npm
Published: 2022-09-20 04:21:12

I use vscode editor on Windows10

### 1. Install Node.js
First download node from the official website [nodejs.org](https://nodejs.org/en/), and install it.

### 2. Initialize NPM
Open vscode terminal. Run the command
`npm init`

Press enter to all the options(description, author, keyword etc.) one by one or put the information in every option(if you wish, but not mandatory). After that, package.json file will generate in your file structure.

![package.json file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4lsu93ltfixrdjoz9syy.jpg)

### 3. Install Sass 
Go to [npm website](https://www.npmjs.com/package/sass) to find sass package.

![npm sass package](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/beesanubckjvrgue8npa.jpg)
 
Execute the command on terminal
`npm install sass`

After that node_modules folder and package-lock.json file will be added the file structure.

![node_modules package-lock json file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5scg8uobc6cqc9aq4nxk.jpg)


### 4. Write sass Command 
Go to the package.json file. In the scripts section remove `"test": "echo \"Error: no test specified\" && exit 1"` and add the small script

```
"scripts": {
    "scss": "sass --watch sass/style.scss css/style.css"
},
```
After executing the script, it will generate style.css and style.css.map in the css folder.

![css folder](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/so5490i7vfd18w0bsaun.jpg)

* If you want to avoid style.css.map file, the script will be
```
"scripts": {
    "scss-no-source-map": "sass --watch --no-source-map sass/style.scss css/style.css"
},
```

* If you want to generate compressed css, then add the script
```
"scripts": {  
    "minify": "sass --watch sass/style.scss --style compressed css/style.min.css"
},
```

* Altogether
```
"scripts": {
    "scss": "sass --watch sass/style.scss css/style.css",
    "scss-no-source-map": "sass --watch --no-source-map sass/style.scss css/style.css",
    "minify": "sass --watch sass/style.scss --style compressed css/style.min.css",
    "minify-no-source-map": "sass --watch --no-source-map sass/style.scss --style compressed css/style.min.css"
},
```

### 5. Run the Script 
Execute the command on terminal to run the script

`npm run scss`
or
`npm run scss-no-source-map`
or
`npm run minify`
or
`npm run minify-no-source-map`


**_<u>Point to be Noted</u>_**
In html file, you must link with the css file generated in css folder.

![css link in html](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jf8gp2sq0tek8y189aob.jpg)

For more effectiveness, use [live server extension](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) on vscode.


HAPPY CODING!!!
718. Leetcode Solution in Cpp
Tags: cpp
Published: 2022-09-20 04:19:36

```
class Solution {
 public:
  int findLength(vector<int>& nums1, vector<int>& nums2) {
    const int m = nums1.size();
    const int n = nums2.size();
    int ans = 0;
    // dp[i][j] := max length of nums1[i:] and nums2[j:]
    vector<vector<int>> dp(m + 1, vector<int>(n + 1));

    for (int i = m - 1; i >= 0; --i)
      for (int j = n - 1; j >= 0; --j)
        if (nums1[i] == nums2[j]) {
          dp[i][j] = dp[i + 1][j + 1] + 1;
          ans = max(ans, dp[i][j]);
        }

    return ans;
  }
};

```
#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/maximum-length-of-repeated-subarray/
Java Constructors - [Java OOP #2]
Published: 2022-09-20 03:41:43

In the previous article of this Java OOP Series, I briefly mentioned how we can use a constructor to initialise objects. In this article, we will further discuss about the different types of constructors.

## Recap
A Constructor is a method that is used to initialise objects. It is called once whenever an object of a class is created.

+ Unlike Java methods, a constructor must have the same name as the class and it does not have a return type.

+ Take note that it is not necessary to write a constructor for a class as the Java compiler creates a default constructor if there isn't any in the class.

## Types of constructors
Java constructors can be categorised into no-argument constructors or parameterised constructors. The default constructor is a no-argument constructor.

+ **No-argument constructors**

A no-argument constructor is a constructor that does not have any parameters.

```java
class Student {
    // fields
    private String name;

    // constructor
    Student() {
        name = "Alice"; 
    }

    public static void main(String[] args) {
        // constructor is invoked while
        // creating an object of the Student class
        Student newStudent = new Student();
        System.out.println("The name is " + newStudent.name);
    }
}    
```

+ **Parameterised constructors**

Parameterised constructors are constructors that takes one or more parameters.
```java
class Student {
  String name;
  int age;
  
  Student(String name, int age) {
    this.name = name;
    this.age = age;
    System.out.println(name + " is " + age + " years old.");
  }

  public static void main(String[] args) {
    Student Student1 = new Student("Bob", 12);
    Student Student2 = new Student("Krystal", 14);
  }
}
```
The `this` keyword is used to avoid ambiguity because Java compiler cannot differentiate between the variable and parameter if they both have same names. `this` keyword will refer to the current object inside the constructor.

+ **Default constructors**

If we do not create any constructors, the Java compiler creates a default constructor during the execution of the program. It initialises any uninitialised instance variables with default values:

|Variable Type|Default Value|
|-------------|-------------|
|boolean|false|
|int<br>byte<br>short|0|
|float<br>double|0.0|
|char|\u0000|
|Reference types|null|

```java
class Example {

  int a;
  boolean b;

  public static void main(String[] args) {
    // call the constructor
    Example obj = new Example();

    System.out.println("Default Value:");
    System.out.println("a = " + obj.a);
    System.out.println("b = " + obj.b);
  }
}
```