teleren/devto huggingface dataset:
tips for python short code part-1
Tags: python
Published: 2021-09-24 19:27:58

1- appending an element to a list:
```py 
k+=[1] #same as k.append(1)
```
2- get multiple lines of from stdin:
#instead of 
```py 
k=[input() for i in range(number_of_lines)]
```
#do
```py 
k=[i.strip() for i in open(0)]
```
3- making a class:
there is multiple modules that have ready porpused classes and types to inherit from or use
# usual class
```py
class paper:
    def __init__(self,nl,*lines_):
       self.numberOf_lines = nl
       self.lines = lines_
```
# dataclass 
```py
from dataclasses import dataclass
@dataclass
class paper:
    lines: list
    numberOf_lines: int
```
. . .
this libraries will help u make a readable classes with less characters and awesome features(compareablity , readable representaiton ...)
4- string manipulation:
```py
k = "abcdef-ABCDEF-123456"
print(k[1:])  #  bcdef-ABCDEF-123456
print(k[:-1]) # abcdef-ABCDEF-12345
print(k[2:-2])#   cdef-ABCDEF-1234
print(''.join(filter(str.isupper   , k))) # ABCDEF
print(''.join(filter(str.islower   , k))) # abcdef
print(''.join(filter(str.isnumeric , k))) # 123456
print(*map("".join,zip(*k.split("-")))) # aA1 bB2 cC3 dD4 eE5 fF6
print(*[k[:i] for i in range(len(k))]) # all substrings "a ab abc abcd abcde abcdef ..." 
```
5- code golfs:
#Bi-Output:
lets asume you have to write "odd" if an input is odd and "even" if not
the first thing that come to mind is:
```py
n = int(input())
if n%2==1:print("odd")
else:print("even")
```
this code is 58 cahracter long
with a bit of python wizardry
```py
print("odd"if int(input())%2else"even")
```
from 58 char to 39
but we can do more
```py
print("eovdedn"[int(input())%2::2])
```
from 58 to 35 char
#function name is repeated a lot
```py
x,y = map(int,input().split())
names = input().split()
fathers = input().split()
mothers = input().split()
age,shoe_size = map(int,input().split())
weight,height,arm_length = map(float,input().split())
```
228 char long
we notice that "input().split()" is repeated to many times
solution:
```py
k=lambda:input().split()
x,y = map(int,k())
names = k()
fathers = k()
mothers = k()
age,shoe_size = map(int,k())
weight,height,arm_length = map(float,k())
```
just like that we saved 47 characters, this example is made for explaining purposes , you can apply it to any repeating funtion or statment with long enough characters. but what i recommend in cases like this is to use stdin file(you can access it with 'open(0)' statment) and dicts to store input
Don't Sweat It - You Got This! 5 Repos To Prepare You For Technical Interviews  
Tags: codenewbie, interview, career, github
Published: 2021-09-24 19:27:51

Hello, job searchers!

Here are some GitHub repos to improve your technical interviewing skills:

**Front-End**
https://github.com/dexteryy/spellbook-of-modern-webdev
https://github.com/yangshun/front-end-interview-handbook

**ReactJS**
https://github.com/sudheerj/reactjs-interview-questions

**JavaScript Algorithms**
https://github.com/trekhleb/javascript-algorithms

**Python Algorithms**
https://github.com/TheAlgorithms/Python


With so many of us in the industry looking for new jobs and going through tough interviews right now, please consider leaving a comment with a link to your favorite resources. 

We're all in this together and I guarantee you can help at least 1 other person.
[pt-br] Acessando keycloak via Spring Netflix Zuul
Tags: springzuul, java, keycloak
Published: 2021-09-24 19:12:23

## Introdução

Olá pessoal!

Hoje eu vou escrever sobre um problema que estava tendo entre o [Spring Netflix Zuul](https://spring.io/projects/spring-cloud-netflix#overview) e o [keycloak](https://www.keycloak.org/)

## O problema entre o Zuul e o keycloak 

O que estava ocorrendo era o seguinte.

Devido a um cliente, precisamos fazer com que o keycloak fosse acessado externamente via o nosso gateway.

Porém ao fazer os testes, acessando essa tela de login do keycloak

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0wwyvr14nrb93dovr5f9.png)  

Via o zuul e após informar o *username* e *password* estava recebendo o seguinte erro

![spring-zuul-keycloak-problem](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/op8xzw23m61th6muzt1a.png)

Porém não ocorria erro no container do zuul e nem do keycloak. O único erro que ocorria, aparecia no console do navegador, mas era apenas um erro 400 e mais nada.  
 
## O que fiz para solucionar

Pois bem, como pesquisando na internet não havia achado nada, fui para documentação do spring na parte [9.4. Cookies and Sensitive Headers](https://docs.spring.io/spring-cloud-netflix/docs/2.2.9.RELEASE/reference/html/#cookies-and-sensitive-headers)

Nessa parte mostra que, por padrão, a *sensitveHeaders* há três valores: *Cookie,Set-Cookie,Authorization*, como mostra o exemplo da própria documentação:

application.yml
```
 zuul:
  routes:
    users:
      path: /myusers/**
      sensitiveHeaders: Cookie,Set-Cookie,Authorization
      url: https://downstream
```

E na explicação abaixo, mostra o que fazer caso alguma rota precise dessas informações.

>The sensitiveHeaders are a blacklist, and the default is not empty. Consequently, to make Zuul send all headers (except the ignored ones), you must explicitly set it to the empty list. Doing so is necessary if you want to pass cookie or authorization headers to your back end. The following example shows how to use sensitiveHeaders:

E foi isso que precisei fazer no meu application.properties, deixei conforme a documentação

```
zuul.routes.auth.sensitive-headers=
```

## Atualização
Quando você for tentar efetuar o login, e no console do navegador estiver apresentando esse erro:

```
Refused to display 'http(s)://host:port/' in a frame because it set 'X-Frame-Options' to 'deny'.
```

Vá nas configurações do seu Spring security e no método 

```
protected void configure(HttpSecurity http) throws Exception
```

Adicione a linha:

```
http.headers().frameOptions().sameOrigin()
```

## Conclusão

Após passar um bom tempo pesquisando e lendo a documentação, consegui fazer o acesso

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfviq11rv0pcdb912rbz.png)

Qualquer dúvida que tenha, ou sugestões e críticas mande uma mensagem no [twitter](https://twitter.com/andremoriya) ou deixa aqui sua mensagem

Muito obrigado e até a próxima.
Argo Tunnels are really fun!🔥🔥🔥🔥
Tags: cloudflare, blog, hotstuff, devops
Published: 2021-09-24 18:47:26

**Unrelated:** It's been a while since I've written anything, and honestly it sucks. My current job has been draining me too much and job hunting isn't going my way, today I finally got the energy to try something out and that is Argo Tunnels.

So what the heck is an Argo tunnel, in the simplest form its a tunnel to the public internet, which means you can run it on your laptop or a raspberry pi and access your content or network anywhere in the world. Argo Tunnels wasn't free, until April 2021, read about it here [Cloudflare Blog Post](https://blog.cloudflare.com/tunnel-for-everyone/)

To get started you can go ahead and read up on the [documentation](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup).

####Prerequisites
* Cloudflare account
* Domain name.


This is a pretty cool concept, if you need a low cost web hosting or just want to demo your work to potential clients.

I launched my portfolio this way, as a means of learning CI/CD, this took me less than 15 minutes to launch so its really a pretty cool concept.
![Image of my portfolio](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dde835sk522gy0vp32xa.png)

Argo Tunnels honestly doesn't require an entire tutorial, but if needed I can help out if you face any issues while trying to install it.
Lab 2 - Create issue and pull requests
Tags: opensource
Published: 2021-09-24 18:30:20

## Introduction
For my second lab, I found a contributor to my code. They have to implement markdown support in my repo. I have to do the same thing to support. My contributor was [Duc Bui Manh](https://github.com/DukeManh).

I started to create a [Issue#8](https://github.com/DukeManh/OSD_SSG/issues/8) on his code, and describe what markdown I will implement to his code. After that, I started to read through his code. It was coded in TypeScript which is the same as JavaScript but with types.
The code workflow wasn't hard to follow. I implemented a function to process all markdown features. In that function, I'm calling all other process markdowns to change markdown to HTML.
I also added some checks such as only accept `.txt` and `.md`. 
After finishing my code I created a pull request [PR#9](https://github.com/DukeManh/OSD_SSG/pull/9) and requested [Duc Bui Manh](https://github.com/DukeManh) to review my change.
He gave me some feedback to change. I had some redundant code. After fixing it I pushed back to remote and re-request to review.

[Duc Bui Manh](https://github.com/DukeManh) has to implement his markdown feature to my code. He first created an [Issue#15](https://github.com/Kevan-Y/text-ssg/issues/15), then created a pull request [PR#16](https://github.com/Kevan-Y/text-ssg/pull/16) for his change. The way of implementing a smarter than my way using some regex. I pull his code and do some testing on my side. I found that the markdown for the link was wrong, the href contains some `<i>` tags. Also, the heading was wrapped with `<p>` tag which doesn't match the HTML5 standard. I had him change it before merging it.

## Conclusion
Overall this lab helped me to learn to read some else code and implement the markdown feature without changing his workflow. And also expose my workflow to others and learn how they implement it.

**GitHub:**
[Kevan-Y](https://github.com/Kevan-Y)
[DukeManh](https://github.com/DukeManh)
Adding markdown parsing to SSG 
Tags: opensource
Published: 2021-09-24 18:07:13

Moving into week 3, I was asked to add markdown support to another student's repo. 

### Adding markdown support to [Francesco's dodo-SSG](https://github.com/menghif/dodo-SSG)

![Dodo's picture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5e7alujh8brgxqprhkoq.jpg)

It seems simple at first but markdown (.md) files have more complicated format than text files. Replacing headings, italic and bold text is easy by replacing any that matches but when it comes to paragraph, it will not work if the paragraphs are not separated by 2 new lines characters. I will add a path for that issue. 

I added some more logic to the script without altering the existing code, I also refactored a piece of code, turning it into a function.

### Pull request stories

My code didn't get accepted the first time, [Francesco](https://github.com/menghif) had some comments on how to improve the pull request (program not accepting `.md` file, updating README).

If my repo received a pull request, I would really appreciate the contributor's time and effort to improve my code base. Of course, not every PR is perfect, I could spot some improvements can be made in the commits, adding a comment in the PR or creating an issue and assigning the the author to the task.

#### Take a look at our pull requests: 
[Francesco's SSG](https://github.com/menghif/dodo-SSG)
[My SSG](https://github.com/TueNguyen2911/tue-1st-ssg)
Write a Python program to reverse only the vowels of a given string.
Published: 2021-09-24 18:05:16

```python
def reverse_vowels(str1):
	vowels = ""
	for char in str1:
		if char in "aeiouAEIOU":
			vowels += char
	result_string = ""
	for char in str1:
		if char in "aeiouAEIOU":
			result_string += vowels[-1]
			vowels = vowels[:-1]
		else:
			result_string += char
	return result_string
print(reverse_vowels("w3resource"))
print(reverse_vowels("Python"))
print(reverse_vowels("Perl"))
print(reverse_vowels("USA"))
```
Code in Public - Time Management website
Tags: lowcode, php, sql, techtalks
Published: 2021-09-24 18:03:58

This video shows how I built a simple Project, Task, Time Logging management website using the low-code Wizards Toolkit (WTK) development environment.

I time-log every step from DB creation to building web pages, writing SQL triggers, creating SQL reports that show the data both in list and graph / chart views, and making it all look good.

Entire project took 3 hours and 18 minutes to have a fully functioning website. Later I did some fine-tuning for another 1.86 hours.  This video only includes the highlights.

{% youtube GCkehIo8w78 %}
Write a Python program to count the number of prime numbers less than a given non-negative number.
Published: 2021-09-24 18:03:58

```python
def count_Primes_nums(n):
    ctr = 0
    
    for num in range(n):
        if num <= 1:
            continue
        for i in range(2, num):
            if (num % i) == 0:
                break
        else:
            ctr += 1

    return ctr

print(count_Primes_nums(10))
print(count_Primes_nums(100))

```
How to remove CSS Property using javascript?
Tags: javascript, webdev
Published: 2021-09-24 18:02:57


 ```javascript
<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
  background-color: coral;
  border: 1px solid;
  padding: 50px;
  color: white;
}
</style>
</head>
<body>

<div id="myDIV">This div element has an onmousemove event handler that displays a random number every time you move your mouse inside this orange field.
  <p>Click the button to change the color of text.</p>
  <button onclick="removeHandler()" id="myBtn">Try it</button>
</div>

<h1 id="demo">Hello everyone</h1>

<script>
document.getElementById("myDIV").addEventListener("mousemove", myFunction);

function myFunction() {
  document.getElementById("demo").style.color = "green";
}

function removeHandler() {
  document.getElementById("demo").style.removeProperty('color');
}
</script>
</body>
</html>
```
OUTPUT:

1.) Without Click ‘Try It’ button text is ‘green’:

![Screenshot (325)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cguomxd512trolc85cw8.png)

2.) After Click the button remove property call and removes the previous css property of text:

![Screenshot (326)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wg2a55cmsg69gxatgnd0.png)

To learn from each other keep sharing and learning!
follow me on Twitter also I post my daily learning and work on Twitter.
https://twitter.com/tk22O9
Write a Python program to find common divisors between two numbers in a given pair.
Published: 2021-09-24 18:01:57

```python
def ngcd(x, y):
    i=1
    while(i<=x and i<=y):
        if(x%i==0 and y%i == 0):
            gcd=i;
        i+=1
    return gcd;
def num_comm_div(x, y):
  n = ngcd(x, y)
  result = 0
  z = int(n**0.5)
  i = 1
  while( i <= z ):
    if(n % i == 0):
      result += 2 
      if(i == n/i):
        result-=1
    i+=1
  return result

print("Number of common divisors: ",num_comm_div(2, 4))
print("Number of common divisors: ",num_comm_div(2, 8))
print("Number of common divisors: ",num_comm_div(12, 24))
```
Write a Python program to find the digits which are absent in a given mobile number.
Published: 2021-09-24 18:00:24

```python
def absent_digits(n):
  all_nums = set([0,1,2,3,4,5,6,7,8,9])
  n = set([int(i) for i in n])
  n = n.symmetric_difference(all_nums)
  n = sorted(n)
  return n
print(absent_digits([9,8,3,2,2,0,9,7,6,3]))
```
Write a Python program to find the number of divisors of a given integer is even or odd.
Published: 2021-09-24 17:59:12

```python
def divisor(n):
  x = len([i for i in range(1,n+1) if not n % i])
  return x
print(divisor(15))
print(divisor(12))
print(divisor(9))
print(divisor(6))
print(divisor(3))
```
Sequence Problem
Published: 2021-09-24 17:55:41

Write a Python program to create a sequence where the first four members of the sequence are equal to one, and each successive term of the sequence is equal to the sum of the four previous ones. Find the Nth member of the sequence. 
```python

def new_seq(n):
    if n==1 or n==2 or n==3 or n==4:
        return 1
    return new_seq(n-1) + new_seq(n-2) + new_seq(n-3) + new_seq(n-4)
print(new_seq(5))
print(new_seq(6))
print(new_seq(7))

```
Beep Boop 7: Making AI Chatbots (No Code Required!)
Tags: beginners, codenewbie, programming, tutorial
Published: 2021-09-24 15:07:09

--- 
title: Beep Boop 7: Making AI Chatbots (No Code Required!)
description: In part 7 of this series, we create an AI chatbot without any code using Power Virtual Agents, part of the Microsoft Power Platform. 
tags: beginners, codenewbie, programming, tutorial
series: "Beep Boop"
published: true
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7utk8y7ilghpotw2u6ke.png
---

Thanks to everyone who joined us live for the 7th episode of [Beep Boop with the Microsoft Reactor](aka.ms/BeepBooptube)! We started off with a walk down memory lane to one of the first chatbots we've ever interacted with, [SmarterChild](https://en.wikipedia.org/wiki/SmarterChild), and [made our very own intelligent chatbot using Power Virtual Agents](aka.ms/beepbooplinks7)! 👩‍💻👩🏽‍💻


If you missed the fun live, don't worry- you can watch the replay [here on YouTube](aka.ms/beepboop7), and in the embedded video below!



{% youtube oDOmtVzuX7k %}



**On this episode we cover:**


- [3:01](https://youtu.be/oDOmtVzuX7k?t=181) We discuss the success of the small business we created in the [last episode of Beep Boop](aka.ms/beepboop6), Franklin’s Salami Incorporated. 🐶🥩

- [9:52](https://youtu.be/oDOmtVzuX7k?t=592) We talk a little bit about the [Microsoft Imagine Cup](https://aka.ms/bbimaginecup) and Chloe shoes off her [training content about how to pitch your project](aka.ms/ICwithCC)! 🎤


- [12:00](https://youtu.be/oDOmtVzuX7k?t=720) As always, we give an overview of what we do here on Beep Boop for our new friends 💕

- [15:01](https://youtu.be/oDOmtVzuX7k?t=901) We recap what we did on the [last episode of Beep Boop](aka.ms/beepboopreplay6). If you'd like an introduction to the Power Platform, we highly suggest [you check it out](aka.ms/beepboop6)! 🔋

- [20:08](https://youtu.be/oDOmtVzuX7k?t=1208) Chloe shows off the army of bots she has built over the years! 🤖🤖🤖🤖

- [31:26](https://youtu.be/oDOmtVzuX7k?t=1886) We throw it back to the 90s and talk about our first introduction to chatbots, SmarterChild on AOL Instant Messenger 🖥💾

- [33:05](https://youtu.be/oDOmtVzuX7k?t=1985) We log into Power Virtual Agents and [create our SmarterTeen chatbot](https://aka.ms/beepboop7links2) by following the [Microsoft Learn module](aka.ms/beepbooplinks7)! 🤓

- [37:44](https://youtu.be/oDOmtVzuX7k?t=2264) We cover the concept of [Topics](https://aka.ms/beepboop7links3) and add some to SmarterTeen, [test out our bot](https://aka.ms/beepboop7links4), and check out [how analytics work in Power Virtual Agents](https://aka.ms/beepboop7links5). 📈🧪

- [53:48](https://youtu.be/oDOmtVzuX7k?t=3228) There are so many channels for [publishing your chatbot](https://aka.ms/beepboop7links6)! We encourage you to check it out and let us know how it goes! Happy beeping and booping 🤠



*Did you have fun? Come back for [Episode 8 of Beep Boop](aka.ms/beepboop8) next week, where we'll continue learning with the [Microsoft Power Platform](aka.ms/beepbooplearnpower)! See you there!*
OH! No, My Macbook is super slow 😱 
Tags: macbook, docker, disk, storage
Published: 2021-09-24 14:59:00

last week my dev laptop (MacBook Pro 13-inch, 2019, Four Thunderbolt 3 ports) went super slow. The laptop fan was working at high speed, it sounds like a bitcoin miner. 
I was curious to see what happened. Nothing was working correctly, really weird!. 

I opened the Activity monitor and checked processes and app resource usage. CPU usage was normal, then I moved to the memory, it was fine, and then I moved to the disk usage. **OH! There were just a few megabytes free.** 
How it was possible, I  use this Macbook just for working purposes.

I used the [grandperspectiv](http://grandperspectiv.sourceforge.net/) to visualize the HDD usage.
![first run](https://i.ibb.co/kKxxWmX/Screenshot-2021-09-03-at-09-01-39.png)

and found these 3 major reason:
* docker.raw (64GB )
* node_modules folders 
* Application cache (chrome, Mozilla, developer tools, yarn and nvm)

### solutions:

* you can change the size of docker.raw in docker settings ( have a look at this [link](https://apple.stackexchange.com/questions/391377/what-is-the-purpose-of-docker-raw-file-on-mac-os-catalina)
* I suggest using this command in your home folder to remove node_modules in all old packages
```find . -name 'node_modules' -type d -prune -exec rm -rf '{}'```
* clean npm and yarn cache

Just by these 3 simple solution I freed up to 100GB of my disk storage.
Tailwind CSS Datepicker
Tags: showdev, tailwindcss, opensource
Published: 2021-09-24 14:55:49

# Tailwind CSS Datepicker

This project is a free and open source datepicker library which uses the utility-first classes from Tailwind and the JavaScript from another open source library called Vanilla JS Datepicker.

This [Tailwind CSS Datepicker](https://flowbite.com/docs/plugins/datepicker/) is part of a larger library of components and interactive elements called Flowbite. Although it can also be used independently from the main library, we encourage you to check out the whole [Tailwind components library from Flowbite](https://flowbite.com/docs/getting-started/introduction/).

<a href="https://flowbite.com/docs/plugins/datepicker/">
  <img src="https://flowbite.s3.amazonaws.com/tailwind-css-datepicker.png" alt="Tailwind CSS Datepicker">
</a> 

## Getting started

If you want to use the **Tailwind Datepicker** plugin using JavaScript you will need to include it into your project via NPM:

```bash
npm i @themesberg/tailwind-datepicker --save
```

After you've installed the NPM library, you will need to import the `Datepicker` module:

```javascript
import Datepicker from '@themesberg/tailwind-datepicker/Datepicker';
```

Initialize a new element using the `Datepicker` constructor and optionally add custom options based on your needs:

```javascript
const datepickerEl = document.getElementById('datepickerId');
new Datepicker(datepickerEl, {
    // options
}); 
```

If you want to use the **Tailwind Date Range Picker** you have to import the `DateRangePicker` module:

```javascript
import DateRangePicker from '@themesberg/tailwind-datepicker/DateRangePicker';
```

Then in the same fashion you can initalize a date range picker component by using the `DateRangePicker` constructor:

```javascript
const dateRangePickerEl = document.getElementById('dateRangePickerId');
new DateRangePicker(datepickerEl, {
    // options
}); 
```

## Documentation

Check out the official [Tailwind CSS Datepicker Documentation](https://flowbite.com/docs/plugins/datepicker/) page to learn how to get started by installing and then using this library in your project.

## License

The Tailwind CSS Datepicker is open-source under the MIT License. Find out more by [clicking here](https://flowbite.com/docs/getting-started/license/).
Creating a CTA Button Progress
Published: 2021-09-24 14:55:16

For my IST 402 class, we are creating a call to action button. I'm still new to web components, so the button is a work in progress for my partner and I.

#Difficulties
We've experienced a series of difficulties along the way of creating this button as we are both brand new to this process and there is way too much that goes into a single button. One thing we've struggled with is the shadow parts aspect of the project, so we're still trying to read up on how it works. We're also having some difficulties getting the disabled aspect to work, but I think we're close figuring it out.

#Successes
My partner and I have learned to celebrate the small victories and take the requirements one step at a time. So far, we've been able to change the CSS for our button to change its look, add hover and focus changes, keyboard accessibility, and icons. We covered icons in class and learned how to add them to our buttons with just a few lines of code (now if we could only get the no icon option to work we'd be golden).

Overall, this process has been a big learning experience and we still have a lot more to figure out, so stay tuned.

If you want to view our button's progress, [click here.](https://github.com/table-in-the-corner/invisi-button-group1a)