teleren/devto huggingface dataset:
Get Some REST: Server Responses
Published: 2021-01-07 01:26:32

Last week I covered the basics of RESTful architecture on the client side. This week I'll be talking about the server side. 

When a client sends a request to the server, content types are included in the request header. When the server is returning a data payload, it needs to include a content type in the header of its response. 

A client trying to access a resource could look like this: 
```
GET /posts/19 HTTP/1.1
Accept: application/json, text/html
```

And the server response might look something like this:
```
HTTP/1.1 200 (OK)
Content-Type: application/json
```

That brings us to response codes! When a server returns a response it includes a status code that lets the client know whether or not the request was successful. There are a lot of different status codes, too many to remember but here are the most common ones:
```
200 (OK) - Response to a successful HTTP request
201 (CREATED) - Response to an HTTP that successfully created an item.
204 (NO CONTENT) - Response to a successful HTTP request where nothing is being returned in the response.
400 (BAD REQUEST) - Response failed due to improper syntax, excessive size or some other error coming from the client side.
403 (FORBIDDEN) - The client doesn't have permission to access the resource.
404 (NOT FOUND) - The one most people see most frequently. This response says that the server wasn't able to find this resource.
500 (INTERNAL SERVER ERROR) - Blanket error for unexpected failures when more information isn't available.  
```

All HTTP verbs have an expected status code when the request is carried out successfully:
```
GET - 200 (OK)
POST - 201 (CREATED)
PATCH - 200 (OK)
DELETE - 204 (NO CONTENT)
```

and that concludes our high-level overview of REST!
Made Vanilla JS landing page
Tags: webdev, showdev, humor
Published: 2021-01-07 00:45:38

Just for fun, I made a Vanilla JS landing page. I was inspired by this page [here](http://vanilla-js.com/). If you don't know what Vanilla JS is, it's just the plain old JavaScript without any silly frameworks or whatever they use.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/56syo1ni4an8pyi5lrqz.png)
Nodejs setup with Typescript
Tags: node, typescript, webdev
Published: 2021-01-07 00:35:09

Setting up Nodejs and Typescript was a little bit of a hurdle for me at the time i was beginning, but turns out it was way easier than i thought. This is going to help you cover a decent set up to get you going.

Firstly i dont think i need to define both technologies, i assume you already know them before reading this post :), if not head over to [Nodejs.org](https://nodejs.org/en/) and [typescriptlang.org](https://www.typescriptlang.org/) to find out about them, so lets get going.

Navigate to your project root folder and run the following terminal commands
`npm init -y`
After that had initialized a package.json file for you run
`npx tsconfig.json`
let it run the choose the technology you are using which is node
```
? Pick the framework you're using: (use arrow keys)
> react
  react-native
  node
```
When that runs finish it automatically generates a suitable tsconfig.json file for your node project.
After that you would need to install some dev dependencies
`yarn add -D @types/node typescript`
or
`npm i @types/node typescript -D`
these are basic dependencies node needs to run typescript.
After that add the following scripts to your package.json file.
```
"scripts": {
   "start": "node dist/index.js",
   "watch": "tsc -w"
},
```
The dist folder is produced with your compiled javascript by tsconfig when you run the watch command on your typescript file.
Create a typescript file in your root and run `yarn watch` or `npm watch` then also run the start command `yarn start` or `npm start` and watch tsconfig compile your typescript file to javascript in the dist folder.

I hope i helped, goodluck :).
Digital Ocean Hackathon App: details and final touches
Tags: dohackathon, hackathon, digitalocean
Published: 2021-01-07 00:14:25

---
title: Digital Ocean Hackathon App: details and final touches
published: true
description: Adding functionality to the app.
tags: dohackathon,hackathon,digitalocean
//cover_image: https://direct_url_to_image.jpg
series: Digital Ocean + DEV hackathon
---

Today has been a heck of a day. Too many things going on, and the last thing I want to do is post about [the app](https://dwindled-plzb3.ondigitalocean.app/). But this post was mostly written already, and I told myself I'd track progress daily, so here it goes.


## New dictionaries

Finally added some of the dictionaries mentioned yesterday, and some more:

- Sports: including basketball, cricket, soccer, some boxing, formula 1...
- Emojis: some of the emojis in text form will be translated into images.
- English language: contractions to shorten words.

Actually, I really like the idea of using emojis. It adds a pinch of color and fun to the app:

<figure>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/p788u8n0p90pl3z1qh1m.png)
<figcaption>Emojis!</figcaption>
</figure>

Emojis are changed the last. Which doesn't mean much... until we explain one more functional change...

## Change in the basic functionality

So far, the app did replacements until it reached the 280-character limit, then it stopped. This preserved most of the original message but also presented some issues (mainly: why was this word changed and not this other one?)

The decision to do that was rooted in the idea that users couldn't pick between the original and the new term. But now they can, so there is no real reason to keep it.

Initially, I removed it, but then we added some options and brought it back, **in an optional way**.

The options also allow users to pick which categories will trigger replacements and which ones won't. By default all will be checked.

Finally, there is a language option. It is a dropdown with a single value at the moment: "English." I may expand it to other languages soon (at least Spanish) This could be an option to apply deeper monetization changes.

<figure>
![Screenshot of Dwindle with the options open](https://dev-to-uploads.s3.amazonaws.com/i/3b6ipm6yx341mzgslu9v.png)
<figcaption>Emojis!</figcaption>
</figure>

Another thing stopping the languages is how I structured the dictionaries: not the best way. It will require some core changes to allow multiple languages without duplicating content.

## Digital Ocean

Yesterday there was a small hiccup with Digital Ocean and the site was offline for 2-5 minutes. Nothing too bad for me... my only regret is to not have set a downtime alert (I don't think there's one) so I could have tested that functionality.

---

## Summary of the day

Some positives:

- New dictionaries
- Added more details to the readme
- Options!

Some not-so positives:

- App only works in English and the dictionaries structure is not generic enough to support multi-language
- 3 days left!
The Surprising Case of `gets` in Ruby
Tags: programming, ruby, gets
Published: 2021-01-16 19:46:26

---
title: The Surprising Case of `gets` in Ruby
published: true
date: 2021-01-07 00:00:00 UTC
tags: programming,ruby,gets,programming
canonical_url: https://jsrn.net/programming/2021/01/07/gets-in-ruby.html
---

`gets` is seen is basically every introductory Ruby tutorial, but they rarely tell the whole story.

You’ll be told to write something like this:

```ruby
#!/usr/bin/env ruby

puts "What is your name?"
your_name = gets.chomp
puts "Hi, #{your_name}!"

```

Confusingly, if this is in a script that takes additional command line arguments, you may not see “Hi, Janet!”

If you execute `./gets.rb 123` you will pretty quickly be greeted by the following error:

```
./gets.rb:4:in `gets': No such file or directory @ rb_sysopen - 123 (Errno::ENOENT)
```

The tutorial didn’t warn you about _this_. The tutorial is giving you a reduced view of things that may, if you’re like me, leave you scratching your head several years later.

`gets` doesn’t just read user input from $stdin. `gets` refers to [Kernel#gets](https://ruby-doc.org/core-2.7.0/Kernel.html#method-i-gets), and it behaves like so:

> Returns (and assigns to $\_) the next line from the list of files in ARGV (or $\*), or from standard input if no files are present on the command line.

If you really, truly want to prompt the user for their input, you can call `gets` on $stdin directly. And who wouldn’t, with a user like you?

```ruby
your_name = $stdin.gets.chomp
```
How to disable the resize functionality of the textarea tag in HTML?
Tags: html
Published: 2021-01-07 00:00:00

---
  title: How to disable the resize functionality of the textarea tag in HTML?
  published: true
  tags: HTML5
  date: Thu Jan 07 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/remove-resize-functionality-textarea-tag-html-css
  cover_image: https://melvingeorge.me/_next/static/images/main-310e706dba268bf846757ab47614a2ec.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/remove-resize-functionality-textarea-tag-html-css)
  
To remove the resizing functionality of the `textarea` tag, you can use the CSS and set the `textarea` tag's `resize` CSS property to `none`.

Normally when you define a `textarea` tag in HTML, you will get a symbol or icon to resize the text area like this,

![Textarea tag resizing button](https://dev-to-uploads.s3.amazonaws.com/i/0f9y5zo3r6vrgemfvvaa.png)

But in some cases, we may need to disable that feature. For example, while designing a custom `textarea` box.

This can be done in CSS like this,

```css
textarea {
  resize: none;
}
```

Now you won't be having that icon to resize anymore.

![Textarea tag resizing button removed](https://dev-to-uploads.s3.amazonaws.com/i/p9goognyblq5xbpn7507.png)

See this example live in [JSBin](https://jsbin.com/tozebicige/2/edit?html,css,output).

That's it! 🌟

### Feel free to share if you found this useful 😃.

---
Day 282 : This is America
Tags: hiphop, code, coding, lifelongdev
Published: 2021-01-06 23:54:15

_liner notes_:
- Professional : Day started off good. Got up early to take part in a talk prep session. I tested out the code I wrote yesterday and then updated the docs. Made a Pull Request to the repo. Set up an Angular project and got my Web Component in it. Took a break to watch Congress debate the validity of the Presidential Election, then..... some domestic terrorists ran up into the Capitol Building. Mind you, in the summer, in the same area, the police brought out the horses, flash bang grenades, rubber bullets, riot gear and tear gas to use on a peaceful protest against police brutality. But today, they let these people get into a government building. Sounds about right. This is America.

- Personal : Last night, pretty much was finishing up some work and watch the Georgia Senate race and fell asleep.

![Above the clouds in Ho Chi Minh City, Vietnam](https://dev-to-uploads.s3.amazonaws.com/i/qd16f7g17xqll2qugmql.jpg)

Yeah, not sure if I'm going to do anything else besides what this ish show of a country unfold.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube VYOjWnS4cMY %}
DAY 3 of building the Higher Order Functions in Javascript. the find Higher Order Function.
Published: 2021-01-06 23:19:45

Hello  community,

today we will be implementing the find Higher Order Function.

    //find function
    /********************
     *@_find prototype is a javascript higher order function   that returns the first value that mets the condition i.e it takes it out of the prepended array because tnen its no more a  collection but rather just a singular value
     *@_find takes in a callback function
     *@callback: the callback takes in the finded value,index     of the finded value,the array
     *@author: Emmanuel Onah
     ********************/

    Array.prototype._find = function(callback){
      for(let i = 0; i < this.length;i++){
         const expectedValue = callback(this[i],i,this);
  
         /*if the index is found i.e expected value exist in   the array, then return it and break        out.Note: i did not  use the break keyword because it will then be redundant in the   scope of return keyword but outside the scope of return  keyword you can use the break keyword.
          */
           if(expectedValue){
              const indexOfExpectedValue =     this.indexOf(this[i]);
       return this[indexOfExpectedValue];
       }
     }
     //if user computation is invalid, then lets just return   the function operation.
     return;
    }

    const names =  ["Jerry","Jude","Joe","CreativeDams","SashaBlanca"];
    //test
    const newValue = names._find((name,index,names)=>name.length > 3);
    console.log(newValue);

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

[Day 1: the map array prototype](https://dev.to/emmanuelonah/day-1-of-building-the-higher-order-functions-in-javascript-the-map-higher-order-function-4b17)
[Day 2: the filter array prototype](https://dev.to/emmanuelonah/day-2-of-building-the-higher-order-functions-in-javascript-the-filter-higher-order-function-56ld)
[Day 4: The reduce prototype](https://dev.to/emmanuelonah/day-4-of-building-the-higher-order-functions-in-javascript-the-reduce-higher-order-function-643)
Intro to Data Structures Part 2, More Array Techniques 
Tags: javascript, beginners, array
Published: 2021-01-06 23:16:30

**Intro**

In my last blog we went over how to store and access arrays. We also learned some simple techniques to add and remove items from the beginning and end of an array. In this article we will look at some more advanced array manipulation techniques

**Removing Items Using splice()**

Previously we learned how to remove items from the end of an array with 'pop()' and the beginning of an array with 'shift()'. But what if you want to remove items from in-between the beginning and end of an array? Or what if you want to remove more than just one element at a time? This is where we use 'splice()' which allows use to remove any number of consecutive elements from anywhere in the array.

Splice can take up to three parameters but for this removal lesson will will focus on two parameters. The syntax for 'splice()' with two parameters is as follows: 

```
array.splice(index, howmany)

// index is where you want to start the splice
// howmany is how many item you want to remove
```

For an example lets look at using `splice()` to remove some fruit from our array:

```
let myArray = ["Banana", "Orange", "Apple", "Mango", "Kiwi"];


let newArray = myArray.splice(2,1)

console.log(newArray) // [ 'Apple' ]
console.log(myArray) // [ 'Banana', 'Orange', 'Mango', 'Kiwi' ]
```

As you can see from our example above `splice()` can also be use to create a new array with the removed items.

**Adding Items Using splice()**

In our previous lesson we removed items using two parameters. Using a third parameter you can add items using `splice()`. Here is the syntax for adding items:

```
array.splice(index, howmanytoremove, items to add)
```
Here is an example of removing items from an array and adding a few items in their place:

```
let myArray = ["Banana", "Orange", "Apple", "Mango", "Kiwi"];

myArray.splice(2,1,"Blackberries","Strawberries")

console.log(myArray) // [ 'Banana', 'Orange', 'Blackberries', 'Strawberries', 'Mango', 'Kiwi' ]
```

**Copying an Array using Slice()**

In our previous lessons when using `splice()` we modify the original array. Using `slice()` we can copy an array leaving the original array intact.

`slice()` only takes two parameters, the first is the index where the extraction begins and the second is the index where to stop the extraction. One key thing to remember is for that second number the extraction will occur up to but not including that element. Let's look at an example: 

```
let myArray = ["Banana", "Orange", "Apple", "Mango", "Kiwi"];
let myNewFruit = myArray.slice(1,3)

console.log(myNewFruit) // [ 'Orange', 'Apple' ]

console.log(myArray) // [ 'Banana', 'Orange', 'Apple', 'Mango', 'Kiwi' ]
```

Notice in the example above we created an new array without changing the original.

**Conclusion**

Now we know how to remove and add items to any part of array. In our next lesson we will take a look at some more array manipulation techniques.
Quick Tip: Reversing a string in Python
Tags: python, beginners
Published: 2021-01-06 23:04:26

---
title: Quick Tip: Reversing a string in Python
published: true
description: How to easily reverse a string in just ONE line of code
tags: #python #beginners
---
You can easily reverse a string in python like this:

```python
print("Hello"[::-1])
```

This syntax reverses the string by converting it to an array (in python strings are actually arrays of characters) and then slicing it The syntax for the array slicing is as follows: ``[start:end:step]`` where empty start means 0 and empty stop means the length of the array. So [::-1] means to slice the array from the 1st element to the last element in reverse order.
Web APIs bastante útiles
Tags: javascript, webdev, beginners, discuss
Published: 2021-01-06 22:43:30

Existe una gran cantidad de Web APIs que nos permiten implementar funcionalidades increíbles en nuestras aplicaciones.

En este artículo comentaremos algunas que en algún momento podrías necesitar.

###Web XR Device API###

Se consideran un grupo de estándares que dan compatibilidad para acceder a dispositivos de realidad virtual (VR) y realidad aumentada (AR) incluyendo los sensores. Todo esto desde un sitio o aplicación web. Algunas de las funcionalidades que nos ofrece son:

- Encontrar dispositivos de salida para realidad virtual o aumentada que sean compatibles.
- Renderizar una o varias escenas 3d en el dispositivo a una velocidad adecuada que no afecte la experiencia del visitante.
- Reflejar la salida de una pantalla 2D.
- Crear vectores que representan los movimientos de los controles de entrada.

###Vibration API###

Esta increíble API permite que un sitio web pueda acceder al hardware de vibración y que el dispositivo se mueva o vibre. Es bastante útil para enviar notificaciones o algún tipo de interacción física con el usuario. A un nivel avanzado, podemos incluso controlar el patrón de vibración del dispositivo.

###Notifications API###

Bastante usado en las PWA (Progressive Web Application), permite que nuestro sitio web controle las notificaciones del dispositivo. Algo importante es que estas son independientes, quiere decir que se pueden mostrar incluso estando en otra pestaña o aplicación.



No hay duda que estas Web APIs nos permiten llevar nuestras aplicaciones al siguiente nivel. Todo depende de las funcionalidades que necesitemos y el nivel de interacción que deseamos tener con el usuario :)
Create a slug from a string Lavavel 8
Tags: laravel, php
Published: 2021-01-06 22:28:19

So as normal I blog on topics I had to research and then pop them here for my reference and if you are reading this then its fantastic! 

So I wanted to create a slug from a string in laravel and it was quite easy to do actually. So here we go. 

We have a simple blog controller taking some request objects.

```php
public function put(Request $request) {

        $article = new Blog;
        $article->title   = $request->input('title');
        $article->article = $request->input('article');
        $article->slug    = Str::slug($request->input('title'), "-");

        

        $article->save();

        $data = [
            'status' => 200,
            'data'   => 'Blog post created successfully'
        ];

        return response($data);

    }
```

The line you want to concentrate on is 

```php
$article->slug    = Str::slug($request->input('title'), "-");
```
This line uses a laravel helper function to take a string value and turn it to full lower case, and then add a - where a space exists. You can change that to be anything you wish. 

At the top of our controller if you add 
```php
use Illuminate\Support\Str;
```
That will pull in the required file that the helper function uses and should work like a dream.

Its as easy as that! Simple fast and slugging along!
The Right Programming Language can make a big difference
Tags: programming
Published: 2022-10-25 23:41:41

---
title: The Right Programming Language can make a big difference
published: true
date: 2021-01-06 22:27:10 UTC
tags: programming
canonical_url: https://www.ericsbinaryworld.com/2021/01/06/the-right-programming-language-can-make-a-big-difference/
---

Recently I came across this video where a programmer solves the same problem in 6 different programming languages:

<iframe loading="lazy" title="1 Problem, 6 Programming Languages (C++ vs Rust vs Haskell vs APL vs Clojure vs Scala)" width="640" height="360" src="https://www.youtube.com/embed/MKb4WD6mioE?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

What’s incredibly beautiful are the Haskell and APL solutions. Whereas every other language requires multiple lines, Haskell solves the problem in just one line. And APL is just a few symbols.

Here’s the same guy solving a problem from the Leetcode challenge in a few languages. Once again, it’s pretty neat how the elegance of the solution varies across languages:

<iframe loading="lazy" title="Leetcode 138 Problem 1 - Height Checker" width="640" height="360" src="https://www.youtube.com/embed/i-KWz4ZHwFk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

I also came across some beautiful examples of code, particularly Haskell as coders shared their solutions to this year’s Advent of Code. I was shocked as I had never realized just how different the solutions could be across languages.

Of course, the problem is that if you really wanted to make the best use of this, your programmer core would need to consist of experts in many different programing languages. Any Turing Complete programming language can solve any other’s problems, so it’s somewhat of a waste of resources to employ such a diverse programmer pool, but it’s still neat to think of a world where each problem is solved by the perfect language for that problem type.
Layanan RINarxiv adalah untuk …
Tags: rinarxiv, preprint, postprint
Published: 2021-01-06 22:17:06

Maaf. Makalah anda belum dapat kami tayangkan. Layanan RINarxiv adalah untuk:

1. Makalah ilmiah lengkap yang belum dikirimkan ke jurnal/panitia seminar.

2. Makalah ilmiah lengkap yang sudah dikirimkan ke jurnal/panitia seminar dan sedang menjalani peninjauan sejawat.

3. Makalah ilmiah lengkap yang sudah menjalani peninjauan sejawat tapi belum terbit.

Salam,

Dasapta Erwin Irawan (inarxiv.id)