teleren/devto huggingface dataset:
Let's talk about feelings
Tags: eq, management, psychologicalsafety
Published: 2022-12-09 21:41:19

Did you know that the whole "boys don't cry" / "men don't have feelings" adage is just 200 years old? It appeared only in the early 1800s. For thousands of years before that, things like manly tears were a social norm.

Let's talk about feelings.

***

I often ask about feelings: "How do you feel about this?", "Any feelings to share?", "How does it feel when we do this?" I intentionally use the language of feelings, because this way I can learn more than through thoughts and opinions.

Our brains do a good job of storing memories but are not so good at retrieving them. Consciousness gives access to recent memories and some bright events from the past. I'm sure you were in a situation when you knew something, but you just couldn't remember it in the moment.

Emotions come from the whole body of our experience, whether you are asking for it or not. Also, they emerge very quickly, faster than we realize.

E.g. someone mentions a risky deployment before Christmas vacation - and you immediately feel anxious. You go through a particularly unreadable piece of code - and you can feel almost physical discomfort. You haven't even formulated yet what is wrong, but you can name the feeling.

It's like a superpower - your brain throws an immediate answer to any question, but the tricky part is deciphering it. If it's anxiety - what makes you anxious? If it's a feeling of satisfaction - what contributes to that?

***

Tapping into feelings requires some ground work.

You need to create an environment where having feelings is safe.

You need to understand your own emotions and be able to expose them in a safe manner.

You need to show your vulnerability.

You need to have the emotional intelligence to accept others' feelings.

The reward is immense. People can be their true selves and get more fulfillment from work. You also build trust and accelerate communication by dropping formalities. You get access to a deeper level of others' expertise.

There are no useless feelings: fear, uncertainty, anger, annoyance are as crucial as joy, peacefulness, confidence, support. Each emotion is your brain helping you to survive. If you want to get 100% from your team - listen to their feelings.
REST vs GraphQL
Published: 2022-12-09 21:38:55

REST and GraphQL are technologies used to consume APIS. However, each one has their own particularity. This text aims to compare each one of them and provide a short introduction to GraphQL.


**GraphQL**
It is a query language for API, according to your specification. It was developed by Facebook Team to fix problems found in the REST API.

The principles of GraphQL are:

- You receive what you ask for.

Data is returned from the same fields that you request by the GraphQL query, for example:

Query example:

```javascript
query {
  city{
    name
  }
}
```

Query return:

```javascript
{
  "data": {
    "city": [
      {
        "name": "jundiaí"
      },
      {
        "name": "campinas"
      }
    ]
  }
}
```
Data is returned from the same fields that you request by the GraphQL query, for example:

```javascript
const data = {
    city: [
      { id: '1', name: 'jundiaí', state: 'SP' },
      { id: '2', name: 'campinas', state: 'SP' },
    ],
  }
```
The objects have the fields "state" and "id", but if we don't request them in our query, the API will not return them

- You need only one request.

Unlike REST where we need to request with numerous endpoints, in GraphQL only have to do one request.

**REST vs GraphQL**

**Over-fetching:** it's very common to request using the REST API and getting too much unnecessary data and fields returned to us. As we saw, this doesn't happen with a GraphQL query.

**Under-fetching:** we can request from the REST API, but your response may not return the data you need, and because of that, another request to a different endpoint must be made.

Finally, GraphQL has one endpoint. This is a big advantage because REST uses too many endpoints which may be confusing.
SQL Server 2022: Logical Functions - GREATEST & LEAST
Tags: sql, tsql, tutorial
Published: 2022-12-09 17:40:59

Now after SQL Server 2022 released we can test new features of T-SQL
One of the long-awaited innovations is support for the GREATEST and LEAST functions.

This functions returns the maximum (minimum) value from a list of one or more expressions as below.

```
SELECT GREATEST(1, 4, 7, 3, 9);

SELECT LEAST('z', 'a', 'f', 'z', '1');
```
As we can see the functions works with any comparable types. Using different types in same function can cause to error:

```
SELECT LEAST('z', 'a', 'f', 'z', '1', -1);
```

Both functions can be applied to several column within same row:

```
CREATE TABLE Tbl (a int, b int);

INSERT INTO Tbl VALUES (1, 3), (9, 2), (0, 0);

SELECT
    a,
    b,
    LEAST(a, b) least_ab,
    GREATEST(a, b) greatest_ab
FROM Tbl;
```

Test this and other [features SQL Server 2022 on SQLize.online](https://sqlize.online/sql/mssql2022/b23a539193ed8153e4b82f79c4d9aff4/)
Jumphost - Pull Switch Configs with Perl
Tags: perl, network, systems, switches
Published: 2022-12-09 21:20:17

I have a few jumphosts that let I use to ssh into and then access network switches. I used to use rancid and have like 6 rancid instanes...no more. I wrote my own switch backup script. I wont go into the details of my script BUT i thought this ssh trick was worth a look with Perl.

[Net::OpenSSH](https://metacpan.org/pod/Net::OpenSSH) <--Awesome

This snippet of code does a ping check using a Jump Host. This is fairly easy to do using just ssh without Perl. But if I wanted to use Expect, I need Net::OpenSSH instance to pass into it. 

The Modules I use for Expect are: 
[Mnet::Expect::Cli](https://metacpan.org/pod/Mnet::Expect::Cli)
[Mnet::Expect::Cli::Ios](https://metacpan.org/pod/Mnet::Expect::Cli::Ios)
I actually wrap these in a [MCE::Loop](https://metacpan.org/pod/MCE::Loop) to do 10 or so switches at a time. MCE::Loop is always my go to for my loops that need to be sped up. Im pulling 30 switches in under a minute.

I am going to break up this snippet and explain whats going on.

Identify your two ips.
```perl
use Net::OpenSSH;
use Modern::Perl;

my $ip = '192.168.1.2'; #switch ip
my $proxy_ip = '10.90.3.2'; #jump host ip
    
sub pingCheck ( $ip, $proxy_ip) {
```
This example uses a ssh key pair, you can change key_path for password and put the ssh password in.

```perl
    my %opts = (host => $proxy_ip, user => 'myuser', key_path => '/home/myuser/.ssh/id_rsa');
    my $ssh_proxy = Net::OpenSSH->new(%opts);
    $ssh_proxy->error and die "Couldn't establish SSH connection: ". $ssh_proxy->error;

```
Now I run a ping command on the jump host.
```perl
    my @ping = $ssh_proxy->capture("ping -c 1 ".$ip);

    foreach(@ping) {
        if( $_ =~ m/^1\spackets transmitted/ && $_ =~ m/\s0\% packet loss/ ) {
            return 1;
        }
        elsif($_ =~ m/^1\spackets transmitted/) {
            return 0;
        }
    }
}
if(pingCheck()) {
    warn "YES";
}
```

If i needed to access the $ip using a different port instead of ping, lets say it was telnet.

```perl 
$ssh_proxy->system({ssh_opts => ['-O','forward','-L127.0.0.1:8000:'.$ip.':23']});
```

I can then do `telnet localhost 8000` and it will connect to the $ip.

This might be confusing for some, its technical and geared for network engineers that can do programming. If you are interested in how i pull switches, you can ask and i'll hint at how to put something together.
Advent of Code 2022 - Day 9
Published: 2022-12-09 20:31:02

---
title: Advent of Code 2022 - Day 9
published: true
description: I'm trying to solve all the Advent of Code puzzles in this video series.
tags:
cover_image: https://i.ytimg.com/vi/QO0woArbE3E/maxresdefault.jpg
---

{% youtube QO0woArbE3E %}

I'm trying to solve all the Advent of Code puzzles in this video series.
Stackoverflow shut down ChatGPT Threads ...
Tags: ai, stackoverflow, programming
Published: 2022-12-09 20:31:00

Amazing, this thing is hot. I had trouble logging into the openAI site, but finally registered. 

It is quite the conversation piece, in fact it wrote a AzureAD powershell script for me. No crap ..

Check it out if you haven't already. I fear we are only seeing the beginning of AI, competing with Humans ... 

Cheers, Joseph
A Very Basic JavaScript Intro by Dannohh and chatGPT!
Tags: javascript, codenewbie, webdev, mentor
Published: 2022-12-09 20:10:10

Welcome to Dannohh and chatGPT's JavaScript basics tutorial. We'll be your guide through the world of JavaScript.

Before we get started, let's go over what you'll need to follow along with this tutorial. First, you'll need a computer with a text editor installed. We'll be using the browser developer tools in this tutorial, but you're free to use any text editor you're comfortable with. You'll also need a web browser to run our JavaScript code. Any modern browser will do, so feel free to use your favorite.

Now that you have everything you need, let's jump in and start learning about JavaScript.

JavaScript is a programming language that is commonly used to add interactivity to websites. It allows you to create dynamic content that can update in real-time, making your web pages more engaging and user-friendly.

One of the key features of JavaScript is its ability to manipulate the Document Object Model, or the DOM. The DOM is a representation of the structure of a web page, and JavaScript allows you to access and modify its elements. This allows you to create highly interactive web pages that can respond to user input and change in real-time.

Let's try out some basic JavaScript to see how it works. Open up your text editor and create a new file. Save the file as "index.html". This file will be our web page that we'll be working with.

Next, let's add some basic HTML code to our page. Type the following into your index.html file:


```
<html>
<head>
  <title>JavaScript Basics</title>
</head>
<body>
  <h1>Hello, World!</h1>
</body>
</html>
```

This code creates a simple web page with a heading that says "Hello, World!". Save the file and open it in your web browser. You should see the page with the "Hello, World!" heading.

Now, let's add some JavaScript to our page. In your index.html file, add the following code just before the closing </body> tag:
```
<script>
  alert('Hello, World!');
</script>
```
Save the file and refresh your web page in the browser. You should see an alert box pop up with the message "Hello, World!". This is a simple example of how JavaScript can interact with the DOM and respond to user input.

In this tutorial, we've just scratched the surface of what JavaScript can do. There's a lot more to learn, so stay tuned for more tutorials on JavaScript and web development. Thanks for reading!
How I can upload a javascript file using ajax once I resize an image in a manner where $_FILES can be used in php
Tags: javascript, ajax, php
Published: 2022-12-09 19:58:51

In my case, I had to resize an image then uploaded as a normal file. Many sources suggest that in order for this php code to work:

```php
$file = $_FILES['base_img_data'];

if($file['tmp_name']){
  echo "FILE UPLOADED";
  exit;
}

echo "FILE NOT UPLOADED";
```

Needs this form:

```html
<form id="upload_form" method="post" action="..."  enctype="multipart/form-data">
   <input type="file" name="base_img_data" />
   <button type="submit" id="savebtn" disabled>Save me</button>
</form>
```

But according to this stackoverflow [answer](https://stackoverflow.com/a/74747693/4706711) I say NO you can upload using ajax, AFTER you process it.

Read more on Stackoverflow answer.
[AI] How to Use the Twitter API with Ruby
Tags: ruby, twitter
Published: 2022-12-09 19:52:29

Read [this](https://dev.to/aneshodza/i-let-chatgpt-loose-on-devto-here-are-the-results-194p) article to understand why the title has the [AI] at the start.
## Introduction
Are you a Ruby developer looking to integrate your application with Twitter? The Twitter API allows developers to access various aspects of the Twitter platform, including the ability to read and write tweets. In this article, we will provide a step-by-step guide on how to use the Twitter API with Ruby.

## Getting Started
Before we get started, you will need to have a Twitter account and a developer account. Once you have both of these, you will need to create a new Twitter application and obtain the necessary keys and tokens.

### Installing the Twitter Gem
To begin, we will need to install the twitter gem, which provides an easy-to-use interface for the Twitter API. To do this, we can run the following command:
```ruby
gem install twitter
```

### Authenticating with the API
Once the gem is installed, we can use the following code to authenticate with the API:
```ruby
# Import the necessary classes
require "twitter"

# Set the keys and tokens
client = Twitter::REST::Client.new do |config|
  config.consumer_key        = "YOUR_CONSUMER_KEY"
  config.consumer_secret     = "YOUR_CONSUMER_SECRET"
  config.access_token        = "YOUR_ACCESS_TOKEN"
  config.access_token_secret = "YOUR_ACCESS_TOKEN_SECRET"
end
```
In the code above, we first import the necessary classes from the twitter gem. We then set the keys and tokens that we obtained when creating our Twitter application. This allows us to authenticate with the API and start making requests.

### Reading Tweets
Once we have authenticated with the API, we can use the following code to read tweets:
```ruby
# Get the user's timeline
tweets = client.user_timeline("twitter")

# Print each tweet's text
tweets.each do |tweet|
  puts tweet.text
end
```
With this code, we first use the `user_timeline` method of the client object to retrieve the user's timeline. We then iterate over the tweets and print the text of each tweet using the text attribute.

### Writing Tweets
In addition to reading tweets, the Twitter API also allows us to write tweets. To do this, we can use the following code:
```ruby
# Set the tweet message
message = "Hello, Twitter!"

# Send the tweet
client.update(message)
```
Above, we first set the message for our tweet. We then use the update method of the client object to send the tweet. It's important to note that tweets have a maximum length of 280 characters, so make sure to keep your messages short and sweet.

### Conclusion
In this article, we provided a step-by-step guide on how to use the Twitter API with Ruby. We discussed how to authenticate with the API, read tweets, and write tweets. By following the steps outlined in this article, you should be able to easily integrate your Ruby application with Twitter.

Thank you for reading. Happy hacking :)
WhyML - New YouTube Channel for ML
Tags: machinelearning, datascience, deeplearning, neuralnetworks
Published: 2022-12-09 19:50:35

Hi everyone,

I would like to humbly introduce my rather new YouTube channel - [WhyML](https://www.youtube.com/@whyml) - where I discuss mostly about why some things happen in machine learning (e.g. why regularization works, why neural nets are universal function approximators etc). I also post from time to time videos where I explain machine learning topics.

I hope that this channel may help any of you gain more insight into some topics in ML.

Any kind of feedback regarding my content is wholeheartedly welcomed!

Many thanks in advance!

P.S. The first three videos have poor audio quality, sorry for that (added subs for them). :(
Convergent Evolution in Code.
Tags: discuss
Published: 2022-12-09 19:32:07

Convergent evolution is when two different and separate organisms evolve the same mechanism to solve a similar problem. Like wings in insects and birds, or fins in Whales and fish. 

Recently I was explaining to my friend, a JavaScript developer, about a helper function I wrote in Rails that would auto-generate rows on a table given the correct data. Their response was, 

"Congratulations, you have built your first react component" 

Now, I have used react before, but it did not occur to me at all that by building this helper in Rails was akin to building a component in react. So my response was, 

" Did I build a react component, or is it convergent evolution? "

Regardless, it made me wonder, what other pieces of code or way of doing things have we as developers all converged upon, regardless of language or framework?
The productivity dilemma
Tags: beginners, productivity
Published: 2022-12-09 19:29:17

I'll start this article by just saying that the tools that you use do not define how smart you are, and here are my thoughts on that.

I'm in the tech field for almost two years now and always faced this constant internal battle in my head, about using the best tools possible to do my job and be "productive", because of this nonstop sense of "being smart".

As a very "environment driven" person, seeing people use those insane Vim configurations and be super fast with their keystrokes and code editing, using the most riced arch installation possible always drove me insane, I wanted that, it felt powerful, it felt easier to do things and more fun...

Every developer that I saw that fit those patterns felt like the image below.

![The famous Hackerman meme image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m0plxl7yzxdgtk0voikw.png)


It didn't take much time for me to start being overwhelmed by the feeling that I needed something like that for me to actually look like a awesome developer. 

![Image of Michael Jordan with the caption "And i took it personally"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xi48ljwdb7l8n1gkkis.png)

But turns out that the more time passed, I felt even worse, I didn't feel "hyperproductive" and even felt dumb in a sense...

It took too much time to configure a cool environment using things like Vim, minimalist window managers, Arch Linux, and stuff. And every once in a while, things kept breaking and I had to start all over again.

That demotivated me a lot, why wasn't I capable of being that 100x developer with insane hotkeys and Vim motions all the way? Where was the so-called "productivity"?

Recently I Acquired a new MacBook and thus I took the personal mission to do the complete opposite since the macOS cannot be overly customized, I decided to stuck with the most basic things that I could to focus on my job.

Whit this article I hope I was able to tell a cool story about myself as a professional developer and also motivate people that felt just like me in the tech area, you don't need that insane setup, the most incredible Vim configuration, it's okay to use your mouse. 

We just need to feel good and make things work, no matter the tool.
Dirty Chains & Messy Nests
Published: 2022-12-09 18:56:02

Having only recently started the full-time online software engineering course at Flatiron I am by no means an expert in my desired field... yet. However I learned very quickly that you can chain methods together almost endlessly in vanilla JavaScript. That can lead to some atrocious code: 

```
document.createElement('button').innerText = document.querySelector('#input').e.target.value
```
Is one example of getting carried away chaining, that while effective, is not efficient. If you were to do the same code with variables, it looks much cleaner:

```
const myButton = document.createElement('button')
const buttonText = document.querySelector('#input')
myButton.innerText = buttonText.e.target.value
```
Once I got the hang of breaking up my method chaining with variables I developed a new bad habit; making massive functions that did far to much. Typically I would write one function to do almost everything I wanted to accomplish in a feature. That frequently manifested in functions with no parameters, no callbacks, and endless nesting:

```
function doTheThing() {
    let myButton = document.createElement('button')
    let buttonText = document.querySelector('#input')
    myButton.innerText = buttonText.e.target.value
    document.appendChild('myButton')
    myButton.addEventListener('mouseover' () => {
        myButton.innerText = "ready to click"
        myButton.addEventListener('click' () => {
            myButton.innerText = "clicked"
        })
    })
} 
```
That is an absolute mess but could easily be replaced using callbacks:

```
function doTheThing(theThing) {
    let myButton = document.createElement('button')
    let buttonText = document.querySelector('#input')
    myButton.innerText = buttonText.e.target.value
    document.appendChild('myButton')
    myButton.addEventListener('mouseover', onMouseOver(theThing))
}

function onMouseOver(theThing) {
    myButton.innerText = "ready to click"
    myButton.addEventListener('click', onClick(onMouseOver))
}

function onClick(onMouseOver) {
    myButton.innerText = "clicked"
}   
```
Much better!
The Secret Trick to Making Sure Your Users Enter Valid Usernames and Passwords!
Tags: webdev, javascript, programming, css
Published: 2022-12-09 18:48:24

Are you tired of dealing with invalid usernames and passwords? Check out this amazing trick to make sure your users are entering valid information every time!

Using the .trim() method in JavaScript is a great way to ensure that your users are entering valid usernames and passwords. This method removes any leading or trailing whitespace from a string, which can be used to validate user input. For example, if a user enters a username with a space at the beginning or end, the .trim() method will remove it and make sure that the username is valid.

This is especially useful for passwords, as it can help prevent users from entering passwords with extra spaces that could potentially be used to gain access to their accounts. So if you’re looking for a simple and effective way to make sure your users are entering valid usernames and passwords, the .trim() method in JavaScript is the perfect solution! Try it out today and see how it can help you keep your users’ information secure.

```

function validateInput(input) {
  let trimmedInput = input.trim();
  if (trimmedInput.length > 0) {
    return true;
  } else {
    return false;
}
   }
```

The .trim() method can also be used to validate other types of user input, such as email addresses, phone numbers, and addresses. For example, if a user enters an email address with extra spaces at the beginning or end, the .trim() method can be used to remove them and make sure that the email address is valid. Similarly, if a user enters a phone number with extra spaces or dashes, the .trim() method can be used to remove them.