teleren/devto huggingface dataset:
How to use GNU screen to run processes
Tags: tutorial, bash
Published: 2022-08-26 23:33:00

Screen is an ancient but still useful software on the GNU operating system that's available on most linux distros and on Macs. 

For example, if you need to SSH to a remote server and need to run a long process that and can't worry about whether the connection will terminate, running the process in a screen will run your process in the background such that even if a connection is lost, it'll keep operating. When you reconnect to the screen, the state of the session will be as-is when you exited.

**Steps**

`screen`

```
sh@SH-MacBook-Pro tutorial % screen
```

you should see a start message here, which you can just press enter to get past.

You're now 'attached' to the screen session. To see that you're attached, you can see a list of screens and their statuses by running `screen -ls`:

```
sh@SH-MacBook-Pro tutorial % screen -ls
There are screens on:
        69475.ttys010.SH-MacBook-Pro      (Attached)
1 Socket in /var/folders/vw/865hm_fd2pj87qtwf_5n329m0000gn/T/.screen.
```

While you're attached, you can run a script and have it start processing whatever it is that you're doing.

```
sh@SH-MacBook-Pro tutorial % python somescript.py
             >> This is some logging being produced by
             >> a script that you're running
```

As your process is producing output, instead of hitting `Ctrl+c`, you can hit `Ctrl + a + d` to "detach" from the screen. The process will keep running in your still-attached screen session. You'll now be back in your normal terminal, and see a log that says you just detached from a screen:

```
[detached]
sh@SH-MacBook-Pro tutorial %
```

If you run `screen -ls` again here, you'll see that there is an active screen that you're detached from.

```
sh@SH-MacBook-Pro tutorial % screen -ls
There is a screen on:
	68979.ttys002.SH-MacBook-Pro	(Detached)
1 Socket in /var/folders/vw/865hm_fd2pj87qtwf_5n329m0000gn/T/.screen.
```

To reconnect to your screen, you can run `screen -r`. If you only have one active screen, you can just run `screen -r`. If you have multiple active screens to choose from, run `screen -r` with the screen id (68979 in this case).

```
sh@SH-MacBook-Pro tutorial % screen -r 68979
```

This will take you to your screen session that you created before. 

```
sh@SH-MacBook-Pro tutorial % python somescript.py
             >> This is some logging being produced by
             >> a script that you're running
             >> More stuff was logged since we last checked
```

To exit a screen, `Ctrl + d` will exit the session. This kills the current screen session, and you won't be able to re-attach to it.


### Scrolling

Within a screen session, scrolling up the terminal window with the mouse will not work as usual. 

Scroll up a screen you're attached to by entering "scrollback" mode. 

`Ctrl + a + Escape` will enter you into scrollback mode. Once you're in here, arrow keys will allow you to actually go up the screen log history. Mouse still won't work sorry.
Javascript Tagalog - Math.ceil
Tags: javascript, tagalog, pinoy, ceil
Published: 2022-08-26 23:30:00

**Ano ngaba ang Math.min sa Javascript?**
Math Function siya na lagi i ro-round yung number na binigay papunta sa largest integer. (also i ta-try ni js na i convert ang mga binigay na value as a number if hindi number data-type yung binigay)

```javascript
console.log( Math.ceil(1.2) ) // 2

console.log( Math.ceil('7.8') ) // 8

console.log( Math.ceil(0.1) ) // 1

console.log( Math.ceil(1.0002) ) // 2

console.log( Math.ceil(-4.004) ) // -4

console.log( Math.ceil('-2.001') ) // -2
```

NaN kapag nag tinry mo mag pass ng hindi number or any na hindi pwede maconvert as a number
```javascript
console.log( Math.ceil() ) // NaN
console.log( Math.ceil({}) ) // NaN
```
**More tagalog Javascript Learning Resources:**
https://javascript-methods-in-tagalog.vercel.app/
Javascript Tagalog - Math.max
Tags: javascript, philippines, pinoy, max
Published: 2022-08-26 23:22:23

**Ano ngaba ang Math.min sa Javascript?**
Math Function siya na i re-return yung pinakamataas value sa mga binigay na parameters/arguments (also i ta-try ni js na i convert ang mga binigay na value as a number if hindi number yung binigay)

```javascript
console.log( Math.max(-1,0,1) ) // -1
console.log( Math.max('3',4,5) ) // 5

const x = [1, 2, 3]
const y = new Set([0,1, 2, 3, 4])

// Using spread operator para mapass mga values as parameters
console.log( Math.max(...y) ) // 4
console.log( Math.max(...x) ) // 3

```
NaN kapag nag tinry mo mag pass ng hindi number or any na hindi pwede maconvert as a number
```javascript
console.log( Math.max({}) ) // NaN
```

**More tagalog Javascript Learning Resources:**
https://javascript-methods-in-tagalog.vercel.app/
Javascript Tagalog - Math.min
Tags: javascript, philippines, pinoy, min
Published: 2022-08-26 23:20:52

**Ano ngaba ang Math.min sa Javascript?**
Math Function siya na i re-return yung pinakamababang value sa mga binigay na parameters/arguments (also i ta-try ni js na i convert ang mga binigay na value as a number if hindi number yung binigay)

```javascript
console.log( Math.min(-1,0,1) ) // -1
console.log( Math.min('3',4,5) ) // 3

const x = [1, 2, 3]
const y = new Set([0,1, 2, 3, 4])

// Using spread operator para mapass mga values as parameters
console.log( Math.min(...y) )
console.log( Math.min(...x) )

```
NaN kapag nag tinry mo mag pass ng hindi number or any na hindi pwede maconvert as a number
```javascript
console.log( Math.min( {} ) ) // NaN
```

**More tagalog Javascript Learning Resources:**
https://javascript-methods-in-tagalog.vercel.app/
Javascript Tagalog - Math.PI
Tags: javascript, pinoy, tagalog, math
Published: 2022-08-26 23:08:00

**Anon ngaba ang Math.PI sa Javascript?**
Re-return niyalang yung value ng PI tapos pwede mona gamitin sa mga calculations na need ang PI.

```javascript
console.log( Math.PI ) 
// 3.141592653589793
```

Calculate Circumference from [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI)
```javascript
function calculateCircumference ( radius ) {
  return 2 * Math.PI * radius;
}

console.log( Math.PI );
// expected output: 3.141592653589793

console.log( calculateCircumference(20) );
// expected output: 125.66370614359172
```

**More tagalog Javascript Learning Resources:**
https://javascript-methods-in-tagalog.vercel.app/
Watch mega.nz videos with mpv
Tags: megatools, mpv, tools
Published: 2022-08-26 23:00:52

yeap!, As you read videos hosted in mega.nz!

I like watch anime videos and there are tons website sharing anime videos in mega.nz well, here a trick!

with this command when megatools its downloading the file it passing to mpv very similar like streaming.

`megatools dl "https://mega.nz/#hashvideo" --path - | mpv -`

the requirements are [megatools](https://megatools.megous.com/) plus [mpv](https://mpv.io/)


![previe gfig](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/elwmn5927vej6uy7v0mk.gif)
Why I always use backticks for strings
Tags: javascript, webdev, discuss, typescript
Published: 2022-08-26 22:53:48

## A quick one from me

If you're using single quotes or double quotes for your strings and not backticks (template literals), then I'm afraid your sanity may be in question.

### What happens when you DON'T use backticks

If you're using single quotes (the worst offender) and your string requires an apostrophe, you're back to using double quotes. Now your code has inconsistent string syntax. The reverse is also true, albeit less common - if you're using double quotes and you need double quotes in your string, you're back to using single quotes. In both of these cases, if you ever need to pass in a variable, you're introducing template literals / backticks - a 3rd string syntax.

### What happens when you use backticks

There are 2 main advantages:

Firstly, your codebase's string syntax is consistent. You can pass in apostrophes / single quotes and double quotes without thinking -- a freedom you don't appreciate until it's taken away from you -- and secondly, you are free to pass in variables whenever you like without going back and changing those damned quotation marks!

I wondered if people didn't do this because of some kind of performance advantage where template literals would be slower or more expensive, but I've found nothing that supports this theory, so it begs the question:

Why would you use any other syntax?
Day 623 : Didn't Care
Tags: hiphop, code, coding, lifelongdev
Published: 2022-08-26 22:22:29

_liner notes_:
- Professional : Pretty chill day. Had a meeting with a developer that is building something with my company's product. They got some cool stuff. Had a good talk and was able to show some demos and blog posts that will hopefully help. Looking forward to seeing what they build. Rest of the short day, I worked on an upcoming workshop.

- Personal : Went through a bunch of tracks for the radio show. Got the translation functionality working on my workshop site. Felt good. Also went through my Japanese reviews on Wani Kani. Ended the night watching "She Hulk" and "The Sandman".

![A dirt road in Seven Lakes Park, MI, USA going through a forest with trees with mostly yellow and light green leaves with some sunlight shining through](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c97rxwzz51dup5sqp5no.jpg)

Going to finish up the radio show pre-work. I want to add the same translation functionality that I did for my workshop's site to my talks site. I'm going to make a subdomain that people can go to during my talk and it will have the real time speech to text and translation if needed and people will also be able to click links that I talk about. Shouldn't be too bad since I got the other site working. Just need to do something similiar, and Firestore didn't care that this new data is different from the previous data I was sending. NoSQL for the win!! haha Want to watch a couple of "The Sandman" episodes. Going to be travelling for like all of September so I don't know if I'll be updating the blog, but I will be posting to my travel site https://doingstuff.in, doing my radio show https://kNOwBETTERHIPHOP.com and probably a couple of more https://untilit.works cypher on this coming Sunday. Till next time. Be safe!

Have a great night and weekend!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube QauTyt8VDOY %}
Updating Odoo Inventory By Lots
Tags: python, odoo, api
Published: 2022-08-26 22:14:00



Odoo inventory management is huge challenge. Handling 1-20 products ? No problem. Handling 1000-20000? We have a problem. 




In this article, I am going to cover how to update inventory of a specific LOT.

I have a repo on the bottom of this page. 


Updating inventory based on LOT’s has a couple of advantages, but for this case I am focused on speed. Lets get started. 




     

1.  Get the ID of all locations where the LOT is located. 
2.  Loop and get all the info we need. 
3.  Overwrite the locations.




#1. Get every location where the lot is located. 

```
lotty= ‘iamalotid1234’

 lotty_product_location = models.execute_kw(db, uid, password, 'stock.quant', 'search_read', [['&', ['lot_id', '=',lotty],['on_hand','=',True]]])

```



Lets break this down. 

The script does two things. 

Searches for ‘stock.quant’, that has a lot_id of ‘lotty’ and the ‘on_hand’ is true. 



#2.  Lets loop and clean up some data

```
 for i in lotty_product_location:
        print("{0} - {1} - {2}".format(i['location_id'] 
              [1],i['product_id'][1],i['quantity']))

```




#3. Okay the data looks clean, lets over write everything to 0. 

 

```
update_qty = models.execute_kw(db, uid, password, 'stock.quant', 'write', [[lotty_product_location[0]['id']], {'available_quantity': '0','quantity': '0'}])

```

We can change to quantity to something else, but for now lets do 0 to see if our inventory is update. 

NOTE: You need to update both 'available_quantity' and 'quantity'

DONE

We can get fancy and add in some more filtering and logic but for now we can updated all inventory based on the lots. 


In the future I will make some more complex scripts, something like update all inventory if the quantity is x amount and the product is a certain product. 


https://github.com/thetrebelcc/Odoo_lot_inventory_updates
CSS Attribute Selectors
Tags: css
Published: 2022-08-19 04:06:00

// select all elements with a given tag name

```
body {
    background-color:rosybrown;
}
```

// impacts all h1 elements when the mouse is hovering over them
```
h1.hover {
    color: purple;
}
```

// 'nth' can be replaced with 'first', 'last', or 'only'. This selector will grab the second li element in the first list
```
li:nth-child(2) {
    color: steelblue
}
```

// this grabs an element by its ID, and defines its properties as a link that has not been clicked
```
#google-link:link {
    color: blue;
} 
```

// this allows us to identify which links have been visited by adjusting their properties after being visited. In this case, it is still only applying to the element with the google-link ID
```
#google-link:visited {
    color: darkblue;
} 
```

// this will impact all links that follow a heading
```
h2 + a {
    color:aliceblue;
}
```

// slightly different from the selector above, this will grab all buttons that follow a text area that they share a parent with
```
textarea ~ button {}
```

// the > is the child selector, in this case grabbing all li's within a ul
```
ul > li {
    color:skyblue;
}
```


// descendent selector, all children and their children
```
ul li {
    color:black;
}
```

// all h2's with the subtitle class
```
h2[class=subtitle] {
    color: magenta
}
```

// all images on page with sources linking to the parent directory*/
```
img[src^="../img/"] {
    border: 10px solid black;
}
```
/*replace ^ with * to contain the phrase anywhere in the string*/

// all h2's with a class subtitle that may be found within a list of class names that are separated by white spaces
```
h2[class~=subtitle] {
    background: green
}
```

// all h2's with a class subtitle that may be found within a list of class names and may have a dash(-) encasing the word rather than a space
```
h2[class|=subtitle] {
    font-size: 12px;
}
```
Hide/Reveal Useful Info - Pure CSS
Tags: codepen
Published: 2022-08-26 22:11:47

<p><em>Created for the <a href="https://codepen.io/challenges/2021/April">April 2021 CodePen Challenge</a></em></p>

{% codepen https://codepen.io/harunpehlivan/pen/zYWVYYN %}
Create Redis Key - An NPM Package to Config & Create Redis Keys
Tags: redishackathon
Published: 2022-08-26 22:01:42

### Overview of My Submission

I created an NPM package named as `create-redis-key`

A Redis key creation utility.

Create `Redis Key Templates`, which include parameters, using a nested config object & use your `Redis Key Template` strings to create Redis Keys.

I published [an introduction post](https://dev.to/alperguven/create-redis-key-easy-way-to-configure-all-your-redis-keys-in-one-place-14hh) for the package on DEV.to!

Explained my motivation for developing such package on the [motivation section of my introduction post](https://dev.to/alperguven/create-redis-key-easy-way-to-configure-all-your-redis-keys-in-one-place-14hh#motivation) for the package.

The code released under [MIT](https://choosealicense.com/licenses/mit/) licence on GitHub.

### Submission Category: 

Wacky Wildcards

### [Optional: Video Explainer of My Project]

None.

### Language Used

Typescript & NodeJS

### Link to Code

See `create-redis-key` on GitHub.

{% embed https://github.com/alper-guven/create-redis-key %}

See [create-redis-key](https://www.npmjs.com/package/create-redis-key) on NPM.

{% embed https://www.npmjs.com/package/create-redis-key %}

### Additional Resources / Info

My package is well documented & tested. Ready for production use.

### Collaborators
@alperguven

- - - 

* _Check out [Redis OM](https://redis.io/docs/stack/get-started/clients/#high-level-client-libraries), client libraries for working with Redis as a multi-model database._
* _Use [RedisInsight](https://redis.info/redisinsight) to visualize your data in Redis._
* _Sign up for a [free Redis database](https://redis.info/try-free-dev-to)._
How to Install Graph CLI On Ubuntu
Tags: graphql, ubuntu, linux, sudo
Published: 2022-08-26 21:54:21

A few days ago, I got stuck trying to install Graph-cli on my Ubuntu operating system. I had to make a lot of research to figure it out, and I did with the help of my peers too. 
In this article, I will be sharing how to install Graph-cli on Ubuntu, and this will be a quick one.

The Graph CLI is written in JavaScript, and you will need to install either yarn or npm to use it; it is assumed that you have yarn in what follows. Once you have yarn, install the Graph CLI by running,

**For Ubuntu, install with yarn or npm:**
```
sudo yarn global add @graphprotocol/graph-cli
```
The sudo keyword gives the dependencies root access to your OS

**Other Methods on Linux**
libsecret is used for storing access tokens, so you may need to install it before getting started. Use one of the following commands, depending on your distribution:

Debian/Ubuntu:```
sudo apt-get install libsecret-1-dev
```
Red Hat: ```
sudo yum install libsecret-devel
```
Arch Linux: ```
sudo pacman -S libsecret
```


**For other OS, install with yarn or npm:**
```
yarn global add @graphprotocol/graph-cli
```

Once installed, the graph init command can be used to set up a new subgraph project, either from an existing contract on any of the public Ethereum networks or from an example subgraph. This command can be used to create a subgraph on the Subgraph Studio by passing in graph init --product subgraph-studio.

If you already have a smart contract deployed to the Ethereum mainnet or one of the testnets, bootstrapping a new subgraph from that contract can be a good way to get started.

Learn more about creating and deploying subgraph [here.](https://thegraph.com/docs/en/developing/creating-a-subgraph/#install-the-graph-cli)
Can't Access Fragment Views
Published: 2022-08-26 21:48:44

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

When the observer is still active on the parent's view, the **Can't access Fragment Views** error occurs. Even if the view is deleted, LifecycleOwner remains ( Navigating to the next Fragment)

Came Across this error while trying to observe live data through the current viewLifecycleOwner

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


**SOLUTION**
A possible and very simple workaround for this type of problem is to encapsulate the code that causes it in an **if statement** with the condition to check if the view is null or not.

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

**Wrap Up**
As long as our condition is true, our line of code has a view to which it may connect, making it accessible. However, if not, such a viewpoint becomes disconnected.

I hope this helps, and I'll make sure to post more about any difficulties and solutions I encounter on my Android journey.
A Logging, Monitoring and Alerting platform for less than $20
Tags: monitoring, devops, tutorial, productivity
Published: 2022-08-26 21:43:00

_Can you track your application, server logs, monitor these, generate alerts from these with same platform and for few dollars only?_

The answer is **yes**, and I have been doing that with Elasticsearch Cloud. Elasticsearch was originally built to track and store logs, and the cloud version allows you also to do the rest: Monitoring and Alerting.

**1 — Tracking logs**

Either you want to keep and track your servers or applications logs, Elasticsearch is a good place to do that. I have been using this platform on both On-Premise and on the Cloud for almost 6 years now. At the end, I would suggest you the cloud one, so you do not have to install anything and worry about the platform. Also, you can get an instance for less than $20 per month.

Regarding logs, there are some tools like Logstash that can help you to parse these on your server, so you send only what you need and within the format you want to. Still, I would suggest you to write your own script just posting the data you need. It will be easier to maintain, and you can add, modify the structure of data you send easily with a simple POST query.

You can get an idea of how to write this down in the following article: [“10 lines of code that will save your life!”](https://dev.to/tipicalls/10-lines-of-code-that-will-save-your-life-33o2)

**2 — Monitoring and Alerting**

Once you have your instance created, you can start building visualization and dashboards. From these, you can then on a daily basis look at how much CPU, bandwidth, number of users, … whatever you tracked, you have.


Great thing is that you can set up threshold in these visualizations and create alerts based on these. I have been using email alerts so far, and it helped a lot.

In Tipicalls.com, the meeting and collaboration platform we built, we are using Elasticsearch to monitor and alert on both web client usage, audio and video bridge usage and issues.

I hope this article helped.

Feel free to visit our 100% free online meeting room platform named [tipicalls.com](https://tipicalls.com/)
React - Part(1)
Tags: beginners, react, codenewbie
Published: 2022-08-26 21:03:00

**What is React?**
- Open Source library for building user Interfaces
- Not a framework
- Focus on UI
- Rich ecosystem

**Why learn React?**
- Created and maintained by Facebook
- More than 100k stars on Github 
- Huge Community 
- In demand skillset

**Component Based Architecture**
- This lets you break down your Application into small encapsulated parts which can then be composed to make more complex UI's.
![React Architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bdzk8czeyk0zrjckzp5.png)

**Reusable Code**
- you could have a component for an article on React the same article can be reused for angular & vue by passing the right data into the article component.
 
![reusability](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xtznidmzkg78apqefgrp.png)

**React is declarative**
- Tell React what you want and React with it's react dom library will build the actual UI this is a declarative paradigm.

> There are two types of paradigm
1. Imperative 
2. Declarative

Let's understand it with a real life example.
Let say you go to an artist you ask them to draw a landscape you don't tell them how to draw it it's up to them this is declarative. (you tell what has to be done and artist will get it done for you)
now the same task you ask of a 5 yrs old child but this time you've to explicitly explain each step draw mountain,river,trees etc.. and best part is that you are in control of flow of landscape that is declarative paradigm. 

- React will handle efficiently updating and rendering of the components.
- DOM updates are handles gracefully in React.

**More on Why React?**
- Seamless integrate react into any of your applications.
- Portion of your page or a complete page or even a entire application itself. 
- React native for mobile applications.

**Prequisites**

- HTML ,CSS and JavaScript fundamentals 
- ES6
- JavaScript - 'this' Keyword,filter,map and reduce
- ES6 - let & const ,arrow functions,template literals,default parameters,object literals,rest and spread operators and destructuring assignments.
- [Node
](https://dev.to/nikhilgautam090696/node-js-2k64)
- [NPM](https://dev.to/nikhilgautam090696/npm-55pl)

Let's get Started 

1. Install [node](https://nodejs.org/en/) on your machine.
2. Install IDE ([Vs code](https://code.visualstudio.com/download))