teleren/devto huggingface dataset:
Question on Contiguous Memory Management | Operating System - M05 P06
Tags: linux, beginners, devops, tutorial
Published: 2020-12-20 07:24:35

**This is a multipart blog article series, and in this series I am going to explain you the concepts of operating system. This article series is divided into multiple modules and this is the fifth module which consists of 26 articles.**

_In this article we are going to see a question based on various allocation methods in contiguous memory management, so we can get a better understanding of the concept._

***Question:*** Request from process are 300 KB, 25 KB, 125 KB, 50 KB respectively, the above request could be satisfied with 

<!-- Image one will come here -->

![Untitled Diagram.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1608448919100/qHXD1IjOl.png)

1. Best-fit but not first-fit
2. First-fit but not best-fit
3. Both 
4. None

***Answer:***
- `(ii)` _First-fit but not best-fit_
- If we allocate process according to the concept of first-fit than all the process will get place, like this 

<!-- Image two will come here -->

![Untitled Diagram (1).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1608448930908/hx3I9fbQQ.png)

- But if we use best-fit concept to allocate the process into the RAM, then the structure of the RAM will look like this.

<!-- Image three will come here -->

![Untitled Diagram (2).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1608448941604/iwMHBkaXh.png)

- Here we cannot put `50 KB` process _(`P4`)_ in RAM due to external fragmentation. This is because in contiguous memory allocation we cannot divide process into different fragments.

_So this was a simple question on various allocation methods in contiguous memory management. Hope you liked it and learned something new from it._

If you have any doubt, question, quires related to this topic or just want to share something with me, than please feel free to contact me. 

### 📱 Contact Me

[Twitter](https://twitter.com/r_mishra10)
[LinkedIn](https://www.linkedin.com/in/rahul-mishra-66210b185)
[Telegram](https://t.me/rahul_mishra10)
[Instagram](https://www.instagram.com/rahul_mishra10/?hl=en)

### 📧 Write a mail
<rahulmishra102000@gmail.com>

#### 🚀 Other links

[GitHub](https://github.com/rahulMishra05)
[HackerRank](https://www.hackerrank.com/rahulmishra10201)
react-reduxify, use simpler reduxify() over the cryptic connect()
Tags: react, redux, reduxify
Published: 2020-12-20 07:23:05

Using redux in React *class components* requires using `connect()` function from [`react-redux`](https://react-redux.js.org/) package.

Example:
```javascript
import React from 'react';
import { connect} from 'react-redux';
import { increment, rate } from '../actions';

class Product extends React.Component {
 // ...
}

const mapStateToProps = state => ({
   likes: state.likes,
   rate: state.rate
})
const mapDispatchToProps = dispatch => ({
   increment: () => dispatch(increment()),
   rate: (value) => dispatch(rate(value))
});

export default connect(mapStateToProps, mapDispatchToProps)(Product)
```

[`react-reduxify`](https://www.npmjs.com/package/react-reduxify) can make this a little simpler.

```javascript
import reduxify from 'react-reduxify';
...
export default reduxify(Product, 'likes,rate', { increment, rate })
```
There's no need to write mapStateToProps and mapDispatchToProps.

## `reduxify` signature:
```javascript
function reduxify(component, neededStates, neededActions, mergeOptions, options) {
...
}
```
Parameters
- `component`: React class component to be reduxified (use some states in redux store in that)
- `neededStates` (*string, array -of string | object- or object*): 
 needed state items from redux store.
- `neededActions` (*object*): needed actions.
- `mergeOptions` (*function*): similar to `mergeOptions` in `connect()`.
- `options` (object): similar to `options` in `connect()`.

String is the simplest form of using `neededStates`. It could be a comma separated list of items with the following format:

`{name?:}{state_key}{=default_value?}`

name and default_value are optional.

Example:
```javascript
export default reduxify(Product, 'count,lang:config.lang=EN,year:config.current_year=2020')
```

This is similar to:
```javascript
const mapStateToProps = state => {
  const props = {
    count: state.count,
    lang: state.config.lang,
    year: state.config.current_year
  }

  if (typeof props.lang == 'undefined') {
    props.lang = 'EN'
  }
  if (typeof props.year == 'undefined') {
    props.year = '2020'
  }

  return props;
}

export default connect(mapStateToProps, null)(Product)
```

More examples at: [**`react-reduxify`**](https://www.npmjs.com/package/react-reduxify) 

`reduxify` has its own cons though. For example it's not possible to use expressions in the neededStates, while this is possible when writing a manual `mapStateToProps` function where you have full control over the `state`.

Comments and suggestions are welcomed.
Daily Reminder
Tags: watercooler, career, itsgoingtobeokay
Published: 2020-12-20 06:23:38

---
title: Daily Reminder
published: true
description: Have the confidence 
tags: watercooler, career, itsgoingtobeokay
//cover_image: https://direct_url_to_image.jpg
---

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ing2yqcs383q5loy2yde.jpeg)
Free Github pro and Perks for Students
Published: 2020-12-20 05:56:47

---
title: Free Github pro and Perks for Students
description: Are you a student? Then you better enroll yourself into getting the Github Student Developer Pack. So many great perks. Find out more about it.
published: true
canonical_url: https://puruvj.dev/blog/get-free-github-pro-and-perks
---
> Read this on my [blog](https://puruvj.dev/blog/get-free-github-pro-and-perks) with dark mode

👋 there! This article is about opening students' eyes about how much perks they can get if they apply for a Github Student Pack.

I am student at the time of writing (December 2020), and just got admission to an engineering college for my higher studies. I very recently applied for the Github Student Pack and got it. One of the happiest day of my life, as now I could use a lot of the paid programmes that I always wanted, for free!!

# What is Github?

Github is an online platform where you can host your code, collaborate on projects, and overall just manage your code really well using the <mark>Version Control System</mark> called [Git](https://git-scm.com/).

Github is based on <mark>Git</mark>, which is a necessity in today's world if you wish to work on code projects in collaboration with other developers, or heck, once you get the hang of it, you will always use it on your personal projects too.

Github is the biggest player out of all the platforms based on Git, and offers damn too many great services and offers.

# Perks for Students, eh?

Yup. Github offers the <mark>Github Student Developer pack</mark>, which is for all the students currently studying under an institution, like a school or university, and doing some engineering related course or work.

> You don't have to be doing a programming course in your college or school to apply. You could be a student in high school or a law university, and still be able to apply for a Student pack.

**And it's 100% free.**

The amount of perks you get from Github Student Pack are just unparalleled and you'll thank yourself in future if you get it now.

According to Github, the value provided by the pack is **12,000 USD** per student 😮.

![Awestruck](https://dev-to-uploads.s3.amazonaws.com/i/j0b0c2q5prj6nmabzwks.gif)

Mind blowing isn't it? It's a great time to be a Student Developer.

You also get Github Pro free in it until you're a student. It gets you the Pro badge on your github profile. I dunno how much good stuff you get from Github Pro, but the badge sure looks great 😉.

Check out [my profile](https://github.com/PuruVJ) to see the pro badge.

# How to get it?

Head over to the website, [GitHub Student Developer Pack](https://education.github.com/pack).

Here you'll find all the perks you get, and register to Github Student Pack here.

This topic is way too big to cover myself, and I suggest you to head over to this Github Blog Post about [Student Developer Pack](https://github.blog/2019-07-30-how-to-get-the-github-student-developer-pack-without-a-student-id/). They have written it better than I ever could ¯\\\_(ツ)\_/¯

Signing off!
Internet Backbone
Tags: webdev, python, javascript, tutorial
Published: 2020-12-20 05:23:17

What if I say - at the end we all connected with Cables...

Yes, the network you are connected maybe wireless but whom you pay for your network is also connected with someone called INTERNET BACKBONE... strange?

All the wires are underground in the Ocean.


![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1608441464357/r6huIfUEv.png)

Why don't you visit on your own to see how internet is connected?

https://www.submarinecablemap.com/
What database should I use?
Tags: help, database, javascript, discuss
Published: 2020-12-20 05:03:14

Hi, so I'm wanting to make a pretty big app but I'm not sure what database to use...

I know there's Mongodb, MySQL, PostgreSQL, and lots more. *My question is*: Which one should I use? What are the pros, and cons of each? Should I use a SQL or nonSQL database? Why would I use one over then other? 

Could someone point me in the right direction? 

BTW I do already know mognodb :)
|YelpCamp| YelpCamp: Adding Basic Styles
Tags: javascript, html, css, webdev
Published: 2020-12-20 04:49:26

---
title: |YelpCamp| YelpCamp: Adding Basic Styles
published: true
description: 
tags: javascript, html, css, webdev
//cover_image: https://direct_url_to_image.jpg
---

                 -A new EJS Tool for Layouts 
                 -Bootstrap 5 Boilerplate 


###A new EJS Tool for Layouts 
The layout is the focus within this section. The goal is to have the ability to include scripts, stylesheets and assets on every single page, without having to duplicate the code. 

ejs-mate creates reusable code that will meet our goal to reduce duplicating code. 

{% github JacksonTian/ejs-mate %}

within the terminal 

```javascript 

npm i ejs-mate

```

Layout is going to allow us to define some boilerplates where we can have code that we insert in between some content. 

```html 
<section> 
  <%- body -%> 
</section> 
```
The body is important for adding content. 


Create a layout folder to put the basic boilerplate template in.

updated index file 
```html

<% layout('../layout/boilerplate')%>
<h1>All Campgrounds</h1>
<div>
  <a href="/campgrounds/new">Add Campground</a>
</div>
<ul>
 <% for (let campground of campgrounds){%>
 <li><a href="/campgrounds/<%= campground._id %>"<%= campground.title <% }%>
</ul>

```

boilerplate template 

```html

<body>
   <%- body %>

</body>

```

the boilerplate template will target all the necessary pages. 



###Bootstrap 5 Boilerplate 

In the boilerplate template is where the bootstrap 5 content will go. 

https://getbootstrap.com/
Ruby iteration shortcut with &(ampersand) operator
Tags: webdev, beginners, ruby, codequality
Published: 2020-12-20 04:16:12

![Ruby logo](https://dev-to-uploads.s3.amazonaws.com/i/pwigrwd2rn9yf3x23ooq.png)

One of the reasons why Ruby is my favorite language is that it has many shortcuts and can do a lot with a few lines of code. `&` (ampersand) operator is one great example.

A quick explanation of how `&` works in Ruby:
```ruby
# These two calls are equivalent:

numbers.select { |number| number.even? }

numbers.select(&:even?)
```
`&` calls the `to_proc` method on the following object which is a symbol `:even?` in the example above. (the `to_proc` method is implemented on symbols.) This means **the object will be encapsulated as a block of code (as a Proc object), and then passed to the given method**.

This might still look weird to you as it did to me in the beginning because `.even?` is a built-in method in Ruby. Why can I use it as a symbol? This works because method names in Ruby are internally stored as symbols. For the same reason, you can use this `&` shortcut for the methods you define as well.

Let's see the examples with Ruby Enumerable that you use everyday:

###1. `find`###
```ruby
# Returns the first admin user

# BAD
def find_admin(users)
  users.find { |user| user.admin? }
end

# GOOD
def find_admin(users)
  users.find(&:admin?)
end
```
***
###2. `select`###
```ruby
# Returns all the admin users

# BAD
def find_admins(users)
  admins = []
  users.each do |user|
    admins << user if user.admin?
  end
  admins
end

# GOOD
def find_admins(users)
  users.select(&:admin?)
end
```
***
###3. `count`###
```ruby
# Returns the number of the admin users

# BAD
def count_admin(users)
  count = 0
  users.each do |user|
    count += 1 if user.admin?
  end
  count
end

# GOOD
def count_admin(users)
  users.count(&:admin?)
end
```
***
###4. `map`###
```ruby
# Returns an array of each user's name

# BAD
def user_names(users)
  names = []
  users.each do |user|
    names << user.name
  end
  names
end

# GOOD
def user_names(users)
  users.map(&:name)
end
```
***
###5. `any?`###
```ruby
# Returns true if at least one user exists.

# BAD
def contains_nil?(users)
  users.each do |user|
    return true if user.nil?
  end
  false
end

# GOOD
def contains_nil?(users)
  users.any?(&:nil?)
end
```
***
###6. `max`/`max_by`###
```ruby
# Returns the oldest user.

# BAD
def oldest_user(users)
  oldest = nil
  users.each do |user|
    oldest = user if oldest.nil? || user.age > oldest.age
  end
  oldet
end

# GOOD
def oldest_user(users)
  users.max_by(&:age)
end
```
***
Knowing this, when you iterate over an array using a block where you simply return `object.method`, you will notice code smells and consider using `&` operator instead.
Why did you decide to study Software Engineering?
Published: 2020-12-20 04:11:33

In the fall of 2015, shortly before I started college I had my first ever real-life exposure to computer programming. One of my friends had somehow blocked some of us from connecting to a wi-fi network we'd been sharing. When asked how he did that he simply replied "code", and showed us a long block of multicolored text on a dark background on his laptop screen. I didn't understand then how he did it, and I still don't understand now, but there's no doubt that experience sparked some interest in me to try to find out what all this "code" talk was about.
Fast-forward two years later in my sophomore year in college, I took two courses in Programming with Visual Basic and MATLAB. At the end of the semester, I built a simple calculator that solved basic petroleum engineering questions when given certain parameters. It wasn't a huge project but I was so excited about it because it only took the click of a button, using the calculator, to get answers whereas solving those same equations manually would've required at least 3 sheets of paper. This is where my interest in computer programming truly peaked and I made the decision to pursue a different career path. I had finally seen first-hand the power of just a few lines of code.
I started taking free online programming courses and even attempted to change my major at a point but that simply wasn't possible. I was told I'd gone too far into my current major(junior year at the time) and I'd have to start all over if I wanted to study computer science. This meant more cost, which I couldn't afford, so I had to just finish my current major and find another way.
As I continued to take free online classes, what began as an interest grew into a passion and I joined Flatiron school upon graduation from college. I aim to become a very solid developer by the time I graduate from Flatiron and also land a very good well-paying job because let's be honest; there's a LOT of dollars to be made in the software engineering job market.
Vanilla JavaScript time of day greeting
Tags: javascript
Published: 2020-12-20 04:06:28

In today's article, we will be looking at how to greet our users based on their timezone.

We will check for three different times and greet accordingly.

- `< 12`: Everything before 12 should say Good morning
- `12-18`: Middle of the day should say Good afternoon
- `> 18`: After 6 pm so say Good evening

It's a cool rather small script that just makes that little bit of extra effort for the end-user.

You can see the end result based on your time in this Codepen.

{% codepen https://codepen.io/rebelchris/pen/zYKZwvG %}

## HTML Structure

Our `HTML` for today couldn't be easier, we can leverage just one div.

```
<div id="greeting"></div>
```

Inside this div, we will place whatever greeting is valid for that time.

## Styling our page

Let's also add some basic styling to our page, nothing crazy, just a quite big centered block.

```css
body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  font-family: Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #ffe6ab;
}
div {
  padding: 2rem;
  background: #06d6a0;
  border-radius: 10px;
  font-size: 3rem;
  color: #fff;
}
```

The center method used is the [Grid absolute center](https://daily-dev-tips.com/posts/css-grid-most-easy-center-vertical-and-horizontal/).

## Vanilla JavaScript time bases greeting

On to the JavaScript part, for this, we need to first get the greeting div.

We use the `documentGetElementById` selector.

```js
const greeting = document.getElementById('greeting');
```

The next thing we need is the current hour for that user.
We can access a new `Date` object and use the `getHours` method.

That will return something like `11` when the time is `11:55` that cool because that's how our greetings will work.

```js
const hour = new Date().getHours();
```

We will also need our three greeting types.

```js
const welcomeTypes = ['Good morning', 'Good afternoon', 'Good evening'];
```

The last part we need is a let to put the text in.

```js
let welcomeText = '';
```

Then we can check if our hour matches certain cases and return the correct line.

```js
if (hour < 12) welcomeText = welcomeTypes[0];
else if (hour < 18) welcomeText = welcomeTypes[1];
else welcomeText = welcomeTypes[2];
```

If the hour is below 12 we return `welcomeType[0]` which is Good morning.
If it's below 18 we return Good afternoon and else we return Good evening.

The final step is to put this welcomeText in our div.

```js
greeting.innerHTML = welcomeText;
```

That it! We now have a fully functional welcome greeting based on the user's time.

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
Solving LeetCode - Remove Element
Published: 2020-12-20 03:41:24

# Question

Given an array nums and a value val, remove all instances of that value in-place and return the new length.

Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

The order of elements can be changed. It doesn't matter what you leave beyond the new length.

Clarification:

Confused why the returned value is an integer but your answer is an array?

Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller as well.

Internally you can think of this:


```
// nums is passed in by reference. (i.e., without making a copy)
int len = removeElement(nums, val);

// any modification to nums in your function would be known by the caller.
// using the length returned by your function, it prints the first len elements.
for (int i = 0; i < len; i++) {
    print(nums[i]);
}
```
Example 1:
```
Input: nums = [3,2,2,3], val = 3
Output: 2, nums = [2,2]
Explanation: Your function should return length = 2, with the first two elements of nums being 2.
It doesn't matter what you leave beyond the returned length. For example if you return 2 with nums = [2,2,3,3] or nums = [2,2,0,0], your answer will be accepted.
```
Example 2:
```
Input: nums = [0,1,2,2,3,0,4,2], val = 2
Output: 5, nums = [0,1,4,0,3]
Explanation: Your function should return length = 5, with the first five elements of nums containing 0, 1, 3, 0, and 4. Note that the order of those five elements can be arbitrary. It doesn't matter what values are set beyond the returned length.
```
Constraints:

* 0 <= nums.length <= 100
* 0 <= nums[i] <= 50
* 0 <= val <= 100


## Let's Go!

Solve by using [PREP](https://dev.to/phariale/prep-technique-for-algorithms-in-js-5b0g).
* **P** - Two parameters. An array of numbers _nums_ & a number _val_
* **R** - Return the length of _nums_ with numbers equal to _val_ removed
* **E** - Examples provided by question. (See Above)
* **P** - See Below

```javascript
var removeElement = function(nums, val) {
    // iterate over nums from last index to 0th
    // remove nums that equal val
    
    //return lengths of nums
};

```

Translate into code...

```javascript
var removeElement = function(nums, val) {
    // iterate over nums from last index to 0th
    // remove nums that equal val
    for (let i=nums.length-1; i>=0; i--) {
        if (nums[i] === val) {
            nums.splice(i,1)
        }
    }
    
    //return lengths of nums
    return nums.length
};

```

### Conclusion

& Remember... Happy coding, friends! =)

#### Sources
* https://leetcode.com/problems/remove-element/
Why Industry Specific Website Design is Important?
Tags: design, websitedesign, industryspecific
Published: 2020-12-20 03:29:35

What is industry specific website design? and why is important?

Industry specific, is customized and designed to fit your business needs. The industry specific website design is fulfil your business activities, lead  viewer become your business target audience, to generated quality lead.

For more details you may inquiry to [PixtureDezign](www.pixturedezign.com). They are expertise on the industry specific website design across Singapore.