teleren/devto huggingface dataset:
49 Days of Ruby: Day 34 - Ruby and HTTP
Tags: ruby
Published: 2021-04-30 04:19:49

---
title: 49 Days of Ruby: Day 34 - Ruby and HTTP
published: true
description: Join us on a 49 day learning journey through Ruby!
series: 49 Days of Ruby
tags: #ruby
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/9m73qaetuse3nm3y3it8.png
---

**Welcome to day 34 of the 49 Days of Ruby! 🎉**

Today we are going to talk about *HTTP* and how you can build requests in Ruby.

First, what is HTTP?

HTTP stands for *Hypertext Transfer Protocol*. It is a protocol, or a set of conventions, that allows for the fetching of resources. Those resources most notably include HTML documents. HTML is the foundational language of a webpage, and HTTP is the protocol that lets you get it off the Internet.

You are viewing the DEV website right on using HTTP, and this blog post was put together using HTML!

There are other ways to make HTTP requests, though, then just with your web browser. You can do so in your Ruby code!

## Making Ruby HTTP Requests

The library we will use and is standard for HTTP requests in Ruby, is `net/http`. You can find the documentation for it on [ruby-doc](https://ruby-doc.org/stdlib-2.7.2/libdoc/net/http/rdoc/Net/HTTP.html).

At the top of our Ruby file we need to require the library:

```ruby
require 'net/http'
```

Once, the library is required we can begin making requests.

There are different types of requests in HTTP, expressed as verbs:

* POST
* GET
* PUT
* PATCH
* DELETE

Each one of those verbs represents a different type of action you wish to perform. The [Mozilla Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) has some good info on them.

We will build a `GET` request now, and for the rest of today, I encourage you to experiment with the other verbs!

```ruby
uri = URI('https://dev.to/bengreenberg/49-days-of-ruby-day-33-creating-a-ruby-gem-44jc')

page = Net::HTTP.get(uri)

puts page
```

In the above example, we first created a new `URI` using the web address for the blog post from #49daysofruby yesterday. (*A URI is an identifier, or address, for a web resource.*) Then, we made a `GET` request to that `URI` saving the results to a variable called `page`. Lastly, we outputted the results.

Try that in your terminal by starting an IRB session. Make sure, to enter `require net/http` first before you start.

You should see a whole lot of HTML, that's the blog from yesterday!

You just made your first HTTP request in Rub. Congrats!

**Come back tomorrow for the next installment of 49 Days of Ruby! You can join the conversation on Twitter with the hashtag [#49daysofruby](https://twitter.com/hashtag/49daysofruby).**
The second beginning.
Tags: webdev, codenewbie, beginners, programming
Published: 2021-04-30 03:56:37

#I am starting again!!!

 So last year I graduated in March from a Full Stack Coding Boot Camp.  This was literally when COVID hit and instead of pursuing a new job with all that I learned I decided to hunker down where I currently was working because the response from my company was phenomenal.  I felt lucky to have my job and I was feeling appreciated, taken care of, and safe.     

 Now I am at the point where I am beginning my journey all over again to chase my dream of becoming a web developer.  I am excited but nervous.  I feel like I took too long of a break but excited to really start buckling down and getting things rolling.  

 The whole purpose of this post is to motivate myself and hold me accountable on my journey.  I look forward to refactoring all of my code and making things more my style.  I have kept my ear in the game but now it's time to get going.  Let's get to work!

Sincerely, 

_tedorock_
April 29th, 2021: What did you learn this week?
Tags: weeklylearn, discuss, weeklyretro
Published: 2021-04-30 03:53:35

Guess what?

<center>

![Justin Timberlake appearing to say "It's gonna be May!"](https://media.giphy.com/media/P5Q6687ftTdV6/giphy.gif)
</center>

It's that time of the week again. So wonderful devs, what did you learn this week? It could be programming tips, career advice etc.

<center>

![Neo in the matrix having just learnt kungfu](https://media.giphy.com/media/3o7btNhMBytxAM6YBa/giphy.gif)
</center>

Feel free to comment with what you learnt and/or reference your TIL post to give it some more exposure.

{%tag todayilearned %}

And remember, if something you learnt was a big win for you, then you know where to drop it as well.👇👇🏻👇🏼👇🏽👇🏾👇🏿

{% link https://dev.to/devteam/what-was-your-win-this-week-29e4 %}

<center>

![Obama drops the mic](https://media.giphy.com/media/3o7qDEq2bMbcbPRQ2c/giphy.gif)
Flutter Create a Rounded Container with a gradient border
Tags: flutter, gradient, ui, design
Published: 2021-04-30 03:02:30

Recognition where it is due. I got most of this approach from Ankit Dubey from stackOverflow. Though I added how to round the circle. If you find this helpful, please head over to his answer in stackOverflow and upvote him. [Here] (https://stackoverflow.com/a/59964891/7842175)
 
##Your constants file
`final kInnerDecoration = BoxDecoration(
 color: Colors.white,
 border: Border.all(color: Colors.white),
 borderRadius: BorderRadius.circular(32),
);
// border for all 3 colors
final kGradientBoxDecoration = BoxDecoration(
 gradient: LinearGradient(
     colors: [Colors.yellow.shade600, Colors.orange, Colors.red]),
 border: Border.all(
   color: Colors.amber, //kHintColor, so this should be changed?
 ),
 borderRadius: BorderRadius.circular(32),
);`
 
 
 
##Your Widget
 
    `ClipOval(
               clipBehavior: Clip.antiAlias,
               child: Container(
                 child: Padding(
                   padding: const EdgeInsets.all(8.0), //width of the border
                   child: ClipOval(
                     clipBehavior: Clip.antiAlias,
                     child: Container(
                       width:
                           240.0, // this width forces the container to be a circle
                       height:
                           240.0, // this height forces the container to be a circle
                       child: Text(
                         "12",
                         style: TextStyle(
                           fontSize: 200.0,
                         ),
                         textAlign: TextAlign.center,
                       ),
                       decoration: kInnerDecoration,
                     ),
                   ),
                 ),
                 decoration: kGradientBoxDecoration,
               ),
             ),`
Here is your end result 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n0l9tvvms5k7whbpg8qt.png)

Please follow my page to share in this Flutter journey!
Define sinstructor
Tags: oop, vocabulary, watercooler, codequality
Published: 2021-04-30 02:49:28

## sinstructor (n)

Computer code in any object-oriented program that defines new members of an object instance outside of its constructor, resulting in unnecessary confusion and forgotten variables.

```python
class Vehicle:
    # a happy constructor
    def __init__(self, wheel_count):
        self.wheel_count = wheel_count
    # end __init__
# end Vehicle

motorbike = Vehicle(wheel_count=2)

# CAUTION: SINSTRUCTOR AHEAD
motorbike.color = '#ff0000' 
```

```javascript
// a happy constructor (sort of)
function Vehicle(wheel_count) {
    this.wheel_count = wheel_count
}

let motorbike = new Vehicle(2)

// CAUTION: SINSTRUCTOR AHEAD
motorbike.color = '#ff0000'
```

Is this a new term? I derived it by taking **con**structor (with) and switching it to **sin**structor (without).
issue with parallel processing- node -axios
Published: 2021-04-30 02:40:31

Hi we are using axios library to send SMS via a third-party service 
when there are multiple incoming requests the SMS received is very slow 
The third-party API works fine with multiple requests and this is verified by using Jersey client in Java 

Is there an issue with multiple requests with Axios library and what is a more efficient way of handling multiple requests in nodejs 

Code snippet 


exports.mekongSend = (message, to) => {
  var username = "xxxx";
  var password = "xxxx";
  var from = "cmcb";
  var url = 'xxx';
  log(to);
  var data = new FormData();
  data.append('sender', from);
  data.append('username', username);
  data.append('pass', password);
  data.append('gsm', to);
  data.append('smstext', message);
  data.append('isflash', '0');

  var config = {
    method: 'post',
    url: url,
    headers: {
      ...data.getHeaders()
    },
    data : data
  };

  axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
    log(to);
  })
  .catch(function (error) {
    console.log(error);
  });
}
vino@ubuntu
Published: 2021-04-30 01:50:24

install
```
sudo apt install vino
```

show connection uuid
```
nmcli connection show #uuid
```

config
```
gsettings set org.gnome.Vino prompt-enabled false
gsettings set org.gnome.Vino require-encryption false
dconf write /org/gnome/settings-daemon/plugins/sharing/vino-server/enabled-connections "['uuid1','uuid2']"
```

start
```
export DISPLAY=:0 && /usr/lib/vino/vino-server &
```
Refactoring Javascript - [Book Review #1]
Tags: computerscience, javascript, books
Published: 2021-04-30 01:35:27


 Refactoring JavaScript is a book by Evan Burchard, about turning bad code into good code.  Since I am going to delve a little deeper into JavaScript in the upcoming months, I thought I could learn from books that actively use JavaScript examples so that I get more familiar with the language. I am about halfway through the book and would like to give some summary and thoughts before I forget them.

The first few chapters lay out the foundation that refactoring is about improving code quality while preserving existing behavior. The author empathized on the importance of testing and having tools to help verify that the code works as intended. He went on to explain some intricacies of JavaScript and the fundamentals of testing. Though the content could be common knowledge to people who aren't beginner coders, I thought that the intense focus was on point. Quite significant efforts were given to drill the following concept into a reader's mind:
> Avoid refactoring without tests!

Here is a flow chart that the author used to illustrate decisions about test, refactor or implement. You can tell from this diagram that refactoring is a small part of the decision process and it relies heavily on having testing in place.
![coding](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/orhleffy4aob0fwffjmp.png)

Another major discussion in the first part of the book is on understanding functions as six basic components and the author provided some general advice for each of them:
- Bulk 
	- keep lines of code and complexity low in each function
- Inputs
	- could be explicit, implicit or non-local, but prefer explicit over non-local
- Outputs
	- avoid returning a null or undefined, or returning different types of values
- Side effects
	- keep to a minimal or nonexistent
- this: the implicit input to functions
	- have it well-defined when possible
- Privacy
	- it necessarily impacts access in JavaScript

---
Author: Evan Burchard [Author's interesting personal site](https://evanburchard.com/)
Link: [Book PDF](https://refactoringjs.com/files/refactoring-javascript.pdf)
Stop Windows Defender From Scanning Your Source Code
Tags: windowsdefender, guides, windows
Published: 2021-04-30 01:22:17

I was fortunate enough to receive a laptop for development work during quarantine. It works well so far except for one important issue, development work is slow! Turns out it can be difficult to program when the simple act of running visual studio grinds the machine down to a halt. At first I thought it was VS itself, until I opened up the task manager and saw the nightmare pictured below:

![defender-scanning-01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whssjreqn99qk3m8po1j.jpg) 

The root of this problem turned out to be Defender scanning my `c:/src` folder. Y'know, the folder that contains dozens of repositories and tens of thousands of files, many of which containing tens of thousands of lines of text?

"Great!" I thought, "Can I even get around this?" Work computers generally have strict policies to keep them well protected. After attempting to get Defender to ignore my source folder to no avail, I did the next best thing: I grumbled to coworkers hoping they knew of a workaround. Turns out, they did! I was sent [this handy guide](https://docs.microsoft.com/en-us/windows/security/threat-protection/microsoft-defender-antivirus/configure-extension-file-exclusions-microsoft-defender-antivirus#use-group-policy-to-configure-folder-or-file-extension-exclusions) that resolved my issue. Note that you'll need admin privileges to do this. Obligatory: You're responsible for whatever you do with your PC.

The steps from the guide are as follows: In windows search, find and open "Edit Group Policy." Now navigate to Computer Configuration → Administrative Templates → Windows Components → Microsoft Defender Antivirus → Exclusions. Enable it then click "Show" next to Path Exclusions. Add a path under `Value Name` and set `0` as its value. I've added `C:/src` to ignore all source code on my machine.

![defender-scanning-02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a6221i1sx0a5v3f6d27a.png) 

It's been about a month since I've made this change and Defender no longer chokeholds my laptop during dev work. Now about Teams...
How I Use GitHub Actions to Auto-deploy my Vue.js Site to GitHub Pages
Tags: vue, github
Published: 2021-04-30 00:27:19

I've been building a small weather forecast project as a way to learn Vue.js. I reached a point where I wanted to host this project using GitHub pages. I've used GitHub Actions in the past to deploy a few projects I created with Angular and wanted to do something similar with my Vue.js project. I searched for and found an amazing Action, appropriately titled [Vue to Github Pages](https://github.com/marketplace/actions/vue-to-github-pages), in the GitHub Marketplace. It didn't take much to get this process implemented, but figured this post may be helpful to someone out there. Here's how I set up this action.

# vue.config.js Setup
I had already created a vue.config.js file at the root of my project, I just had to this small snippet:
```javascript
publicPath: '/weather-vue/',
```

The value `weather-vue` is the name of my GitHub repository. If you're following along, you'll want to replace `weather-vue` with the name of your repo.

# GitHub Actions Workflow
After updating my `vue.config.js` file, I went my `weather-vue` repo and clicked on the Actions Tab. This is where you can create "workflows". I didn't choose one of the Workflow Templates, instead I clicked the 'set up a workflow yourself' link. I copied the yaml from the [Vue to Github Pages](https://github.com/marketplace/actions/vue-to-github-pages) actions page and pasted it in to the editor. I did have to add my username and my repo name. I also added a couple of environment variables that I have stored as GitHub Secrets. My entire yaml looks like this:
```yaml
name: Build Vue
on: [push]
jobs:
  build_vue:
    runs-on: ubuntu-latest
    name: Build Vue
    steps:
    - uses: actions/checkout@v2
    - id: Build-Vue
      uses: xRealNeon/VuePagesAction@1.0.0
      with:
        username: 'jasonfritsche'
        reponame: 'weather-vue'
        token: ${{ secrets.GITHUB_TOKEN }}
      env:
        VUE_APP_KEY: ${{ secrets.VUE_APP_KEY }}
        VUE_APP_URL: ${{ secrets.VUE_APP_URL }}
```
I added the `env` key to use the two environment variables. Once I was finished with the yaml file I clicked the "start commit" button. This kicked off the workflow.

# Turn on GitHub Pages 
The last thing I needed to do was go to the Settings tab/section in my repo. In Settings I clicked on the Pages section. I found the source dropdown and changed  that to `gh-pages`. It took a little over twenty minutes for my page to be available at the url. 

# Conclusion
This process was made super simple by the developer/s behind the [Vue to Github Pages](https://github.com/marketplace/actions/vue-to-github-pages) action. I had no trouble getting my Vue.js project deployed to GitHub Pages. Now, my page is deployed on every push I make, of course that could easily be changed to be on every merge or some other action instead. 

Thanks for reading this post.
How to get the extension of a file from the path in Node.js?
Tags: node
Published: 2021-04-30 00:00:00

---
  title: How to get the extension of a file from the path in Node.js?
  published: true
  tags: Nodejs
  date: Fri Apr 30 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/get-extension-of-file-from-path-nodejs
  cover_image: https://melvingeorge.me/_next/static/images/main-fafd80ac4b6b667fa3a82dafa16e0cf0.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/get-extension-of-file-from-path-nodejs)
  
To get the extension of a file from a path, you can use the `extname()` method from the global `path` module in Node.js.

For example, let's say you have a path like `myFolder/myFile.txt` from which you need to get the extension of the file. For that, you can pass the path string as an argument to the method like this,

```js
// require path
const path = require("path");

// path string
const pathStr = "myFolder/myFile.txt";

// get the extension of the file from the path
// using the path.extname() method
const extension = path.extname(pathStr); // ".txt"
```

- The `extname()` method returns the extension of the file from the path.
- If no extension is identified from the path the method returns an empty string `''`.

See the above code live in [repl.it](https://replit.com/@melvin2016/get-extension-of-a-file-from-path-nodejs#index.js)

That's all! 😃

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

---
Responsibility without authority is just janitorial service
Tags: teams, authority, ownership
Published: 2021-05-04 16:02:25

---
title: Responsibility without authority is just janitorial service
published: true
date: 2021-04-30 00:00:00 UTC
tags: teams,authority,ownership
canonical_url: https://jhall.io/archive/2021/04/30/responsibility-without-authority-is-just-janitorial-service/
---

A few years ago I was working at a large IT company with a company-wide mantra of “Take ownership!”

I imagine most of us work in such places, regardless of the size of the company. And that’s fine, as far as it goes. I’m sure most of us can agree that proactivity is a good thing.

The problem at this company came in that there was also another policy in place: nobody had authority to make decisions. This was framed as a positive attribute of having a “flat structure”, and there can be merits to that, when done responsibily.

The problem here was that these two, well-meaning policies had a disasterous effect when they operated together, by undermining true “ownership”.

If you’re given responsibility of keeping the office break room tidy, but you’re not allowed to tell people to use a trash can, or put their coffee cups in the dishwasher, you don’t have ownership. You’re just on janitorial dutiy.

The same happens in your technology. Someone tasked with keeping the software deployment working, but without the authority to tell others “don’t merge that broken code” or “don’t upload 57 terabytes of warez to our S3 bucket” is really acting as an IT janitor.

True ownership includes both responsibility _and_ authority.

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Start building rails apps quickly with quickstart-rails-tailwind
Tags: rails, webdev, showdev, productivity
Published: 2021-04-29 23:31:19

This is a base project to quickly spin up a Rails+Tailwindcss application. I'm using it for my rails projects and It helps me to start my new project quickly.

## Heroku Link
[Quickstart](https://quickstart-rails-tailwind.herokuapp.com/)
**Email:** test@test.com
**Password:** 123456

## Github
[Quickstart](https://github.com/MA-Ahmad/quickstart-rails-tailwind)

## Features
- Uses Rails, Tailwind CSS and Webpacker.
- Uses Stimulus and view_component to handle notifications.
- Uses Devise and PostgreSQL.
- Uses Font Awesome.

## Built with

- [Ruby (3.0.1)](https://www.ruby-lang.org/en/)
- [Ruby on Rails (6.1.3.1)](https://rubyonrails.org/)
- [Stimulus (2.0.0)](https://stimulus.hotwire.dev/)
- [Tailwindcss (2.1.2)](https://tailwindcss.com/)
- [View_component](https://viewcomponent.org/)
The State of Serverless Databases in AWS
Tags: serverless, database, aws
Published: 2021-04-29 23:10:20

Databases are a key piece of any service or application, because is where gonna live your most precious assets: your data. Since my post [“Serverless is Ready, Developers are Not”](https://dev.to/aws-builders/serverless-is-ready-developers-are-not-12f9), I talked with a lot of peers about some issues in the space and a lot gravitates around tools and a great deal is about ways to handle data.

## First, we need to talk about Relational Databases and Serverless

Relational Databases and FaaS don’t play nice together by nature: RDS are connection-based, so they should work with a few long-lived clients, such as web servers, not the fast, ephemeral, spike, nature of serverless workloads.

Even with the great latest improvements like [Amazon RDS Proxy](https://aws.amazon.com/rds/proxy/) and cold starts becomes more and more a UX question (depending, of course, of your runtime and use-case).

Still, RDS is the most familiar pattern to handle data and some could say, the “standard” one—NoSQL as a category, describes tools wildly different, since it encompasses all that are *not* SQL, all stacked together. 

Jeremy Daly in **Building Resilient Serverless Systems with “Non-Serverless” Components** on Serverless Days 2020 made a great talk about still use RDS models with FaaS. Is not “easy-peasy” or plug and play, as you can see (I highly recommend this video, is also a crash course on FaaS architectures):

{% youtube coygxBg2wTY %}

So, in this series I’ll experiment with a lot of options available, use-cases, trade-offs and get a hands-on and share my experience here. This is the starting of a series of serverless databases in AWS. I will throw third party offerings in it too, which I can use on AWS. Below is my list. If I’m missing some database or completely getting something wrong—please, let me know!

- [Aurora Serverless](https://aws.amazon.com/rds/aurora/serverless/)

- [DynamoDB](https://aws.amazon.com/dynamodb/)

- [DocumentDB](https://aws.amazon.com/documentdb)

- [ElastiCache](https://aws.amazon.com/elasticache/)

- [FaunaDB](https://fauna.com/)

- [MongoDB](https://www.mongodb.com/cloud/atlas)

- [Upstash](https://upstash.com/) - [Redis: Exploring Redis as Serverless Database to solve idempotence in APIs](https://dev.to/aws-builders/redis-exploring-redis-as-serverless-database-to-solve-idempotence-in-apis-2gma)

- [Route 53](https://aws.amazon.com/route53/)

In the next post in this series I will go over one of these databases, try to use on a use case a little more than “Hello World”—all is shinning and pretty in “Hello World” projects. So, please point me out databases missing, use cases you think I should approach and so on!

-------

{% link https://dev.to/aws-builders/serverless-is-ready-developers-are-not-12f9 %}

_Cover Image by <a href="https://unsplash.com/@jankolar?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Jan Antonin Kolar</a> on <a href="https://unsplash.com/s/photos/database?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>_