teleren/devto huggingface dataset:
JavaScript primitives Methods
Tags: javascript, node, webdev, tutorial
Published: 2021-02-19 20:14:25


[![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1613790212070/3UPsbbEeI.png)](https://www.sitepoint.com/?ref=osagiebello&utm_source=osagiebello)

---
Primitives are fundamental data types like strings, numbers, booleans, etc. These primitive data types can be worked on as objects (non-primitive).

For example, a method on an object. See the syntax below:

```js
object.method()
```

A method can also work on primitive data. 

Let's assume the primitive data type is `pmt`:

```js
pmt.method()
```

The syntax above is true because *an instance is an object which resides in memory at runtime*. 

> An instance is an object in a class.

We will see **classes** in future articles.

A method that works on an object may not work on primitive data.

See the example below:

```js
const str = "Hello";

console.log( str.toUpperCase() ); // HELLO
```

Accessing the `str` means the creation of a new object (instance of the string) that knows the value of the string (saved value in memory). The object also contains useful methods like `toUpperCase()` `toLowerCase()` etc. The object gets destroyed once the result (`HELLO`) is retrieved.

Since objects have properties, there are properties like `length`.

```js
const str = "Hello";

console.log(str.length); // 5
```

`.length` counts the number of characters in a string, `str`.

Methods like `toUpperCase()` are functions in an object. The function may contain properties like `length` - Every data type has its object.

See the example below:

```js
const num = 1.23456;

console.log( num.toFixed(2) ); // 1.23
```

> The most primitives `null` and `undefined` are exceptions because they have no corresponding wrapper objects (no methods and properties). 

**Happy coding!!!**

---
[![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1612902517533/1HxzNj7hF.png)](https://www.buymeacoffee.com/techstackmedia)

---

[![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1613790333966/S19xwpc0I.png)](https://www.datacamp.com/?tap_a=82040-4385c0&tap_s=1301289-aaa316)
Day 53 Of 100DaysOfCode: More About Algorithm
Tags: womenintech, codenewbie, 100daysofcode
Published: 2021-02-19 16:20:45

Greetings everybody. I hope you all are great. Today I started to learn SQL from [Data camp](https://campus.datacamp.com/courses/introduction-to-sql/filtering-rows?ex=4). Gain more knowledge about Algorithms. Tried to write some algorithm. Completed some assignment on coursera.

Below is my some algorithm today I tried to write myself.
#Python code
python code to find Last Digit of a Large Fibonacci Number.
```python
def calc_fib(n):
    a = 0
    b = 1
    fib = [a,b]
    if n <= 0:
        return n
    
    else:
        for i in range(1,n):
            f = a + b
            a = b
            b = f
        return b
    
        

n = int(input())
print(int(str(calc_fib(n))[-1]))
```
Output of the code is,
```python
999999
6
```
Python code to compute gcd of two number
```python
def gcd(a,b):
    m1 = min(a,b)
    m2 = max(a,b)
    CF = []
    for i in range(1,m1+1):
        if m1 % i == 0 and m2 % i == 0:
            CF.append(i)
        return max(CF)

a, b = map(int, input().split())
print(gcd(a,b))
```
When above code run we can get
```python
18 35
1
```
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Day 53 Of <a href="https://twitter.com/hashtag/100DaysOfCode?src=hash&amp;ref_src=twsrc%5Etfw">#100DaysOfCode</a> and <a href="https://twitter.com/hashtag/Python?src=hash&amp;ref_src=twsrc%5Etfw">#Python</a> <br>Hello! everyone. I hope you all guys doing well. Today I return to my 100daysofcode after taking 3 days of brake.<br>Today&#39;s achievement is,<br>* Learned SQL From Data Camp <br>* Continue to learned Algorithmic Toolbox<br>* Tried to write some Algorithms <a href="https://t.co/8TX3x5PLkb">pic.twitter.com/8TX3x5PLkb</a></p>&mdash; Durga Pokharel (@mathdurga) <a href="https://twitter.com/mathdurga/status/1362795258036166656?ref_src=twsrc%5Etfw">February 19, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
how to make rackup sinatra as systemd and auto restart on failure
Tags: sinatra, systemd
Published: 2021-02-19 20:04:10

sinatra app
```
#acc-server.rb
require 'sinatra/base'

class MyApp < Sinatra::Base
  set :bind, '0.0.0.0'
  set :port, 3333

  get '/' do
    "Hello #{params[:name]}"
  end
  run! if app_file == $0
end
```

rackup
```
require './acc-server'
run MyApp
```

shell script `server.sh`
```
#!/bin/bash
cd /root/server && /usr/local/bin/rackup -p 3333 -P /root/server/server.pid </dev/null &>>/root/server/log
```

systemd conf `/etc/systemd/system/pserver.service`
```
[Unit]
Description=Prosody http server

[Service]
ExecStart=/root/server/server.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target
```

start the service
```
systemctl start pserver.service 
```

then enable it on startup
```
systemctl enable pserver.service 
```
Pairing with Community Member Jono Yeong
Tags: devstream, pairprogramming, javascript
Published: 2021-02-19 19:38:48

On <time datetime="2021-02-17">February 17th</time>, DEV Community member [Jono Yeong](https://dev.to/jonoyeong) joined [Christina](https://dev.to/coffeecraftcode) and I on the pairing stream to work on an issue related to wanting to render HTML tags as text.

{%youtube WO201vtzWM4 %}

Here is the issue that we were working on:

{%github https://github.com/forem/forem/issues/2204 %}

### On this stream, we covered:

* **Debugging tools in the browser**, which helped us solve the issue
* **[Cross Site Scripting](https://owasp.org/www-community/attacks/xss/)** (XSS) mitigation -- a security in place that was causing the issue we were working on.
* How to retain security best practices while still allowing this issue to be fixed.

<center>

![Pikachu looking through a magnifying glass](https://media.giphy.com/media/42wQXwITfQbDGKqUP7/giphy.gif)

</center>

Thanks again for coming on the stream, Jono!

### You can also find the three of us all over the web here:

Jono:

* [Twitter](https://twitter.com/JonoYeong)
* [Website](https://www.jonathanyeong.com/)
* [YouTubel](https://www.youtube.com/channel/UClb6km0HLkGUOEjHlp5WdPA0)
* [Newsletter](https://newsletter.jonathanyeong.com/)

Nick:

* [Twitter](https://twitter.com/nickytonline)
* [Website](https://iamdeveloper.com/)
* [livecoding.ca](https://livecoding.ca)
* [YouTube](https://youtube.iamdeveloper.com)

Christina:

* [Twitter](https://twitter.com/coffeecraftcode)

Looking forward to seeing you on future streams! If you're interested in pairing, fill out [this form](https://iamdeveloper.com/pair). We’d love to tackle an issue with you that the whole community could learn from!

P.S. [Follow DEV on Twitch](https://twitch.tv/thepracticaldev) to be notified when future streams begin and catch old streams on [YouTube](https://www.youtube.com/c/thepracticaldevteam)
Note: Just noticed Okular PDF is on Windows
Tags: note, windows, tools
Published: 2021-02-20 01:46:43

---
title: Note: Just noticed Okular PDF is on Windows
published: true
date: 2021-02-19 19:37:37 UTC
tags: note,windows,tools
canonical_url: https://randomgeekery.org/note/2021/02/just-noticed-okular-pdf-is-on-windows/
---

 ![Just noticed Okular PDF is on Windows](https://randomgeekery.org/note/2021/02/just-noticed-okular-pdf-is-on-windows/cover_hu7c9721bdce4c9c20f27d59ab6cb92c99_151508_600x0_resize_box_2.png)

[Okular](https://okular.kde.org), the [KDE](https://kde.org) document viewer, works on Windows. Not only that, but it’s available in the [Microsoft Store](https://www.microsoft.com/en-us/p/okular/9n41msq1wnm8?activetab=pivot:overviewtab).

Free, obviously.

This should help keep annotations in order as I work through my TOREAD stack — three chapters down, only several hundred books to go! — regardless of current operating system.
What was your win this week?
Tags: discuss, weeklyretro
Published: 2021-02-19 19:34:51

---
title: What was your win this week?
published: true
description: Got to all your meetings on time? Started a new project? Fixed a tricky bug?
tags: discuss, weeklyretro
cover_image: https://cl.ly/188e843c2985/download/Image%202019-02-15%20at%202.36.37%20PM.png
---

Happy Friday!


**Looking back on your week — what was something you're proud of?**

All wins count — big or small 🎉

Examples of 'wins' include:

- Starting a new project
- Landing a new job
- Playing with a pet ... or whatever else might spark joy ❤️ 

---

Happy Friday!

![Jumping into the weekend](https://media.giphy.com/media/d5Z1X8rZO8TqoBY5PR/giphy.gif)
Get all headings and their target URLs from a Markdown generated page
Tags: snippet, javascript, markdown
Published: 2021-02-19 19:24:48

---
title: Get all headings and their target URLs from a Markdown generated page
published: true
description: A snippet to get all headings and their URLs from a markdown generated HTML document
canonical_url: https://christianheilmann.com/2021/02/19/a-code-snippet-to-scrape-all-headings-and-their-target-urls-from-a-markdown-generated-page/
tags: snippet,javascript,markdown
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0oyt3rp9ci3gq94vqajc.png
---

When you use Markdown to write your documentation most static page generators will generate IDs for each of the headings in the document to allow you to navigate directly to them.

```markdown
## Gerbils and other rodents
```
becomes
```html
<h2 id="gerbils-and-other-rodents">Gerbils and other Rodents</h2>
```
To go directly there you can then use `https://example.com#gerbils-and-other-rodents` if you published at `example.com`. 

The other day I was asked to create a list of all the links in the [What's new in Devtools 89](https://docs.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/whats-new/2021/01/devtools) document, which is generated from Markdown. The list should be the text of the headline followed by the full URL to get to that part of the document. This was to batch generate some shortURLs from them. 

I am pretty sure there are a lot of clever ways to do that by scraping but as I like my browser environment, I just used the Console to do that. Here's the script that you can paste into the Console:

```javascript
let out = '';
$$(':is(h1,h2,h3,h4,h5,h6)[id]').forEach(elm => {
   out += `${elm.innerText}
${document.location.href}#${elm.id}
` 
});
copy(out);
```

You can see it in action in the following GIF:

![Running the script in the console to get all the heading information](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/slua50od7quzzxg6itzz.gif)

The next step was to store this as a [Snippet](https://docs.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/javascript/snippets) and next time I just need to run that.
NEPTI Script v1.01
Tags: linux, shell, tutorial, codenewbie
Published: 2021-02-19 18:51:28

Github Project- https://github.com/navjots7/NETPI-v1.01

This is our first script and it is based on the basic networking tools that are already available on Kali Linux. But instead of opening different terminal windows for different tools, this script will save your time. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0lnxyr2cy6zey84yh5d0.png)

While writing this article, the script contains 6 features namely: 
1. IP Address - Know your IP Address
2. MAC Address- Know your MAC Address
3. Turn off the Interface- Turn off the interface
4. Gateway IP- Know the Gateway IP
5. Whois- use whois tool and the output will be saved in a different file named as Output.txt
6. Hostname- Know the hostname
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rbgkls7ny7uffw89a5fg.png)
So for this script to work, you need an interface with state as up. If the interface is down, this script will initially try to change the state of the interface. 

At first, it will list all the network interfaces which are in the up state. If you see your choice of Network interface in that list, you need to write down the interface to continue. Else just mention the specific interface you want to use, it will try to bring that interface in the up state and if that is successful then you will further proceed with the script or it will show an error if the interface is not present (This will result in exiting of the script.).

Once you are done with this, just use the script with these tools. We will add some more tools in the near future.

If you find any issue with the script, do mention it in the “issue” tab.

> WE ARE NOT RESPONSIBLE HOW YOU ARE GOING TO USE THIS SCRIPT. PLEASE BE ETHICAL, LEGAL AND USE IT FOR EDUCATIONAL PURPOSES ONLY.


## CREATORS

**Twitter-** 
@navjot7s - https://twitter.com/navjot7s
@dhairyachandra - https://twitter.com/dhairyachandra

**Github-**
@navjots7 - https://github.com/navjots7
Dhairyachandra - https://github.com/dhairyachandra
@Singhm-n - https://github.com/Singhm-n
NEPTI Script v1.01
Tags: network, shellscript, kalilinux, tools
Published: 2021-02-19 18:41:47

Github Project- https://github.com/navjots7/NETPI-v1.01

This is our first script and it is based on the basic networking tools that are already available on Kali Linux. But instead of opening different terminal windows for different tools, this script will save your time. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0lnxyr2cy6zey84yh5d0.png)

While writing this article, the script contains 6 features namely: 
IP Address - Know your IP Address
MAC Address- Know your MAC Address
Turn off the Interface- Turn off the interface
Gateway IP- Know the Gateway IP
Whois- use whois tool and the output will be saved in a different file named as Output.txt
Hostname- Know the hostname
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rbgkls7ny7uffw89a5fg.png)
So for this script to work, you need an interface with state as up. If the interface is down, this script will initially try to change the state of the interface. 

At first, it will list all the network interfaces which are in the up state. If you see your choice of Network interface in that list, you need to write down the interface to continue. Else just mention the specific interface you want to use, it will try to bring that interface in the up state and if that is successful then you will further proceed with the script or it will show an error if the interface is not present (This will result in exiting of the script.).

Once you are done with this, just use the script with these tools. We will add some more tools in the near future.

If you find any issue with the script, do mention it in the “issue” tab.

WE ARE NOT RESPONSIBLE HOW YOU ARE GOING TO USE THIS SCRIPT. PLEASE BE ETHICAL, LEGAL AND USE IT FOR EDUCATIONAL PURPOSES ONLY.


CREATORS

Twitter- 
@navjot7s - https://twitter.com/navjot7s
@dhairyachandra - https://twitter.com/dhairyachandra
Github- 
@navjots7 - https://github.com/navjots7
@dhairyachandra - https://github.com/dhairyachandra
@Singhm-n - https://github.com/Singhm-n
Movies App With React
Tags: react, node, mongodb, express
Published: 2021-02-19 18:40:51

Hello Everyone 🖐, hope you are doing great i want to introduce to you my movies app to which is a little bit like Netflix 😅. 
First of all i have to say that this app in Albanian language, i chosed to do this app with react not just because is fast but also i love it 😍.

For the backend i have used node with express and mongo.

Some of the functionalities that i have added for this app are live search, favorite movies also the time of movies that you are watching [you have to signup for those functionalities] which are free 

In the future maybe will also be a English version

I hope you will like it 🤩

Note all movies are with albanian captions


Here is the url https://ufilma.com/
Add current working directory in your shell prompt
Tags: bash, shell, linux, terminal
Published: 2021-02-19 18:33:23

Bash prompt can be set by setting the environment variable `PS1`.

Current directory can be displayed in 3 types:
 - Full path
```
~/work/esp/esp-idf/examples/bluetooth/nimble$ 
```
 - Partial path
```
~/.../bluetooth/nimble$ 
```
 - Only parent directory.
```
nimble$ 
```

In value of `PS1`, `\w` or `\W` can be used to include working directory in the prompt. Change the value of `PS1` in your `$HOME/.bashrc` file to change it for every terminal.

> If you use `zsh` or any other shell, search where the config file is located and update it accordingly. `.bashrc` is used for `bash` shell which is default in most systems.

To set full path, `\w` can be used.
```sh
PS1="\w$ "
# Prompt would look like:
# ~/work/esp/esp-idf/examples/bluetooth/nimble$ 
```

To see only current directory's name in prompt, use `\W`
```sh
PS1="\W$ "
# Prompt would look like:
# nimble$ 
pwd
# Prompt will show only first parent directory, current path is:
# /home/chinmay/work/esp/esp-idf/examples/bluetooth/nimble
```

To see partial path, the environment variable `PROMPT_DIRTRIM` can be set to desired value to see number of parent directories. Default value of `PROMPT_DIRTRIM` is `0`.
```sh
PS1="\w\$ " # Setting PS1 to show full path
# ~/work/esp/esp-idf/examples/bluetooth/nimble$ 
export PROMPT_DIRTRIM=4 # Trimming path to 4 directories
# ~/.../esp-idf/examples/bluetooth/nimble$ 
export PROMPT_DIRTRIM=2 # Trimming path to 2 directories
# ~/.../bluetooth/nimble$ 
export PROMPT_DIRTRIM=0 # Back to normal
# ~/work/esp/esp-idf/examples/bluetooth/nimble$ 
```

Checkout [designing a minimal bash prompt](https://dev.to/chhajedji/minimal-and-super-useful-shell-prompt-1g8l).
#SimpleGuide002 - How deploy a website to Heroku
Tags: heroku
Published: 2021-02-19 18:33:09

Hi, I am Zsolt a beginner self-taught developer. I just started my journey into coding and CS and decided create simple step by step guides to help my learning process.

## Simple Guide 002
### How deploy a website to Heroku
<br/><br/>
A simple step by step guide for beginners to deploy a website to Heroku
<br/><br/>
<br/>
Step 1 - Create new app on Heroku
- Log in to Heroku
- Click New
- Click Create new app
- Type in app name
- Click create

Step 2 - Log in to Heroku using your command-line interface
- Type $ heroku log in and follow instructions


Step 3 - Initializie Git, add files from  and commit
- Open your chosen command-line interface (I use and love Hyper)
- Go to your project folder --> $ cd *folder name*
- Initialize Git --> $ git init
- Add all files to git --> $ git add .
- Commit --> git commit -m "*commit name*"

Step 3 - Add heroku remote
- Go to your project on Heroku
- Click Deploy
- Choose Heroku Git
- Copy heroku git:remote -a *project name*
- Go back to your command line 
- Paste heroku git:remote -a *project name*

Step 4 - Deploy to Heroku
- Push to Heroku with command-line --> $  git push heroku main


When command-line finished executing your app/website will be deployed to heroku.
Shift the TZ for your K8s CronJobs
Tags: kubernetes, timezone
Published: 2021-02-19 18:31:20

In your Kubernetes clusters, the timezone is typically assumed to be UTC, which is a very cloud-native way to provision things.  The resources you have might be across the globe, so having every node or host use the same timezone makes sense, especially if you're correlating information in logs.

But in other environments, there is a need to have the local timezone configured.  

What happens if your cronjobs in the cluster are not aligned with the local timezone?  This could cause some minor havoc.  

The answer is simple.  The timezone settings for cronjobs are managed by the `kube-controller-manager` component.  Assuming all of your control-plane nodes are provisioned prior with localized and correct timezone settings, just add an extra mount, adding in `/etc/localtime` into the `kube-controller-manager` component.

Inside Rancher RKE it may look something like this in your cluster.yaml file:

```bash
services:
  kube-controller:
    extra_binds:
      - '/etc/localtime:/etc/localtime'
```

Provision your clusters with the localtime setting mounted and your jobs will be in the proper timezone.
NetworkManager, leave Calico Interfaces alone.
Tags: kubernetes, calico
Published: 2021-02-19 18:20:27

We've all been there.  You set up your nifty new Kubernetes cluster, and choose your favorite CNI, Calico, to handle networking.

But then NetworkManager comes along and has to watch and interfere with all of these new virtual interfaces introduced by Calico.

We can tell NetworkManager to ignore these interfaces by making the new file...
```bash
/etc/NetworkManager/conf.d/calico.conf
```
... and including the following content inside of it.
```bash
[keyfile]
unmanaged-devices=interface-name:cali*;interface-name:tunl*;interface-name:vxlan.calico
```

Now those virtual interfaces used by Calico will get ignored and will not see any interference from NetworkManager.  Of course, you can also always decide not to use NetworkManager, but this may not be practical in all environments.
Plan My MD Visit Part 2
Tags: ruby, rails
Published: 2021-02-19 18:19:14

I have decided to fine-tune **[Plan My MD Visit](https://plan-my-md-visit.herokuapp.com/)** after receiving feedback from fellow developers on responsive web design and future build status.

### Responsive Web Design

Previous front-end built was centered around the users navigating through web browser. I went back, adjusted CSS/style classes, and added the `<meta>` tag for mobile phone users.

```html
<!DOCTYPE html>
<html>
  <head>
    <title>PlanMyMdVisit</title>
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>

    <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=0.9">

    ...

  </body>
</html>
```

> **[Plan My MD Visit](https://plan-my-md-visit.herokuapp.com/)** is now responsive on mobile, tablet and desktop browser! 🌟

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n7pxygvhz57r7zffk0dx.gif)

### Build Status and Future Improvement

Current project-built was completed in a 2-week timeframe from API data search, model association development, and MVP for both patient and admin user interface. 
Future cycle of product development as follows:

- Add `Healthcare Provider` to model associations. Patients can find their healthcare providers, and sort through in-network doctors by their specialties.
- Outsource from different APIs for doctors, currently restricted to Medicare Care Compare eligible professionals.
- Develop user interface for users as doctors.
- Set up customized validations for scheduling appointments where each individual doctor can personalize their preferred schedule.
- Communication features (i.e., private messaging) in between doctors and patients.
- Design separate CSS layouts for different user groups: patients, admins and doctors.

{% github fentyhall/PlanMyMDVisit %}

***

Post Scriptum:
This is my Module 3 capstone project with Flatiron School. I believe one of the catalyst to becoming a good programmer is to welcome constructive criticism. Feel free to drop a message. 🙂
 
Keep Calm, and Code On.

***
<center>[**fentybit**](https://fentybit.me/) | [GitHub](https://github.com/fentybit) | [Twitter](https://twitter.com/fentybit) | [LinkedIn](https://www.linkedin.com/in/fentybit/)</center>