teleren/devto huggingface dataset:
PHP isn't dead! Don't be afraid to use it and implement it in your projects...
Published: 2021-11-20 07:24:31

Ok. Let's get this straight. PHP is not dead. It's not going to die anytime soon. Why? PHP released a new version recently (actually just a few months ago). It exists in more than 80% of all websites. It’s also used actively by millions of developers. None of that will disappear out of thin air.


Despite the fact that many new languages flourish every year, I would not hesitate to say that PHP (besides JS) is one of the safest languages in the world in terms of jobs, and will securely guarantee an enormous job market around the world for much longer than 5 years. Here is why.

**PHP adopts new ideas slowly.** It may sound like a weird reason for a programming language to keep up with the contemporary development trends. In fact, what happens is only proven, polished and time-checked ideas find their way into PHP.

**PHP has low entry level.** This means that it is one of the easiest languages to start coding for newbies ever. Then, once it is adopted by newbies, it often turns out that this language is enough for a lot of people that do not need genius, complex, mathematical and scientific features. Result - they just keep using PHP.


**Big platforms and companies which use PHP make lots of money every day!** WordPress, for example, which is made in PHP, is a free framework, but WordPress.com is a commercial WordPress hosting and makes money out of it. Then, there are tens of others like it. Now multiply this business volume by the number of other big PHP projects, like shopping carts, CRMs, issue tracking systems, web analytics...


And one of the biggest reasons...
**Servers accessibility.** The cheapest servers / VPS for web projects always support PHP. PHP has one of the lowest minimum requirements to the memory / processor speed.


Is PHP on the decline? Yes. But that doesn’t mean it’s going away any time soon.

Consider COBOL. An almost sixty year old language that’s horrible by modern standards and has been on the decline for thirty years. Yet it runs our financial infrastructure, and there are still an estimated one million COBOL developers worldwide. Maybe that is what PHP will be like in a couple of decades.
Functional (SAM) interfaces in Kotlin
Tags: kotlin, programming
Published: 2021-11-20 07:20:02

An interface with only one abstract method is called a functional interface(Single Abstract Method). functional (SAM)  interface can  have multiple non abstract method but only one abstract method

```kotlin
// functional interface example
interface CatchAble {
    fun invoke()
}
```

## SAM conversions
Instead of creating a class that implements a functional interface manually, you can use a lambda expression.

```kotlin
// functional interface example
interface CatchAble {
    fun invoke()
}

// functional interface example
fun interface FunctInterface{
    fun invoke(list: List<Int>) :List<Int>
}

// functional interface
interface FuncInterface3 {
    fun abstract_method(a: Int, b: String?)
    // Second method prevents lambda conversion
    fun   nonabstract_method() {
        println("do something")
    }
}


```

```kotlin
fun main(){

    // if we don't use SAM conversion
    val run  = object : CatchAble {
        override fun invoke() {
            print("Invoking CatchAble ")

        }
    }
    run.invoke() //  // Invoking CatchAble

    // if don't SAM use SAM conversion
    val fi = object :FunctInterface{
        override fun invoke(list: List<Int>): List<Int> {
            return  list.filter { pre -> pre %2 ==0 }
        }
    }
    print(fi.invoke(listOf(2,5,1,5,79,0))) // [2, 0]

    // using same conversion
    val fi2 = FunctInterface {
        it.filter { pre -> pre %2 == 0 }
    }
    print(fi2.invoke(listOf(2,5,1,5,79,0))) // [2, 0]

val fi3 = object : FuncInterface3{
        override fun abstract_method(a: Int, b: String?) {
            print("This is abstract method")
        }

        // it's not force to override this method
        override fun nonabstract_method() {
            print("overriding non abstract method")
        }
    }

    fi3.nonabstract_method() // do something
    fi3.abstract_method(2,"323") //overriding non-abstract method
}
```
## [Functional (SAM) interfaces in Java](https://sanjayprajapat.hashnode.dev/functional-interface)
Code Reviews
Tags: opensource, beginners, github, webdev
Published: 2021-11-20 07:13:18

After I contributed to an internal project, I experienced reviewing 2 pull requests and they were in the repository I contributed to. This project is for an online note for C language in my college, and uses Docusaurus.
:link:Repository: [IPC144](https://github.com/Seneca-ICTOER/IPC144)

When I contributed to the project, I audited and fixed the markdown page and was familiar with each task, so I reviewed the Pull Requests of other students who did it.

### Review1.
:link:Issue: [https://github.com/Seneca-ICTOER/IPC144/pull/95](https://github.com/Seneca-ICTOER/IPC144/pull/95)
I reviewed Reza9472's work, where he worked on not only the markdown file but also modified css and package.json file. He did a good job but I found some extra spaces similar to how I did it, so I made a comment about it.

### Review2.
:link:Issue: [https://github.com/Seneca-ICTOER/IPC144/pull/84](https://github.com/Seneca-ICTOER/IPC144/pull/84)
I read the markdown file line by line and found an extra comment, so I asked rclee91 to delete it. I wondered if we needed to delete extra indentations in the code blocks because I thought it wasn't user-friendly.
![code block and the mobile display](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0j6hxw9ujhit275hmfn8.png)
I checked C language code format, and the generator fixed the extra indentations, also some other students deleted the indentations in their PR. However, the original course note ([IPC144](https://ict.senecacollege.ca/~ipc144/pages/content/valid.html))has the same indentations so I just suggested him to change it.
rclee91 said the indentations are the same for all of the code example in the md file. The owners of the repo didn't say anything, so I was driven by the desire to have all the formatting the same, but decided to overlook it.

### Conclusion
I experienced getting reviews and also reviewing through this assignment. By comparing what I did with what other people did along the same task, it was helpful to be able to know what I was missing.
Weekly Challenge 139
Tags: perl, python, theweeklychallenge
Published: 2021-11-20 06:17:53

[Challenge](https://theweeklychallenge.org/blog/perl-weekly-challenge-139/), [My Solutions](https://github.com/manwar/perlweeklychallenge-club/tree/master/challenge-139/sgreen)

## Now with Python

Before I get stuck into my solutions for this task, I have some news. I've used Perl for over 20 years, and think I'm pretty good at it. However, Python is something relatively new for me. I've only really used it for the past five years, and I'm using it more and more at work these days. So from this week forward, I'll do at least one solution in Python. On with that, here's this weeks blog.

## TASK #1 › JortSort

### Task

You are given a list of numbers.

Write a script to implement JortSort. It should return true/false depending if the given list of numbers are already sorted.

### My solutions

This is relatively straight forward and my solutions in both languages follow the same logic.

* Assume the numbers are sorted
* Iterate through the array (Perl) / list (Python) from the second element to the last. If that value is smaller than the previous one, we know it is not sorted, and can exit the iterations early.
* Display `0` or `1` (representing false or true)

The main difference between the Perl and Python code is that Python doesn't automatically convert strings to numbers, so that has to be done manually.

### Examples

```
$ ./ch-1.py 1 2 3 4 5
1

$ ./ch-1.py 1 3 2 4 5
0
```

## TASK #2 › Long Primes

### Task

Write a script to generate first 5 Long Primes. A prime number (p) is called Long Prime if (1/p) has an infinite decimal expansion repeating every (p-1) digits.

### My solution

Like with the first solution, my solutions this task follow the same methodology for both languages. I start from three and keep counting until I find five numbers that (a) are primes and (b) has an infinite decimal expansion repeating every n-1 digits.

To determine if a number is a prime, I have a function that counts from 2 to the square root of the number. If the number is divisible by that value without a remainder, I return false. If the loop ends, then I return true.

To determine the second conditional, we can be use the logic of the [repeating decimals](https://en.wikipedia.org/wiki/Repeating_decimal) formula to calculate the number of digits required to repeat the sequence. This was also used in the second task of [challenge 106](https://dev.to/simongreennet/weekly-challenge-106-1cn7).

Unlike that time, we aren't really interested in the actual digits. For this this task, I take the value of `(10 * remainder) mod number` and keep looping until we hit the same remainder.

Then it's a matter of printing the list. For Perl that is `say join ', ', @solutions` while Python is `print(*solutions, sep=', ')`.

### Examples

```
$ ./ch-2.py 
7, 17, 19, 23, 29

$ ./ch-2.pl 
7, 17, 19, 23, 29
```
Open Exchange
Use Third Party Charting Libraries Today In Your Analytics Dashboard!
Tags: analytics, javascript, opensource, uidevelopment
Published: 2021-11-20 06:52:10

Now available on [Open Exchange](https://openexchange.intersystems.com/package/ThirdPartyChartPortlets) is a library of third party charts available to use within DeepSee/InterSystems IRIS BI dashboards. To start, simply download and install, select the new portlet as the widget type, then select the chart type that you desire. If you don't find the type of chart you are looking for, you can easily extend the portlet to implement your desired chart type. These new chart types can be used within existing dashboards or you can create new dashboards using them.

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

<!--break-->

After installing, the portlet can be selected and configured as follows:  
1) Add a new widget to your dashboard  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k56fwdeklrzavokf72bi.png)

2) Select Portlets, then Highcharts, then assign your data source  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ge3qr033qaj5mp43uuig.png) 

3) The widget will default to a line chart  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bjykqm65h06lis3kh0eg.png) 

4) Navigate to the Widget Settings to change the Chart Type if desired  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c00c1ks4cj48t3urvd7z.png) 

5) Select the desired chart type (I will choose "Bar" for this example)  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tnxx63og3sjm9bauwcu0.png) 

6) Data is now rendered using the new chart type  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mbv3gfo7cwmfipyutlyf.png)
Doing code reviews
Tags: opensource
Published: 2021-11-20 06:26:41

This week, I had a chance to review some pull requests from different students in [IPC144](https://github.com/Seneca-ICTOER/IPC144) repo.

## Review #1 
I did some reviews for this a PR on `Information.md` but the author ran into some technical issues, I tried to help him to resolve using git as I ran into the same issue as well, but he deleted his fork and tried opening new PRs. I pointed out some typo issues, markdown issues and his mistake committing an unresolved conflict. You can check them here, [PR#1](https://github.com/Seneca-ICTOER/IPC144/pull/115), [PR#2](https://github.com/Seneca-ICTOER/IPC144/pull/101), [PR#3](https://github.com/Seneca-ICTOER/IPC144/pull/119)

## Review #2
I pointed out an unnecessary section of the page of the [PR](https://github.com/Seneca-ICTOER/IPC144/issues/79) on `functions-arrays-and-structs.md` and advised an accessibility improvement on this [PR](https://github.com/Seneca-ICTOER/IPC144/pull/92)

## My thoughts 
Reviewing does take quite some time and great attention to details especially with those PRs. I did have some fun reading people's reviews and I learnt more about correct markdown syntaxes. I hope to review more challenging PRs next time.
Add Continuous Integration to GitHub Repo
Tags: ci, python, github, actions
Published: 2021-11-20 06:19:36

For this part of the work, CI (Continuous Integration) pipeline was applied in my GitHub opensource project, [TextHTMLPress](https://github.com/Qiwen-Yu/TextHTMLPress).

In general, CI is a method whereby we build and run our tests (i.e., integrate everything in our project) automatically whenever anything is pushed to the repo, or a new pull request is made. In this way, we can implement the idea that no developer is ever allowed to break the main branch. 

For GitHub projects, GitHub provides its own CI service called [GitHub Actions](https://github.com/features/actions). Actions allow us to automate workflows in response to events in a GitHub repo (e.g., merging to main, creating a pull request, etc). In this repo, I created a GitHub Actions Workflow that runs my tests and can be triggered on any push to the default branch (e.g., main), and for any pull request to the default branch. To add an GitHub Actions for python project, the [manual](https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python) is here, which is to add a `.yml` workflow file to the `.github/workflows` directory of your repository. My [workflow file](https://github.com/Qiwen-Yu/TextHTMLPress/blob/main/.github/workflows/TextHTMLPress_ci.yml) can be found here.

The CI process integrated to my project, It will test code in `ubuntu` system with Python version 3.6, 3.7, 3.8 and 3.9. It can install dependencies, lint with Flake8, and run tests with pytest.

After I set up my CI, I submitted a PR to test my CI and [it passed all tests automatically](https://github.com/Qiwen-Yu/TextHTMLPress/actions/runs/1483701730). Similarly, I submitted another [PR](https://github.com/lmpham1/cool_ssg_generator/pull/27) to test the CI of another opensource.
How to find an entity in jpa with primary key
Tags: java, jpa, codever, snippets
Published: 2021-11-20 06:18:00

Use the `find` method of the `EntityManager`, where the primary key is provided as the second parameter:

```java
@Stateless
public class PartnerRepository {

  @Inject private EntityManager em;

  public Optional<Partner> find(String partnerNumber) {
    return Optional.ofNullable(em.find(Partner.class, partnerNumber));
  }
}
```

The entity looks something like the following, with `partnerNumber` as primary key:

```java
@Entity
@Access(AccessType.FIELD)
@Table(name = "T_PARTNER")
public class Partner {

  @Id
  @NotNull
  @Column(name = "PARTNER_NUMBER", nullable = false)
  private Integer partnerNumer;

  //other fields ignored for readability
}
```

<hr/>

> Shared :heart: from [Codever](https://www.codever.dev/snippets/619524c9fb0221040e48bbb5/details).  :point_right:  use the [**copy to mine**](https://www.codever.dev/snippets/619524c9fb0221040e48bbb5/details) functionality to add it to your personal snippets collection.
How to see remote url in git
Tags: git, codever, snippets
Published: 2021-11-20 06:09:47

The simplest way:

```shell
git remote -v

# result similar to the following
origin  git@github.com:codeverland/codever.git (fetch)
origin  git@github.com:codeverland/codever.git (push)
```

<hr>

To get only the remote URL:

```shell
git config --get remote.origin.url

# result similar to the following
git@github.com:codeverland/codever.git
```

<hr>

In order to get more details about a particular remote, use the `git remote show [remote-name] command`

```shell
git remote show origin # here "origin" is the remote name

# result similar to the following
* remote origin
  Fetch URL: git@github.com:codeverland/codever.git
  Push  URL: git@github.com:codeverland/codever.git
  HEAD branch: master
  Remote branches:
    dependabot/npm_and_yarn/backend/aws-sdk-2.814.0  new (next fetch will store in remotes/origin)
    dependabot/npm_and_yarn/backend/nth-check-2.0.1  new (next fetch will store in remotes/origin)
    dependabot/npm_and_yarn/backend/path-parse-1.0.7 new (next fetch will store in remotes/origin)
    dependabot/npm_and_yarn/path-parse-1.0.7         new (next fetch will store in remotes/origin)
    docs/add-links-to-vscode                         tracked
    feat/add-last-searches-to-side-menu              tracked
    feat/add-welcome-info                            tracked
    feat/migrate-to-codever                          tracked
    master                                           tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local refs configured for 'git push':
    docs/add-links-to-vscode            pushes to docs/add-links-to-vscode            (local out of date)
    feat/add-last-searches-to-side-menu pushes to feat/add-last-searches-to-side-menu (local out of date)
    feat/add-welcome-info               pushes to feat/add-welcome-info               (local out of date)
    feat/migrate-to-codever             pushes to feat/migrate-to-codever             (local out of date)
    master                              pushes to master                              (up to date)

```

<hr>

> Shared with :heart: from [Codever](https://www.codever.dev/snippets/6194ba49fb0221040e48b6c5/details).  :point_right:  use the [**copy to mine**](https://www.codever.dev/snippets/6194ba49fb0221040e48b6c5/details) functionality to add it to your personal snippets collection.
Starting My Self-Taught Developer Journey
Tags: beginners, webdev, codenewbie, devjournal
Published: 2021-11-20 05:29:12

Hello, fellow self-taught developers! I am going to document my journey as a self-taught developer as a reminder and motivator to myself. I also hope this will help others who might be struggling with the same things I am.

Let's get started.

## Background
A quick introduction of my coding background, I majored in Geography and minored in Computer Science at the University of Texas at Austin. I currently work as a GIS Technician and primarily use Python and SQL. I’m also taking Harvard's CS50 and participating in #100DaysOfCode on Twitter.

## Deciding where to start
After deciding I wanted to become a developer, I began looking into various boot camps and self-taught developer paths. I watched videos, read articles, listened to podcasts, and reached out to people for advice. The more advice I received, the more stressed I became from the overwhelming amount of resources to choose from (paralysis by analysis). 

All these options made me realize there isn't a perfect answer or right path to becoming a developer. So I just need to start with what I think would work for me. I narrowed down my choices to what advice resonated with me.

Here is my **current** study plan:
## Review C and the Fundamentals
A Full Stack Developer I know, who's been working for almost 20 years, recommended me to learn C as an intro. They told me C could be used to teach the core concepts, data structures, and algorithms. They suggested I read [The C Programming Language, 2nd Edition](https://www.google.com/aclk?sa=L&ai=DChcSEwji_a-yzaP0AhX2bW8EHbbVCZsYABADGgJqZg&ae=2&ei=GyqXYerbI8_4aIH8kuAE&sig=AOD64_0MebtbbIlMQlbd8tATsv7Ywhnjbw&ctype=5&q=&sqi=2&ved=2ahUKEwiq1Y2yzaP0AhVPPBoKHQG-BEwQ9aACegQIARA9&adurl=) by Brian W. Kernighan, Dennis M. Ritchie. 

I have previous experience with C from taking Harvard's CS50 so this will be a good review.

The reason I am going to utilize this in my developer study plan is because I am not confident on my fundamentals of programming. My hope is C will help me grasp concepts easier in the future. Specifically, data structures and algorithms.

## Crash Course on HTML, CSS, and JavaScript
I will be taking a crash course for each language to learn the basics. I don't want to get trapped in tutorial hell so I will not be spending too much time on watching tutorials.

## Build Projects
After finishing the tutorials, I will start building projects, save them on my GitHub, and add them to my portfolio. 

The majority of the advice I received emphasized the importance of creating projects. I prefer applied learning so I understand things better from building out and dissecting code.

## Determine What Kind of Developer I Want To Be
Researching what kind of developer I want to be and then focusing on the languages, frameworks, etc. for that role.


## Conclusion
This is the beginning of my self-taught developer journey. In the future, the plan I laid out might change, but I’m excited to see where this takes me.
Contributing to Seneca OER
Tags: javascript
Published: 2021-11-20 05:23:25

I had a chance to [contribute](https://github.com/Seneca-ICTOER/IPC144/pull/41/files) to [IPC144](https://github.com/Seneca-ICTOER/IPC144), a work in progress which aims to upgrade the [current IPC144 website](https://ict.senecacollege.ca/~ipc144/) using Docusaurus. 

## The issue: 
I chose a pretty interesting issue to work on which asked me to convert the website into a pdf, the future students would be able to take notes partly thanks to me, yay! 

## Solving the issue: 
I took a look at a few packages that convert Docusaurus website into a pdf and I came to a conclusion to using [mr-pdf](https://www.npmjs.com/package/mr-pdf) as it supported Docusaurus v.2 and had multiple options. 

### Using `mr-pdf`
I created a shell script to run a line of command to convert the website into a pdf and added the script to the `scripts` of `package.json`.

```sh
#!/usr/bin/env bash

npx mr-pdf 
--initialDocURLs="http://localhost:3000" 
--contentSelector="article" 
--paginationSelector=".pagination-nav__item--next > a" --excludeSelectors=".margin-vert--xl a,.theme-edit-this-page,.tocCollapsible_1PrD theme-doc-toc-mobile tocMobile_3Hoh,.tocCollapsibleButton_2O1e" 
--coverImage="https://download.logo.wine/logo/
Seneca_College/Seneca_College-Logo.wine.png" 
--coverTitle="IPC144" 
--outputPDFFilename "Seneca-IPC144.pdf"
```

Another issue came up, as `mr-pdf` required a running instance of the website (`initialDocURLs`), the pagination target (`paginationSelector`), I needed to create a way for the project to `build` and `serve`. 

### Creating a way to automatic `build`, `serve` and convert
I wrote a Javascript file that used [`execa`](https://www.npmjs.com/package/execa/v/0.6.0) to handle child processes and [`wait-on`](https://www.npmjs.com/package/wait-on) to wait for resources on the `localhost` to be available and then converted the page into a pdf. Killing the port was the last thing to do. 

### Conclusion 
My PR technically was working but I had to to spend quite a while fix  to meet the standard, and I made a bunch of small, syntactic errors. Some of which I didn't know but thanks to the experience, I think I will not make those mistakes again.
Un-official Github Action for Deployment to Railway
Tags: actionshackathon21
Published: 2021-11-20 05:10:10

[Instructions]: # (To submit to the GitHub Actions x DEV Hackathon 2021, please fill out all sections.)


### My Workflow
[Note]: # (Please make sure the project links to the appropriate GitHub Actions repository, and includes [an open source license](https://choosealicense.com/) and README.)


### Submission Category: 

[Note]: # (Maintainer Must-Haves, DIY Deployments, Interesting IoT, Phone Friendly, or Wacky Wildcards)

DIY Deployments


### Yaml File or Link to Code

[Note]: # (Our markdown editor supports pretty embeds. Try this syntax: `{% github link_to_your_repo %}` to share a GitHub repository)

{% github bervproject/railway-deploy %}

* [Yaml](https://github.com/bervProject/railway-deploy/blob/main/action.yml)

### Additional Resources / Info

Example project that implement the **bervproject/railway-deploy**:

{% github bervproject/MyPersonalWebAPI %}

* [Action Link](https://github.com/bervProject/MyPersonalWebAPI/blob/master/.github/workflows/node%26docker.yml)