teleren/devto huggingface dataset:
Javascript Prototypes DIY
Published: 2021-01-20 22:01:58

##What Are Prototypes?

Javascript prototypes scale up to the global level, and down to individual objects and elements coded into an environment. Global prototypes that come native to JS simply append to this object-oriented structure. Of course, coders can build upon this existing structure with their own prototypes.

So what are prototypes, and why use them?

Prototype methods are functionally the same as non-prototype methods, but, in most cases, prototype methods are the more efficient option. This is because non-prototype methods are copied within every instance of that datatype. The result is higher memory usage.

On the other hand, prototypes are stored as a single instance, thus taking up less memory.

The question of whether or not to use prototypes hinges on how frequently they’ll be accessed. If your method will only be used sporadically, then a prototype is probably the best bet. The native methods of JS also adhere to this approach.

These are (some of) the non-prototype methods for arrays:

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

And here are (some of) the prototypes:

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

## Thinking Globally

In every JS environment, the global Object reigns, and all other complex data types inherit its prototypes. These complex data types themselves are objects, and they have access to their own set of methods and prototypes.


To see this in action, enter Object.prototype in the Dev Tools console.

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

For the global Window object, or any new objects that are created, these prototypes are available.

Now check the global Array prototypes by entering Array.prototypes. You’ll see a set of functions stored under the “proto” label.

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

Look familiar? You can see how the Array object has inherited all of the global Object’s prototypes. Notice these prototype methods are actually all functions. Also, notice how the functions have access to their own folder of global function prototypes.

##Prototype DIY

Understanding this, you can see the functional symmetry between global objects and objects you code into a JS environment. Array methods and prototype methods are simply key/value pairs assigned to the global Array object, and, since they’re stored globally, any arrays you create will be able to access them.

Now we can, say, create a printMoney method that translates any array into dollar signs, and make it globally available for all arrays:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/f1xcfvtcy142c7wey0mo.JPG)
Digging Roots
Published: 2021-01-20 21:39:47

---
title: Digging Roots
published: true
description: 
tags: 
cover_image: https://images.unsplash.com/photo-1547401372-0ac4589c4d3e?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1563&q=80
---

I began re-reading [Seneca](https://www.amazon.com/Letters-Epistles-Seneca-Digireads-Com-Classic-ebook/dp/B00E0VXJ30/ref=sr_1_1) again to great delight! I feel it needs to be read like poetry, lingering on each sentence giving it equal weight and thought by which it was written.

One of the first letters on time affirms my transition to more re-reading and re-writing. The idea that a plant can't take root when constantly shifting. That it's good to get awareness of the new and exotic but need to grow our roots deep to have depth of fulfillment in life.

Personally I love variety. I hardly ever watch a show or movie twice or read a book twice, with a couple exceptions:

I would read Douglass Crockfords "the Good Parts" every year for about four years and observed that every time I read it I would get different lessons from it because my context had drastically changed. In a sense, it wasn't me reading the book again, it was a different person reading the book each time.

The second exception is that my wife and I enjoy watching the entire Harry Potter series over the holidays each year. This is a much different experience but now I can't imagine the holidays without Harry Potter, it's our version of all the tradition around Santa. I've also noticed not matter how many times I watch these films, I'll be surprised by some detail I had forgotten.

The key take-away here is to keep a list of works that you know are high value not only now but will be in the future and dig your roots into this core. 

And if you need a place to start, [Seneca](https://www.amazon.com/Letters-Epistles-Seneca-Digireads-Com-Classic-ebook/dp/B00E0VXJ30/ref=sr_1_1) in my opinion, is a fantastic example.
Updating dependencies (including require-dev) Killed - Composer Error Message
Tags: composer, php, memory, ram
Published: 2021-01-20 21:36:35

If you are facing that error message `Updating dependencies (including require-dev) Killed` when trying to update some library with composer. Then maybe that StackOverflow answer can help you: https://stackoverflow.com/a/34998803

It worked for me. 

It happened on AWS EC2 running Ubuntu.
Animated skill bar using html,css,jquery
Tags: 100daysofcode, javascript, html, css
Published: 2021-01-20 21:24:12

Hi everyone,

I am starting my 100 days of code challenge today.
I am going to create a small functionality or project on daily basis.
# Day 1 - Animated Skill bar
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xixj51esm134l3e4jvx5.png)
 Check the code - [Github](https://github.com/umapreethi-dev/100-days-of-code)
Crash & Build Series: Crash Course on HTML & CSS
Tags: codenewbie, webdev, tutorial, event
Published: 2021-01-20 21:19:52

# The NYC Codecademy Chapter presents:
#### Crash & Build Series: Crash Course on HTML & CSS

![crash and build ONE|500x500, 50%](https://dev-to-uploads.s3.amazonaws.com/i/x3dyilvsv9cu21cbh38j.png)

##### About this event

Don't get stuck in tutorial hell! How many times are you going to re-learn the same lessons over and over again? It's time to sit down, let go of the deadweight and grab the next rung on the ladder. We are going to do away with the details and technicalities and focus on what works and how to put it together to make it work for us.

##### Should You Attend This Event?

YES IF:
* You are new to HTML and/or CSS
* You know a little about HTML and/or CSS but want to learn more
* You are struggling to "put it all together" and work on your own projects
* You want to review the fundamentals

NO IF:

* You are already well-versed in HTML and CSS
* You don't need any help with HTML or CSS
* You are looking for more advanced topics like JavaScript, Front-end Frameworks, etc.


**TIME:** 15:00 EST (that's 3pm NYC time)
**DATE:** Jan 22, 2021 (Friday)

Are you interested in attending? Awesome! Just follow the link to the [Crash & Build Series](https://community.codecademy.com/events/details/codecademy-nyc-presents-crash-build-series-part-1-go-from-zero-to-ready-with-this-crash-course-on-html-and-css/#/) event page and RSVP. We can't wait to meet you all!
GitHub Token : Very Confusing
Tags: github, authentication
Published: 2021-01-20 21:18:30

Just created a new repo and I received an email that stated:

> "Basic authentication using a password to Git is deprecated  and will soon no longer work."

Ok, I've been through this and I've created a token and uploaded it to my GitHub account, but after that I'm 100% unsure how to use the token to login.

## Question
Can someone reply and let me know the steps on how to login via command-line and token to GitHub?  
Or, can someone point me to the steps?  
Here's the [totally confusing document the GitHub team provides](https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/).

## EDIT -- Additional Info
I just found the [following on StackOverflow and I'm reading it now](https://stackoverflow.com/questions/18935539/authenticate-with-github-using-a-token).
Open source alternative to AWS api gateway?
Tags: awsapigateway, aws, discuss, serverless
Published: 2021-01-20 21:08:22

Hi all,
The way we can create rest API using flask in python,I wanted to try making the same the serverless way.A bit of googling suggests to use lambda and api gateway for the end point.Wanted to know is there another way of creating endpoint other than using AWS api gateway like how we create api in flask?
Published Book: Amazon Kindle (Free)
Tags: programming, career, html, javascript
Published: 2021-01-20 21:03:37

I've just [released my book on Amazon](https://amzn.to/35YIZ22).
This is Learn HTML5, CSS, JavaScript Volume 1.
It's 144 pages and is a walk-thru for beginners.
I've listed it at the low price of $2.99.

## Get It Free
If you'll post back here and tell me you'd like a copy for free, I will DM you a link to get a free ebook (kindle (.mobi), .epub or .pdf).

### Let Me Know Which Document Type
When you leave a comment that you would like a link to the book, please let me know which document type you want too: .MOBI, .EPUB or .PDF.

### Chat / Dev.to DM
It looks like to send you the link in a dev.to chat you need to follow me (then I'll follow you) so I can Chat you and send the link privately.  Thanks

![Launch Your Dev Career](https://dev-to-uploads.s3.amazonaws.com/i/ttuhcmb0zwces89vddad.png)

All I ask in exchange is that you write a review at Amazon for the book. 

All the source [code is available at my GitHub repo](https://github.com/raddevus/LaunchYDC). 

Check it out and let me know what you think.
Python Zero to Hero - Ep.32 - Exploring what's in a package
Tags: python, tutorial, beginners, internal
Published: 2021-01-20 21:00:29

---
title: Python Zero to Hero - Ep.32 - Exploring what's in a package
published: true
description: This time we will use the magic build-in function "dir" to explore what's in a package and how python put things in place.
tags: python, tutorial, beginner, internal
---
This time we will use the magic build-in function "dir" to explore what's in a package and how python put things in place. If you have any questions or any suggestions about which Python topics to cover, please leave your comment at my [Twitch channel](https://www.twitch.tv/cheukting_ho)

You can get the slide deck [here](https://slides.com/cheukting_ho) and the example code and homework form [GitHub here](https://github.com/Cheukting/python02hero). Ask questions at my [Twitch channel](https://www.twitch.tv/cheukting_ho)
For the love of Functions!!
Tags: functions
Published: 2021-01-20 20:39:16


As I move forward in my coding journey, you learn more and more. But there is one thing that i learned that is very important. How powerful functions are and how are important it is to know that your function should have one purpose only. Starting off my journey into coding, I thought function wasn't as important. How naive of me!Functions performs a particular task and gets executed when you invoke it/call it. As it says in MDN web docs "Functions are one of the fundamental building blocks in JavaScript, Functions are one of the fundamental building blocks in JavaScript.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/srztkgy3rzvcjokwe7o4.png)

The picture above is a basic function that adds 2 to whatever number you put as the argument. As you can you see on the picture above, we gave our function one purpose only and thats to add 2 to whatever number we put in the function call. 


But there is also functions called high order function. These are functions that returns a function or takes a function as an argument. The main higher order functions that we all know is map, filter, and reduce. We would use these high order functions to solve more complex functions.  Functions can be more complexed like in underbar and recursion.  And thats where I personally and maybe some of y'all start to over think and try to give our functions more purposes. This is an example of high order function called flatten from underbar that is complexed. It flattens a nested array. So if you are an array nested with arrays. The Flatten function should flatten the array into a one-dimensional array.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hnzzcewnyju0l90xty1d.png)
As you can see, I used reduce to take a multidimensional array and convert it to a single array. At first i was using map and filter. All types of craziness. But like Andy said a functions only serves one purpose, so don't overcomplicate it and definitely do not give it more than one purpose. You can break the code.
 

In conclusion, function is our best friend. Functions used to be my worst nightmare. I had  a hard time understanding it during prep. But after practice and studying, I figured out what function is and what does it do. It is our life support in coding, especially javascript. We will make functions for the rest of coding careers. But one main thing we need to understand is that functions should only have one purpose.This understanding will help us in the long run. I know sometimes we can overcomplicate things, thats the journey of coding but we need to remember when it comes to functions, we should not give it more than 1 purpose because if we do we can screw things up. Whenever we get stuck, we need to look back at the basics of a function and remember that every function we make should have one purpose only. Some days will be fun and some days will be like hell. We are in this together. Remember to stay healthy and stay relaxed. You and I will achieve our goal into one day become a software engineer. Good luck with the exam!!!
Explaining RSpec doubles, mocks and stubs in 2 minutes
Tags: rspec, ruby, testing
Published: 2021-01-20 20:35:35

This post is for those who are familiar with RSpec, but do not understand the meaning of "to mock something" or "to stub something". Short, to the point, and with examples.

## Double
A stunt object that substitutes a real system object during tests:

```ruby
describe NotificationsController do
  # The NotificationsController downloads
  # the latest notifications from a third-party service
  # via HTTP call using NotificationsDatasource
  let(:datasource) do
    double(:datasource, as_json: { notifications: [] })
  end

  before do
    # Replace the real NotificationsDatasource with a double,
    # avoiding external depency in the test:
    allow(NotificationsDatasource)
      .to receive(:new)
      .and_return(datasource)
  end

  describe "#index" do
    it "wraps notifications in 'data' key" do
      get :index, format: :json

      expect(json_response["data"].keys)
        .to have_key "notifications"
    end
  end
end
```


## Stub
A stub for a method or object that returns canned value:
```ruby
context "when attachment file is too large to email" do
  let(:max_file_size) { Attachment::MAX_FILE_SIZE }

  before do
    allow(attachment)
      .to receive(:file_size)
      .and_return(max_file_size + 1)
  end

  it "raises 'file is too large' error" do
    # ...
  end
end
```

The attentive reader has already noticed that in the previous example with `NotificationsController` there was a stub, too. That's right: a stub is a double with pre-defined responses.


## Mock
Stub with expectations, which RSpec will check at the end of the test:
```ruby
context "when cloning process cannot be performed" do
  before do
    allow(doctor).to receive(:clone) { raise "can't clone" } # stub
  end

  it "notifies airbrake" do
    expect(Airbrake).to receive(:notify) # mock
    # RSpec will stub `Airbrake.notify`
    # and at the end of this `it do...end` block
    # will check, if it has been called.
    # If it hasn't been called,
    # it would raise an error and fail the test.
    #
    # So when asked at a job interview what's
    # the difference between a mock and a stub, answer,
    # "Only a mock can fail a test."

    clone_poor_dolly
  end
end
```

Mocks change the order of phases in the test. Instead of "Setup — Exercise — Verify" you get "Setup & Verify — Exercise". If you, like me, find this hard to read, use a stub with a check:
```ruby
# mock
it "notifies airbrake" do
  expect(Airbrake).to receive(:notify) # setup & verify

  clone_poor_dolly # exercise
end

# stub
it "notifies airbrake" do
  allow(Airbrake).to receive(:notify) # setup

  clone_poor_dolly # exercise

  expect(Airbrake).to have_received(:notify) # verify
end
```

-------------------------

More on this topic:
* [Mocks Aren't Stubs](http://martinfowler.com/articles/mocksArentStubs.html)
* [Thoughts on Mocking, Part 2](https://www.practicingruby.com/articles/thoughts-on-mocking-2)
* [Thoughts on Mocking](http://myronmars.to/n/dev-blog/2012/06/thoughts-on-mocking)
Php Web Server
Tags: php, tip, desarrollo
Published: 2021-01-20 12:36:18

---
title: "Php Web Server"
description: "Sabían que la línea de comandos de php tiene un servidor web interno."
tags: ["php", "tip", "desarrollo"]
canonical_url: https://marceloandrader.github.io/blog/2021/01/20/php-web-server/
published: true
---

Sabían que la línea de comandos de `php` tiene un servidor web interno.

Me ha servido mucho para realizar desarrollos de prueba o verificar un sitio estático o 
incluso para compartir archivos en una red interna.

El comando es:

```
$ php -S 0.0.0.0:8000 -t www
```

Donde -S indica el host y puerto donde se escuchará las peticiones. 
0.0.0.0 indica abra el puerto en todas las interfaces disponibles
Y -t indica el directorio desde donde se leerá los archivos.

Esto creará un pequeño servidor web, puedes abrir el sitio en [http://localhost:8000](http://localhost:8000) o 
desde otro dispositivo en la misma red http://ip-donde-ejecuto-php:8000

Lo más importante de este tip es que si existen archivos php en ese directorio se ejecutan. El comando `artisan serve` de laravel 
usa este servidor interno.
How to test whenever config
Tags: ruby, rspec, testing
Published: 2021-01-20 20:12:13

I recently made a typo in the [whenever](https://github.com/javan/whenever) (Ruby cron jobs manager) — config:

```ruby
# config/schedule.rb
every 1.day, at: "03:30 am", roles: %i(backupable) do
  rake %( # %( should be %w(
    backup:db
    backup:assets
  ).join(" ")
end
```

It broke deployment pipeline with the following error:
```
NoMethodError: undefined method `join' for "backup:db backup:assets":String
```

To avoid this in the future, we need at least minimal validation of the whenever config. The solution is simple, just run this command on CI:
```shell
bundle exec whenever
```

If there are problems in config, it will return an error. If there are no problems, it will display the resulting crontab.
ArchUnit
Tags: java, codequality, productivity
Published: 2021-01-20 20:11:57

*Hello there!*

This is the first tool I encountered in my search journey and it seems that slowly but surely takes effect while we are focusing only on the business logic of the project.

##[ArchUnit](https://www.archunit.org/)

Its purpose is to help developers ensure an architecture level quality by writing a suite test case to cover all that matters to the project and the team involved.

This library offers great support for newcomers and has different ways to include it in your project based on the JUnit version or an alternative in case there is no JUnit used.
   * [JUnit 4](https://github.com/TNG/ArchUnit/tree/master/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4)
   * [JUnit 5](https://github.com/TNG/ArchUnit/tree/master/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5)
   * [Plain](https://github.com/TNG/ArchUnit/tree/master/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest)

In the above list, you can find, for each option, several Test classes that have specific goals *e.g. CyclicDependencyRulesTest.java* (which I warmly recommend you trying at least)

Also, each of the Test classes has an associated [*Real* Test class](https://github.com/TNG/ArchUnit/tree/master/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example) in which the applied rules are explained.

***
I hope it will help you too, and feel free to come up with suggestions or alternatives. Happy coding!
***

*Stay tuned for the next article in the series!*


> *[Cover photo](https://unsplash.com/photos/iHeX3jWkv9s) by Markus Spiske on [Unsplash](https://unsplash.com/)*
Introduction
Tags: java, codequality, productivity
Published: 2021-01-20 20:11:50

*Hello there!*

I am in a small team of 3 Java developers, including myself, who work hard to finish a complex project which is suitable for 4 or 5 people.

This project has a critical deadline and we are already 1 month behind because of the team availability, and the only thing we can do is to speed things up by reducing time on code reviews and still keeping the code quality and performance, limiting the technical debt.

Therefore, I said to myself, there should be some tools, plugins, or frameworks to use in order to boost a bit our daily work.

Due to this opportunity, I am creating here this series with short but insightful articles to introduce and cover every tool I found and use.

***

*Stay tuned for the next article in the series!*

> *[Cover photo](https://unsplash.com/photos/iHeX3jWkv9s) by Markus Spiske on [Unsplash](https://unsplash.com/)*
Control AWS Costs
Tags: aws
Published: 2021-01-20 20:04:07

Released today, my course 'AWS Cost Control' - updated for 2021 on LinkedIn Learning at https://www.linkedin.com/learning/aws-controlling-cost

In addition, as with the majority of my cloud courses in the LI_L platform, I have created a [companion GitHub Repo](https://github.com/lynnlangit/aws-cost-control) with links, notes and other information for this course.  Repo image shown below

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

For many of my customers the AWS services that result in the highest service costs are EC2, RDS, EMR or S3.  Which services cost your organization the most?