teleren/devto huggingface dataset:
Understanding string memory allocation in JAVA ,why not to use "==" operator rather to use String.equals() function.
Published: 2021-11-20 18:36:16

In JAVA string can be allocated in two ways depending on how string is created. For example if string with String s1="cat"; JVM will put this string in string pool area. And if you again create String s2="cat"; so it will check that already a cat s1 exist with same value so it will not create another cat rather it will link the address of s1 to s2 in the string pool area, so for this condition only "==" operator works but it's not recommended to use.

But if you create another String s3=new String("cat"); it will get stored in the heap area and in this case if you will use "==" operator to compare s1 and s3 it will give wrong answer because s1 and s3 are stored in different parts of the memory so it will not be able to compare.

As "==" operator checks the value of LHS and RHS, as both are stored in different parts of memory so it will not be able to compare so it is recommended to use s1.equals(s3); function because it compares each characters in the string so it will give correct output in every case.
Can we add source code inside a Button?
Published: 2021-11-20 18:34:34

You can add source code inside a Button using a Repeater.

lets add source code to a button

<Button Text="Click Me" Command="{App.DoPointerCommand}"/>    <!--Add the following to the beginning of your button--> <StackPanel> <Button Content="Press Me!" Command="{App.DoPointerCommand}" /> </StackPanel> [[source:https://developer.microsoft.com/en-us/windows/uwp/controls]]<!--Add the following to the end of your button--> <Button Content="Press Me!" Command="{App.DoPointerCommand}" OnPointerLeave="{Binding ElementName=onPointerLeave}" /> 

Markup:

StackPanel-- Div for adding a Button using Upper and Lower StackPanel as a container

Command-- Command is used to execute a method from the code behind. In our case it is used with calling method from code behind.
Right click on Command Textbox and select command from drop down menu. In this case we have used a pointer command that repeats a code inside a StackPanel.

Information that I Got: https://www.automaticchina.com/
PHP Short Code for Downloading Images ???
Published: 2021-11-20 18:21:28

As the web grows, images have become one of the most important factors that fuel its expansion. In order to improve their websites and consolidate image sources, businesses have been turning to image short codes for download links.

Failing to deliver images in a timely fashion can negatively impact the popularity of your site. That is why copyright owners and bloggers have been working to find simple and effective ways of making sure images are delivered fast and easy. The use of image short codes for download links is considered one of the most popular solutions on the current web.

But how exactly do they work? What are the benefits that are associated with using these types of systems? If you want to know more about this subject, read on to learn more about the process involved.

Need to download from here: https://www.oemairpurifier.com/
Installing Ubuntu 20.04
Published: 2021-11-20 17:46:59

My Experience and guide to install Ubuntu

Take a back up files needed, this install will format the disk.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1hhd6kreeg1nomr54o0u.jpeg)

I have downloaded ubuntu Linux on my laptop.These are steps to install ubuntu .A pen drive or a Hard disk(optional) 
So, that download ubuntu desktops file system to Fat32 filesystem(Default).
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cz3gdchi5gcatgj8e2ar.jpeg)
Format the pen drive first , for this open Balena Etcher, where you will see options to add file/image and another option of Target which will automatically connect to your pen drive. In the option for file/image select Ubuntu file which you have downloaded. Then click Flash(It may take some time).
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uz4imzppnzua5d95qs5k.jpeg)
Now we have to allocate some space in the storage for Ubuntu. Search for  on your windows search tab. It will then open your Disk management window, over there at the bottom area you will see a  window as  which will have your disk space written, right click on that and click on Shrink Space. Here it will ask you to enter the amount of space you want to allocate to run Ubuntu(Note : more than 40GB will be enough). After giving the space click shrink.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/feq3vg1eq8w4tfs79aow.jpeg)
Search for on window search tab, there you will see an option for under Advance Startup, go and select the Restart now option. Make sure your pen drive is connected to your device during this time. While rebooting you will see an option of your pen drives name, click on it and then select on Ubuntu.

And that's it !!!! , You can simply install Ubuntu from here as per your requirements.
PHP or JavaScript Which One is better for Long Project?
Published: 2021-11-20 17:24:51

PHP and JavaScript are two languages that can be used to develop web pages, but it's hard to say which one is better. If you're asking yourself this question, there are several things you'll want to consider before making your decision.

This Question will take a look at these two popular languages and see how they stack up against each other. It'll also mention some of the advantages and disadvantages each language has, as well as give recommendations for which one might be best for certain types of projects.
Read Reviews: https://www.automatedfl.com/
Why meaningful names are important?
Tags: programming, cleancode, beginners
Published: 2021-11-20 17:21:06

## Introduction

We name everything in code from directories and files to functions, arguments, and variables. Choosing good names takes more time and saves more than it takes. A name should answer all the questions that may pop up to the next coder.

## Why does it matter?

We often excuse the subtle name with code comments. If a name requires a comment, it does not reveal the intent. Why should we give it a name when it does not solve the very reason it was considered?

We go for a short names for simplicity-sake and without our knowledge, it makes a lot of assumptions about the reader to understand the same thing we do from the short name. When the assumptions are wrong, it will only arise more questions.

## 10 reasons why meaningful names are important

1. Noise words like Info and Data are not helpful without distinction for names
2. Pronounceable names are easy to read and search by humans.
3. With larger scope, single letter or small names do not help much but make the job even harder defeating the purpose of using them.
4. Generalisations only add disinformation if not true. For example, using List when it's actually not a list or using similar names would only confuse the programmer and considered disinformation.
5. Humours and culture-oriented slangs do not mean the same everywhere. Do not use them.
6. Problem domains are not completely understandable by the programmers. Use solution domain for names in the program. Problem domain names can be a last option as documentation or domain experts would be able to help. Do not use names from neither domains.
7. Adding context to the names would look expanding the code. But, it will be found necessary reading the code after months by other teammates who has to take over the project or even by the same author.
8. Clarity is king. Be creative to share enough context and still deliver clarity.
9. Additional encoding adds extra burden to understand the code. For example, p_address for permanent address data. Do not use unnecessary encodings and go for meaningful complete names instead.
10. Picking different names for the same concept confuses to understand the distinction or similarity. Pick one work per concept. For example, settle on one name among get, fetch, retrieve and one among manager, controller, handler, and driver.

Happy coding! 🙂
How to implement OAuth Login (Single Sign-on) using Google & Java(Spring Boot) — Part 2
Tags: java, programming, webdev, beginners
Published: 2021-11-20 17:12:47


## OAuth2 Google


Hello All, Its **Rohan Kadam**

In previous part 1, we looked into how to create projects and keys and credentials. Let us look into code for implementing OAuth Login in Spring boot

![Google OAuth using Java and Spring Boot -Part 2](https://cdn-images-1.medium.com/max/6000/1*-fPd6eIt5crPO4nN49mkWQ.jpeg)

Follow the below article for Google Configuration.
[**How to implement OAuth2 Login Using Google — Part 1**](https://medium.com/@rohankadam965/how-to-implement-oauth2-login-using-google-part-1-d57f9563b6b9)

### **Step 1**:- Create a Spring Boot Project using Spring initializer.
[**Spring Initializr**](https://start.spring.io/)

### **Step 2:-** Add the following dependencies in your project pom.xml

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-oauth2-client</artifactId>
    </dependency>

### **Step 3:-** Create a Configuration File for implementing OAuth2.
{% gist https://gist.github.com/Rohan2596/b4252f70f0c76151ba8c049123a90739.js %}
### **Step 4:-** Create Application Yml which will consist of Google Configuration.
{% gist https://gist.github.com/Rohan2596/c3c1457a1ac1c5ac1ecc8075d8b06db0.js %}
### **Step 5:-** Create a Rest Controller which consists of two endpoints.
{% gist https://gist.github.com/Rohan2596/aa957c6d3c1691de37585a83be5b6c2c.js %}
**Note:-**

 1. Principal Object contains username, email and profile image depending on scope.

 2. If an **error** occurs regarding an incorrect **redirect Url** add the following URL [**https://localhost:8080/oauth2/callback/google](https://localhost:8080/oauth2/callback/google)**

![Thank You](https://cdn-images-1.medium.com/max/2800/1*f9TMjifJVReTlh93qJ845Q.png)
Orthopedic Doctors in NJ
Published: 2021-11-20 17:10:24

For years, patients have benefited from our specialization in orthopedic surgery services. Our professional and certified [Orthopedic doctors in NJ](https://www.femino-duceyorthopaedics.com/Our_Doctors.aspx) ensure that only the best solutions are provided so there is no pain associated with the surgery.
Java Under the Hood
Published: 2021-11-20 16:48:25

Java is a high-level programming language, it means that we don't need to know the internals of the language and how it works under the hood to be a Java developer. However, if you want to lead back-end projects, earn a higher salary, be respected and admired, you will need to learn what it takes to run a Java program. 

I have recorded a series of videos showing essential parts of Java that you need to know to call yourself a senior Java developer.

### Introduction

{% youtube lkhEiJrd6ys %}

### Java development environment

{% youtube Z6szYHeZr4s %}

### Packaging strategy 

{% youtube YlKtVc9XFzA %}
{% youtube Mc8Q3TrA4b0 %}
{% youtube i1PFG9T-AlM %}
{% youtube T5TAq1570D8 %}
{% youtube xr4ppFKSUgQ %}

### Process vs threads

{% youtube ZRIC5yV5TTw %}

### JVM Architecture

{% youtube bDwFVx5-puQ %}

### Memory management

{% youtube B2eoUjakIOc %}

### Garbage collection

{% youtube v6eYxgBdAq8 %}
How to reuse Angular Material Dialog with dynamic content
Tags: angular, javascript, typescript
Published: 2021-11-20 16:42:25

I have a Angular Material Dialog Component that takes Inputs and uses them in header and footer of modal. I want to pass some html elements in modal's body section from a component.

dashboard.component.html displays a 'show/hide columns' button.


**dashboard.component.html**
```html
<app-modal [title]="title" [btnText]="text'>
   <section #template>
    <mat-form-field appearance="outline" *ngIf="!showForm && viewParams.length > 0 && cn_hostname_index >= 0">
      <mat-label>Search Columns</mat-label>
      <input 
        matInput
        id="columnSearchTxt"
        placeholder="Search Columns"
        name="columnSearchTxt"
        [(ngModel)]="colSearch.title"
      />
      <button *ngIf="colSearch.title" (click)="colSearch.title = ''" mat-icon-button matSuffix (click)="searchHosts()" matTooltip="Filter on hostname">
        <mat-icon aria-hidden="false" aria-label="Clear">close</mat-icon>
      </button>
    </mat-form-field>
  
    <mat-slide-toggle
      *ngFor="let col of colDefs | filter: 'title':colSearch.title"
      color="primary"
      [name]="col.title"      
      [(ngModel)]="col.includeField"
      labelPosition= "before"
    >
      {{ col.title }}
    </mat-slide-toggle>
   </section>
</app-modal>
```

**modal.component.ts**
```js
import { Component, Inject, Input, TemplateRef, ViewChild } from '@angular/core';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';

export interface DialogData {
  title: string;
  text: string;
  template: TemplateRef<any>
}

@Component({
  selector: 'app-modal',
  template: `<button mat-raised-button (click)="openDialog()">{{ btnText }}</button>`,
  styleUrls: ['./modal.component.scss']
})
export class ModalComponent {

  @Input() btnText: string;
  @Input() id: string;
  @Input() modalTitle: string;
  @Input() okText: string;
  @Input() name: string;
  @ViewChild('template') template: TemplateRef<any>;

  constructor(public dialog: MatDialog) { }

  openDialog(): void {
    const dialogRef = this.dialog.open(ModalDialogComponent, {
      data: {
        id: this.id, 
        title: this.modalTitle, 
        text: this.okText, 
        name: this.name,
        template: this.template
      },
    });
  }

}

@Component({
  selector: 'modal-dialog',
  templateUrl: './modal-dialog.component.html',
})
export class ModalDialogComponent {
  constructor(
    public dialogRef: MatDialogRef<ModalDialogComponent>,
    @Inject(MAT_DIALOG_DATA) public data: DialogData,
  ) {}

  onNoClick(): void {
    this.dialogRef.close();
  }
}
```

**modal-dialog.component.html**
```html
<section>
    <div>
        <mat-icon (click)="onNoClick()" aria-hidden="false" aria-label="close icon">close</mat-icon>
    </div>
    <h1 mat-dialog-title>{{ data.title }}</h1>
    <div mat-dialog-content>
        <!-- Want to display html elements from app-modal -->
    </div>
    <div mat-dialog-actions>
        <button mat-button (click)="onNoClick()">{{ data.text ? data.text : 'Ok' }}</button>
    </div>
</section>
```
Github: Using multiple deploy keys
Tags: github, git
Published: 2021-11-20 16:21:22

**This tutorial will cover how to use multiple deploy keys with Github on a Linux/Mac system.**

## The first repository with deploy key
To use a repository with a deploy key first check if you have an id_rsa.pub file
```
ls -l ~/.ssh
```
if there is a key created you will see a result like this:
```
ls -l ~/.ssh/
total 40
-rw------- 1 jonasg domain^users  2610 nov 20 10:26 ceep_rsa
-rw-r--r-- 1 jonasg domain^users   580 nov 20 10:26 ceep_rsa.pub
-rw-r--r-- 1 jonasg domain^users   117 nov 20 10:27 config
-rw------- 1 jonasg domain^users  3389 out  4 14:34 id_rsa
-rw-r--r-- 1 jonasg domain^users   752 out  4 14:34 id_rsa.pub
-rw-r--r-- 1 jonasg domain^users 11272 nov 19 09:42 known_hosts

```
In the example above I have 2 different keys, one id_rsa, and another ceep_rsa. Each key is composed of a rsa file and a rsa_pub file.

For creating or first "deploy key" we will use the id_rsa.pub file. Copy the content of the command:
```
cat ~/.ssh/id_rsa.pub
```

And on your Github repository, access Settings / Deploy keys / Add deploy key. Past the key on the Key field, give it a name in the field Title, and check the permission to write to be able to push to this repository.


![Image of the deploy key section on Github.com](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtge1vtmadhk3xpksfxl.png)
 
## Adding a second deploy key

Create a new ssh key:
```
ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jonasg/.ssh/id_rsa): /home/jonasg/.ssh/second_rsa
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
```

This will create a new pair of files named second_rsa and second_rsa.pub. Copy the second_rsa.pub content and paste it on Github Deploy key of the second repository on Settings / Deploy keys / Add deploy key.

Now it will be necessary to create a config file for our keys:

```
vi ~/.ssh/config
```

And add the configuration below:

```
Host repositoryOne.github.com
  HostName github.com
  User git
  IdentityFile /home/jonasg/.ssh/id_rsa
  IdentitiesOnly yes

Host repositoryTwo.github.com
  HostName github.com
  User git
  IdentityFile /home/jonasg/.ssh/second_rsa
  IdentitiesOnly yes
```

And on local git repository:

```
vi "local_repository"/.git/config
```
Change the value of URL replacing only the repositoryTwo part. The end result will be something like 'git@repositoryTwo.github.com:your-repository-path'

```
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = git@repositoryTwo.github.com:jonas-gerosa361-react/ceep.git
        fetch = +refs/heads/*:refs/remotes/origin/*
```

Now you will be able to push to both repositories without passing user and password. For adding more repository just follow the same proccess for them.

Have fun :)
DPS909 - Lab 9
Published: 2021-11-20 16:19:47


# Introduction
For this week in DPS909 our lab challenged us to implement continuous integration into our static site generators. To accomplish this, we would use Github Actions, which is going to allow us to automate workflows in response to events that occur in my static site generator Github Repo.

## Setup
The setup part of GitHub Actions was rather simple, all we had to do was follow [these](https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python) steps. Since my project is developed in python, I ensured to use pytest as my testing platform, since my project already has test code written in pytest. Doing so would make it very easy to implement GitHub Actions into my repository.

## The work
So now that GitHub Actions was configured, I had to make a new test in a branch. Luckily I forgot to implement a test for one of my functions, so after a quick implementation, I committed my changes and pushed them to my Repository. 

Now after opening my [PR](https://github.com/roman-rezinkin/RomanStaticSG/pull/27), I was able to confirm that my continuous integration was operating as expected. So ensure that failures would be caught, I pushed a commit with a broken test, and on my PR I was able to see the failure.

The second part of the lab was to find a partner in our class, and test their continuous integration by implementing a new test case. I chose to work on [A-Rokay](https://github.com/a-rokay/static-site-generator)'s static site generator, as it was written in Python so it would be very easy to work on. Here is the [Pull Request](https://github.com/a-rokay/static-site-generator/pull/24) I made to test their continuous integration.

# Conclusion
Overall, I really enjoyed implementing continuous integration into my repository. Introducing this will ensure that very high quality code is being pushed to the `main` branch. I think almost every repository should have some sort of testing enabled that provides some coverage of the code base.
Four rules to maintain the motivation high working to your projects
Tags: watercooler, motivation
Published: 2021-11-20 16:17:13

[Resting](http://resting.owlcode.eu/) is the most long-lived side-project of mine.
I have been working on it since December 2017.

It's not easy to maintain the focus on the same project for such a long time: so many mermaids try to attract your attention in new wonderful projects 🧜‍♀️🧜‍♀️🧜‍♀️🧜‍♀️🧜‍♀️🧜‍♀️.

I think the main obstacle is to keep the motivation on the project.

These are four advises to maintain the motivation high.

## Schedule a daily window

Schedule a moment to work to your project every day. I don't think it's important to invest a big amount of time, but to preserve this moment ongoing.

I believe that even 15/30 minutes per day are enough and the results will be visible after some time.

## Discuss with a friend

It's important to have someone to speak with. It helps you to understand the evolution of the project.

If you haven't the lucky to speak to someone, think about enter in a focused online community like:

- [Indie Hackers](https://www.indiehackers.com/),
- LinkedIn [Side-projects](https://www.linkedin.com/groups/13568032/),
- subreddit [SideProject](https://www.reddit.com/r/SideProject/),

## Spread your project

Take the courage of speaking publicly about your project. You have to move the project from your head to the real world.

Public speaking about it makes your project real and creates good expectations about it.

## Take a short development iteration

Take a short development cycle of your project. This permits you to perceive the real progress of your project and to be more flexible about the future.
Your enthusiasm increases perceiving the effective progress of your project.

Don't be a perfectionist: it's better to release an idea of the feature and improve it in the next iterations.
How to create download button for CSV and PDF using Ruby on Rails
Tags: ruby, rails, csv, pdf
Published: 2021-11-20 16:01:12

### Hey Guys !
#### Let's cut to the chase, hands on code !

* First generate scaffold
```ssh
rails g scaffold Note title
```

* run db:migrate
```ssh
rails db:migrate
```

* now we are going to install the gem to generate PDF, we will use the gem 'prawn' and the 'prawn-table':
```ssh
bundle add prawn prawn-table
```

* now we're going to add the route and buttons for downloads nor csv and pdf format:
```ruby
# add route in file config/routes.rb
resources :notes
root 'notes#index'
post 'download/notes', to: 'notes#download'

# add method downlod in controller app/controllers/notes_controller.rb
def download
    respond_to do |format|
      format.csv { send_data Note.to_csv, filename: "notes-#{Date.today}.csv" }
      format.pdf { send_data Note.to_pdf, filename: "notes-#{Date.today}.pdf" }
    end
end

# adds concerns to the note model to export the data
class Note < ApplicationRecord
  include ExportCsv
  include ExportPdf
end

# now let's create the modules in app/models/concerns
# first export_csv.rb
# frozen_string_literal: true

# module ExportCSV
module ExportCsv
  extend ActiveSupport::Concern

  # module ClassMethods
  module ClassMethods
    def to_csv
      require 'csv'
      options = { col_sep: ';', encoding: 'utf-8' }
      headers = %i[id title]

      CSV.generate(headers: true, **options) do |csv|
        csv << headers

        all.each do |note|
          csv << [note.id, note.title]
        end
      end
    end
  end
end

# second export_pdf.rb
# frozen_string_literal: true

# module ExportPdf
module ExportPdf
  extend ActiveSupport::Concern

  # module ClassMethods
  module ClassMethods
    def to_pdf
      require 'prawn'
      require 'prawn/table'

      options = { position: :center, column_widths: [300, 300], width: 600 }

      header = %w[ID Title]
      data = all.map { |note| [note.id, note.title] }
      Prawn::Document.new do
        text 'All Notes', align: :center, size: 18, style: :bold
        table([header, *data], header: true, **options)
      end.render
    end
  end
end

# and finally add the links on the app/views/notes/index.html.erb page
<%= button_to "Download CSV", download_notes_path(request.params.merge(format: :csv)), data: {turbo: :false} %>
<%= button_to "Download PDF", download_notes_path(request.params.merge(format: :pdf)), data: {turbo: :false} %>


```

And that's it, we're done!

Github source: https://github.com/nemuba/import_export_file_rails