teleren/devto huggingface dataset:
Git - Tracking method/function history
Tags: github, git, function
Published: 2021-01-08 12:53:21

The `git log` command helps us to view the information about previous commits occurred in the project. But do you know, you can see the history of any method/function in your codebase easily with:

```bash
git log -L :function:path/to/file
```

A quick example on this command:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/nkkbgmdc0zdutj6keg01.png)

It cannot necessarily handle all the languages, for that, you need to configure the git config correctly in order for git to recognize method/function declarations in that specific language.

I checked for `Golang`, `JavaScript`, `Python` and `C`, it's working without adding any particular language-specific configuration.

Interestingly, if you wish to check the history for some specific number of lines within the file, you can check with:

```bash
$ git log -L :<start>,<end>:<file>
```

You can also pass regex to find anything in your codebase files using:

```bash
git log -L :<regex>:<file>
```

This was originally posted [here](https://stackoverflow.com/questions/4781405/git-how-do-i-view-the-change-history-of-a-method-function)! 💜
Goodeed - DO Hackathon Submission
Tags: dohackathon, webdev, programming, react
Published: 2021-01-08 12:48:50

## 🤝 Goodeed 

A neighbourhood/community platform that allows people to connect, make friends around you and post on what they want to borrow such as tools, games, books or anything that they would want to use probably once. 

### 📋 Category Submission: 

Program for the People

### 📎 App Link

https://goodeed-app-ugrpa.ondigitalocean.app/

### 📸 Screenshots
![Screenshot 1](https://dev-to-uploads.s3.amazonaws.com/i/vgcbiewsietd0q4c81hq.png)

![Screenshot 2](https://dev-to-uploads.s3.amazonaws.com/i/eptaglflhgsvri904xri.png)

![Screenshot 3](https://dev-to-uploads.s3.amazonaws.com/i/n8jeypmcewuy4479sffo.png)

### ✏️ Description

Features for this app includes:
- Post on what you would like to borrow and they'd show up for people who are close to you
- Private message users 
- Comment on posts
- Keep tab of what's borrowed

### 👩🏻‍💻 Link to source code
https://github.com/annacjy/goodeed-app

### 🔒 Permissive License

MIT License

https://github.com/annacjy/goodeed-app/blob/main/LICENSE

## 😎 Background

The idea came about recently when I wanted to do a DIY project and needed a tool or I wanted to play a PS4 game but I only want to only play it once and wouldn't mind if it's a loan. Those were the times I wish I could have one of these apps. 

One of the main features is that the posts shown would be sorted close to you. Real time private messaging is also another important feature although people can comment on posts, perhaps the users wouldn't want to write something for the public to see such as time and place of where to meet etc.

### 💪 How I built it 

I took an opportunity participating in this hackathon to learn an entirely new tech stack and it was definitely worth it. I've been wanting to learn GraphQL for quite some time now so this was a great chance to get my hands dirty.

Deploying to DigitalOcean App Platform has never been easier. DevOps is something that's still rather intimidating to me but this sort of lifts all of the complication and time off a deployment process which is a **HUGE** plus for me. The instructions are also very clear and the CI/CD integration with Github repository works great. I really am a fan of the 1-click deployment which just makes deployment process as simple as it should be.

### 👀 Additional Resources/Info

#### Tech
- Apollo
- GraphQL
- Next.js (React)
- SASS
- Socket.io

#### DB/Cloud storage
- MongoDB Atlas
- Cloudinary
Do you pay for database storage?
Tags: discuss, database
Published: 2021-01-08 12:40:13

---
title: Do you pay for database storage?
published: true
description: 
tags: discuss, database
cover_image: https://blog.capterra.com/wp-content/uploads/2019/05/HEAD-Top_6_Free_and_Open_Source_Database_Software_Hero_no_text.png
---
Data is a significant resource that lies in the heart of almost every business. When the business grows, the data grows too and it's important to have enough storage for it.

Are free plans generous enough for your personal projects or do you pay for the storage space?
Running Rails Console Commands on Terminal
Tags: rails, ruby, linux, ec2
Published: 2021-01-08 12:32:13

Wherever you are unable to run the rails console directly we can use something else. I found that to be helpful since I didn't have admin rights on the EC2 terminal but I had to play with rails console for Staging Environment 

`bundle exec rails runner "_rails command_" -e $(ENVIRONMENT)` 

is that helpful command which helped me in running rails commands for the staging environment. We should definitely avoid using it as much as possible but there are scenarios where playing with rails console is our only choice.

Example commands: 
```bundle exec rails runner "puts Cart.where(tenant_id: 3).destroy_all" -e staging```
Using the Pan Tilt Zoom Camera API
Tags: webdev, javascript, webcam, codepen
Published: 2021-01-08 12:32:10

# What is the PTZ API?
The PTZ Api is an expansion of the Camera API and was added in Chrome version 87, it allows developers to access the pan, tilt and zoom functionality of a webcam.

# That sounds great how do I use it?
Because this API is pretty new you should first check if the browser supports this API.
```javascript
const supports = navigator.mediaDevices.getSupportedConstraints();

if (supports.pan && supports.tilt && supports.zoom) {
  // Browser supports camera PTZ.
}
```

If the browser does support it we should request a user's permission to "Use & move" the camera. You can do this by calling `navigator.mediaDevices.getUserMedia()`.

```javascript
async function requestPTZ() {
  try {
  // First we request permission from the user, if they accept it will yield a MediaStream object
  const opts = {video: {pan: true, tilt: true, zoom: true}};
  const stream = await navigator.mediaDevices.getUserMedia(opts);
  // Secondly we can bind this stream to a <video> element on the page.
  document.querySelector("#video").srcObject = stream;

  // Lastly we want to get the capabilities of our webcam, the current settings of it and the videotrack itself.
  const [videoTrack] = stream.getVideoTracks();
  const capabilities = videoTrack.getCapabilities();
  const settings = videoTrack.getSettings();

  // ...
 } catch (error) {
  throw new Error(error)
  // User denies prompt, or
  // matching media is not available.
 }
}

```

So we now have the ability to view and control a user's webcam, we can now pass arguments to `videoTrack.aplyConstraints` to change the pan tilt or zoom like this
```javascript
async function changeZoom(capabilities, settings, videoTrack) {
  await videoTrack.applyConstraints({
   advanced: [{ zoom: capabilities.zoom.max }]
  })
}

if ('zoom' in settings) {
  changeZoom();
}
```

## Demo
I wrote a short interactive demo on codepen, please note that the embed doesn't work since it required a user to confirm a browser API dialog so please click on the link to [view it on codepen](https://codepen.io/selenecodes/full/JjRBXxb) or [view it on ObservableHQ](https://observablehq.com/@selenecodes/pan-tilt-and-zoom-api).
Problem with UseState 2D array
Tags: react, codenewbie, webdev, javascript
Published: 2021-01-08 12:31:38

I am facing strange behavior with useState. In the sandbox https://codesandbox.io/s/elastic-ellis-gjre7 I have 3 input fields, that change value if you click on them. The problem is with history state, that I log in console. 

Expected behavior is, that as soon as you click on 1 of the boxes, it saves the state of all 3 boxes in history array, when we click another, it adds to history array new placements. 

When clicking 1 box, it works correctly - "History 1" shows placement, and "History 2" and "History 3" are undefined.

But when we click 2nd box, it starts to act strange - It rewrites previously written "History 1", so now the content for "History 1" and "History 2" are the same. Strange, because all we do is concatenate new value to history array, but it overwrites the previous values.

Can anyone explain, why does it act in such a way?
NYC Codecademy Chapter 2021 Welcome Event
Tags: codecademy, event, learn, motivation
Published: 2021-01-08 12:18:34

Hi everyone! I'm the co-leader of the NYC Codecademy chapter and I wanted to share that we are hosting our chapter welcome event today and tomorrow! (exciting 😃). Both events will be online at **3pm EST**. Here's the event info:

---

##### *Welcome to the New York City Codecademy Chapter! Let's welcome the new year with a fun meet and greet event for all chapter members. We will introduce ourselves, talk about our interests, and maybe even brainstorm a bit on the kind of events we will like to host in the future.*


#### Should you attend this event?

##### Whether you are new to the chapter or a recurring veteran, this event will be a great opportunity to meet other chapter members and the chapter leaders and to help come up with ideas for future events.

##### All learners welcomed, domestic and international. At the NYC chapter we welcome members from across the world!

##### **NOTE:** We will be hosting this event both on Friday and Saturday to give everyone a chance to attend. We will cover the same topics so you do not need to attend both unless you really like to hang out with everyone.

---

Here are the links for more info:
[NYC Codecademy Chapter page](https://community.codecademy.com/nyc/)
[2021 Welcome Event (Friday)](https://community.codecademy.com/events/details/codecademy-nyc-presents-2021-welcome-event-friday/#/)
[2021 Welcome Event (Saturday)](https://community.codecademy.com/events/details/codecademy-nyc-presents-2021-welcome-event-saturday/#/)

I'll make it a point to regularly post here all of our future events. I don't know why we haven't done it before but that changes now. And no worries if you can't make it, we host multiple events online every month.
Enough JavaScript to get you Started : #3 Hello JavaScript !
Tags: javascript, webdev, node, 100daysofcode
Published: 2021-01-08 12:11:37

### Enough of Theory 
now that we've learnt enough of the theory , it's now time to write your first JavaScript Program 🎉

### Resources we're Going to use throughout the series

1.  [Chrome Browser](https://www.google.com/chrome/) 

2. [Vs Code - IDE for Writing code](https://code.visualstudio.com/download)

### How to use Developer Tools

👉 Head over to Chrome Browser and type <code>ctrl</code>+<code>shift</code>+<code>i</code>

![browser.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1609866315098/owcgiuAJ6.png)

👉**hey what's this?**

1. the part which is highlighted with red color is known as window which is used for displaying output

1. the part which is highlighted with yellow color is known as developer tools window which offers many functionalities for debugging and performance of web app

1. the part which is highlighted with green color is known as console which is used for seeing errors and responses of JS code , but we're using it for typing JS code , console helps to write code in live environment and throws output in console

👉 take a look at window opened in side , if you want to become a web developer chances are you'll open chrome dev tools on day to day basis for debugging your JavaScript code

### Let's write first line of code

in the dev tools go to console and start typing the following code and hit enter : <br>

```
console.log("Hello John");
``` 

👉 Notice that the part in ""(quotes) is the text we want to print and we can type whatever we want <br> 
👉 log method prints the text which is passes inside ("pass the text here") <br>
👉 **Exercise : Change hello john to hello + your name** <br>

<p>Let me know in comment section if you have any doubt or feedback. it's always worth to give time to thriving developer community :) <br>
<br>
Keep Coding ❤
</p>

#### Hey , Let' Connect👋
 [Twitter](https://twitter.com/codarsh) /
 [Github](https://github.com/WhoAdarshPandya/)
Traditional marketing vs digital marketing: can they work together?
Tags: traditionalmarketing, digitalmarketing, digitalmarketingstrategy, digitalmarketingindustry
Published: 2021-01-08 12:02:22

Reaching out to the people, creating brand awareness and generating leads for the business is always a difficult task. But we all have heard the word marketing many times in our life. Well, to advertise products/services of any particular brand is called marketing. Marketing plays an important role to generate awareness regarding any product or service among the targeted audience.

Today, with the help of digital platforms, it has become relatively easy to reach out to the targeted audience. Before this digital era, there were only limited options to do marketing. But after the arrival of new technologies and the digital platform, it has generated more opportunities for marketing which has overtaken traditional marketing concepts.

<p>With the help of these new digital marketing concepts, one can market their brand globally. Well, let’s check out <a href="https://www.globalvincitore.com/traditional-marketing-vs-digital-marketing-work-together/">digital marketing and traditional marketing</a> in detail and how, by the arrival of digital marketing concepts, the marketing department has taken a new face, all around the world.</p>  

<h2><b>What is Digital Marketing?</b></h2>

Marketing of any brand over social media platforms or digitally via other digital platforms like email marketing, PPC (Pay Per Click) ads, and Google AdWords is called digital marketing. It can also get it as online marketing. Recently, due to the Covid-19, where every other industry had a considerable loss, it has been seen a high rise in the digital marketing industry. 

Today, almost 90% of the population is using social media and making out most of the new digital technologies. However, to get connected directly with the customers today, it has become essential for every brand to be present over the digital platforms and to have digital marketing services. 

<h2><b>What is Traditional Marketing?</b></h2>

Traditional marketing is also known as offline marketing, which we can do without the use of the internet. Well, when the marketing of any brand running through various platforms like newspaper ads, pamphlets, hoardings, TV broadcast, radio broadcasts, banners & other offline mediums is called traditional marketing.

Even today, it is the best option for reaching out to the local audience. Any small brand which wants to create its awareness among the local customers can use traditional marketing options like pamphlet distribution, TV broadcast, Radio broadcast, posters & hoardings for brand promotion. 

For more information, Visit <a href="https://www.globalvincitore.com/traditional-marketing-vs-digital-marketing-work-together/">Global Vincitore</a>  website.
Checking the availability of NVIDIA and AMD Graphic Cards and CPUs
Tags: showdev, startup, monitoring, node
Published: 2021-01-08 11:58:17

The new NVIDIA RTX3070, RTX3080 and RTX3090 Graphic cards have just been released, but buying one is going to be an adventure on its own! Currently there is almost no stock, and if there is, Scalpers who monitor these stocks and steal them from you are going to make your life difficult!

But what if you could play a scalper yourself, and only needed 5 minutes to do so?! Well let me introduce a way on how you can easily monitor these websites yourself and get notified when the stock changes!

Let's start off by loading the[ NVIDIA Website for the Founders Edition card](https://www.nvidia.com/de-de/shop/geforce/gpu/?page=1&amp;limit=9&amp;locale=de-de&amp;category=GPU&amp;gpu=RTX%203080) (I used the German website).

![](https://blog.scraper.ai/_posts/monitoring/checking-availability-of-nvidia-rtx-3080-cards/1.png)

With Scraper.AI we can now easily state that we want to extract the price and details, but also put an interval on how frequently we wish to extract information! So open up the extension and select that you wish to **"Monitor Data"**

![](https://blog.scraper.ai/_posts/monitoring/checking-availability-of-nvidia-rtx-3080-cards/2.png)

The main part will now open up and you will be able to utilize the **Single** mode to select non-repeating content such as the Price, Image and Title of the graphic card.

![](https://blog.scraper.ai/_posts/monitoring/checking-availability-of-nvidia-rtx-3080-cards/3.png)

Once that is done, just specify the interval you wish to extract the data for and select **Finish**

![](https://blog.scraper.ai/_posts/monitoring/checking-availability-of-nvidia-rtx-3080-cards/4.png)

Your data is now being extracted and the dashboard will show up with your extracted record!

![](https://blog.scraper.ai/_posts/monitoring/checking-availability-of-nvidia-rtx-3080-cards/5.png)

Based on the interval specified in the extension (or as you can also see in the **Schedule **section). Your data will now be updated!** A Final thing** to do however, is to make sure that we get notified of changes! So open up the **Notifications **section and fill in your email!

![](https://blog.scraper.ai/_posts/monitoring/checking-availability-of-nvidia-rtx-3080-cards/6.png)

Next time data is updated, you will now be notified of any changes through your email!
🧩 Refactoring by Breaking Functions Apart: a TypeScript Experiment
Tags: typescript, function, programming
Published: 2021-01-08 11:45:49

📚 Learn how to refactor a complex TypeScript function by breaking it into a composition of simpler ones.
[Read more...](https://auth0.com/blog/refactoring-breaking-functions-apart-typescript/?utm_source=facebookgroup&utm_medium=sc&utm_campaign=typescript)
Quickly remove an entry from known_hosts
Tags: ssh, shell, fish
Published: 2021-01-08 11:38:11

---
title: Quickly remove an entry from known_hosts
published: true
description: Remote host identification is cool and all, but for device development, here's a little helper to ease edits of your `known_hosts` file.
tags: ssh,shell,fish
//cover_image: https://direct_url_to_image.jpg
---

Do you SSH to servers a lot? Then this will sooner or later pop up:

```
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
<host key>.
Please contact your system administrator.
Add correct host key in /path/to/.ssh/known_hosts to get rid of this message.
Offending key in /path/to/.ssh/known_hosts:<line>
RSA host key for [ip-or-host]:<port> has changed and you have requested strict checking.
Host key verification failed.
```

This is one of the user-friendlier error messages I've encountered: What went wrong, possible causes, what to do, pointer to the `known_hosts` file/line that caused this.

When you connect to an existing, well-known server that wasn't modified, you should check with your friendly admin or hosting provider – in case someone has actually meddled with your server.

However, my work on IoT devices involves a lot of SSH'ing to local devices, and frequent teardown/re-flash means they get assigned the same IP address/host name as a previous device – but with a different host key. So each time, OpenSSH will issue its dutiful warning above. I don't want to disable strict checking completely or on a per-host basis. Removing the offending line by hand each time gets tedious, but luckily OpenSSL's `ssh-keygen` can take care of this:

```shell
ssh-keygen -R <ip-or-hostname> -f "/path/to/.ssh/known_hosts"
```

Still to much to type on a regular basis. My shell of choice is [fish](https://fishshell.com), so I wrapped this in a function `rmkh` (“remove known host”):

```shell
function rmkh -d "removes a given host from ~/.ssh/known_hosts"
  ssh-keygen -R "$argv" -f "/path/to/.ssh/known_hosts"
end
```

So the next time I get a host verification message, I can just run `rmkh <offending-host-or-ip>` and get on with it. Also works with multiple hosts.

Note: At least inside a fish function, this needs to have the full path to your `known_hosts` file *as a string*, so don't use a tilde and quote everything to be safe.
Difference between call,apply and bind
Published: 2021-01-08 11:27:25

In Object Oriented JavaScript, everything is an object and therefore we can set and access additional properties to functions and methods via the prototype

**Call( )**: The call() method invokes a function with a given 'this' value and arguments provided one by one. This means that we can call any function, and explicitly specify what 'this' should reference within the calling function.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/k8fhwe6drl4kml35ztyp.png)

**Apply( )**: Invokes the function and allows you to pass in arguments as an array.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/p3tvqaq6yuwcvg9yb2mw.png)

**Bind()**: returns a new function, allowing you to pass in an array and any number of arguments.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/kpmd4piznn62kmu8id0e.png)

When we use the bind() method:

1.The JS engine is creating a new *invite* instance and binding *friend1* and *friend2* as its 'this' variable. So basically it copies the *invite* function.

2.After creating a copy of the *invite* function it is able to call *inviteFriend1( )* and *inviteFriend2( )*, although it wasn’t on the *friend1* and *friend2* object initially. It will now recognizes its properties and its methods.

*Call* and *apply* are pretty interchangeable. Both execute the current function immediately. You need to decide whether it’s easier to send in an array or a comma separated list of arguments.  Whereas Bind creates a new function that will have this set to the first parameter passed to bind().

Thank You!