teleren/devto huggingface dataset:
Leetcode September Day16
Published: 2020-09-16 18:06:54

Problem
>Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231.

>Find the maximum result of ai XOR aj, where 0 ≤ i, j < n.

>Could you do this in O(n) runtime?

Example
"""
Input: [3, 10, 5, 25, 2, 8]

Output: 28

Explanation: The maximum result is 5 ^ 25 = 28.
"""

Approach - 
The brute force approach would be to consider all pairs and return the pair with maximum xor.
```
ans = float('-inf')
for i in range(len(arr)):
    for j in range(i, len(arr)):
        ans = max(ans, arr[i]^arr[j])
return ans
```
Time Complexity of this approach is O(n^2) and space complexity is O(1).

How can we optimize it ?

We know that a^b = 1 if a != b . (assuming a, b to be either 0 or 1).
So, xor of two numbers will be maximum if the they differ in their bits at most places.
For example `11001` will give max xor with `00110` which is `11111`.
So, We will first convert all numbers into their binary string representation. Then for each number we will try to find the number with opposite bits (as close as possible) and we update the answer.

Now, to find the number with opposite bits we will be using tries. The time for search in trie is O(len(word)).

Solution
```
class Solution:
    def findMaximumXOR(self, nums: List[int]) -> int:
        bin_list = ["{0:b}".format(el) for el in nums]
        max_len = len(max(bin_list, key = lambda x: len(x)))
        bin_list = ["0"*(max_len - len(el)) + el for el in bin_list]
        ans = float('-inf')
        # create a trie and for each representation try to find the exact opposite as much as possible
        trie = {}
        for word in bin_list:
            parent = trie
            for char in (word):
                if char in parent:
                    parent = parent[char]
                else:
                    parent[char] = {}
                    parent = parent[char]
        # now for each item in binary_list, try to find the opposite
        ans = float('-inf')
        for word in bin_list:
            parent = trie
            curr = ''
            for idx, char in enumerate(word):
                to_find = '1' if char == '0' else '0'
                if to_find in parent:
                    curr += to_find
                    parent = parent[to_find]
                else:
                    curr += char
                    parent = parent[char]
                if idx == len(word) - 1:
                    ans = max(ans, int(word, 2) ^ int(curr, 2) )
        return ans  
```
Time Complexity - 
For creating binary list = O(n*log(len_of_digits)) = O(n)
for each word we are search in trie = O(n*log(len_of_digits))  = O(n).
So, approximately the time complexity of this solution is O(n).
Scoreboard App
Tags: react, javascript, beginners, webdev
Published: 2020-09-16 18:42:49

Hi all 👋 I have just deployed the [scoreboard](https://score-me.netlify.app/) app I created using React, check it out 👩🏻‍💻 


To give you an overview of how I tackled this project:
![scoreboard](https://dev-to-uploads.s3.amazonaws.com/i/ybuwtnw1b4lbuyqt740x.png)


If you're curious about how I created the scoreboard app, here is my [code](https://github.com/gladys-pascual/scoreboard).


Until my next project! ✌🏼😎
TailwindCSS with Sapper and Svelte
Tags: svelte, sapper, tailwindcss, postcss
Published: 2020-09-16 18:10:45

**What ?**

An initial template with Sapper 0.28.0, Svelte 3.17.3 and Tailwind CSS 1.8.6 updated to September 25th, 2020

**Why ?**

Because there are a lot of posts and reference working but with old versions. This is only another alternative more, trying to use newer versions (that soon will be old too).

**How ?**

Run the commands:

```bash
npx degit csaltos/sapper-svelte-with-tailwindcss app1
cd app1
npm i
npm run dev
```

And open the browser at http://localhost:3000 to see a Sapper page done with Svelte using a Tailwind CSS sample.

**Where ?**

At https://github.com/csaltos/sapper-svelte-with-tailwindcss you will find the source code as a reference which is based on the original Sapper with Svelte template.

Please take special attention to the commit at [dc251b6]( https://github.com/csaltos/sapper-svelte-with-tailwindcss/commit/dc251b6b335f18a566e5c1d36c350091870aca73) which contains the exact change details to activate Tailwind CSS.

**Who ?**

This template is possible thanks to many posts and reference from:

* https://github.com/dan-unhuman/sapper-template-rollup-tailwind (special thanks to dan for this cool solution used on this version 2)
* https://www.apostrof.co/blog/getting-tailwind-css-to-integrate-nicely-with-svelte-sapper/
* https://github.com/tailwindlabs/tailwindcss-setup-examples/tree/master/examples/sapper
* https://github.com/babichjacob/sapper-postcss-template
* https://github.com/sarioglu/sapper-tailwindcss-template
* https://dev.to/sarioglu/using-svelte-with-tailwindcss-a-better-approach-47ph
* https://dev.to/alancwoo/sapper-svelte-postcss-tailwind-473i
* https://github.com/sveltejs/language-tools/blob/master/docs/preprocessors/other-css-preprocessors.md
* https://dev.to/inalbant/a-simpler-way-to-add-tailwindcss-to-your-svelte-project-11ja

**IMPORTANT**: obviously this is only a starting point, please review TailwindCSS documentation for further steps.

**NOTE**: you may also use Smelte which comes already configured with TailwindCSS and cool Material components with Sapper and Svelte here -> https://smeltejs.com/
Cypress - setup to reports, USEFUL MATERIALS
Tags: javascript, testing, cypress, codequality
Published: 2020-09-16 17:56:35


[Cypress](https://www.cypress.io/) is a fantastic testing tool. And for me, the best part, it is written in JavaScript. So all of my code can be in the same language. The problem is that it is a bit low on a practical guide area. It is especially noticeable in areas about setup and reports. Many are outdated, and many things depend on a specific version. Below are some of my guides for setting up an environment for testing and reports.

## Getting started – initial Cypress setup

In [this](https://dev.to/chriss/cypress-initial-setup-l4) article, you can find out how to install Cypress and set it up for testing. Once you do that, you can set it up for [running against different environments](https://dev.to/chriss/running-cypress-against-multiple-environments-54m9).

## Cypress reports
When it comes to Cypress reports, you can go with a popular solution that might be more complex to set up and use the following three articles for that. The first one talks about how to generate [mochawesome](https://www.npmjs.com/package/mochawesome) report. Since every site generates separate reports, [the next article](https://dev.to/chriss/cypress-merging-multiple-mochawesome-reports-1855) describes how to merge them into one.

If this is too complex, and you don’t want to install multiple dependencies, you can use the [cypress-dashboard](https://www.npmjs.com/package/cypress-dashboard) package. With this one, you get a dashboard report by just installing one dependency. Here is a guide on that.

***

For more, you can follow me on [Twitter](https://twitter.com/hi_iam_chris_), [LinkedIn](https://www.linkedin.com/in/kpajtasev/), [GitHub](https://github.com/kristijan-pajtasev/), or [Instagram](https://www.instagram.com/hi_iam_chris_/).
Submission for the actions hackathon
Tags: actionshackathon, github, opensource, showdev
Published: 2020-09-16 17:50:11

[Instructions]: # (To submit to the GitHub Actions x DEV Hackathon, please fill out all sections.)
# **DEV ACTION**
This is the post for the submission of my action for the [actionshackathon](https://dev.to/devteam/announcing-the-github-actions-hackathon-on-dev-3ljn) on DEV.

### My Workflow
[Note]: # (Make sure to include the name of your GitHub Action and share where it's being used!)

This [GitHub action](https://github.com/marketplace/actions/dev-action) posts a new article on **DEV** whenever a new release has been published on GitHub.

### Submission Category: 

[Note]: # (Maintainer Must-Haves, DIY Deployments, Interesting IoT, Phone Friendly, or Wacky Wildcards)
I am submitting my action under the **Wacky Wildcards** category.

### Yaml File or Link to Code

[Note]: # (Our markdown editor supports pretty embeds. Try this syntax: `{% github link_to_your_repo %}` to share a GitHub repository)

Below is the example YAML file for the workflow to be run

```yml
on:
  release:
    types: [published]

jobs:
  hello_world_job:
    runs-on: ubuntu-latest
    name: A job to post an article on DEV
    steps:
      # To use this repository's private action,
      # you must check out the repository
      - name: Checkout
        uses: actions/checkout@v2
      - name: Publish Release Update on DEV
        uses: sheikh005/dev-action@1.0.0 # Uses an action in the root directory
        id: publish
        with:
          dev-to-secret: ${{ secrets.DEV_TO_TOKEN }}
          tags: "news,opensource,github" # Comma separted list of tags
      - name: Get the URL of the post
        run: echo "The URL of the POST is <${{ steps.publish.outputs.url }}>"
```


### Additional Resources / Info

### Repository
{% github sheikh005/dev-action no-readme %}

### Link to the action on the marketplace

[Dev action](https://github.com/marketplace/actions/dev-action)
Help with getting started in building bot for Slack
Tags: help, beginners, slack
Published: 2020-09-16 17:47:38

I am trying to build a bot for Slack. I somehow managed to do the MVP version of it using Python's slack event API library `slackeventsapi` 

Today in an evening discussion, my friend suggested that I should probably try my hands with Hubot or Bolt framework in JS for building slackbot because those frameworks makes use of RTM(Real time messaging). The discussion couldn't go further because of some time constraint. Now I have been googling around to try and understand what kind of pros I'll get over choosing one over other and why?

If someone could help me by explaining it in a bit easier terms, it would be so helpful. Thanks a lot :))
My #100DOC - Day 21
Tags: 100daysofcode, challenge, log
Published: 2020-09-16 17:41:14

### Day 21: September 16, 2020

#### **Today's Progress**: 
1. **Terminal/Shell Day** (1h 20min):<br>Today I was fine-tuning my Git Bash, it had plenty of things and it lacked others.
    
#### **What I learned**: 
* Tuning Git Bash, creating a new .bashrc.
* Handling of aliases in Bash.

#### **Total time**:
1h 20min.
I Translated Big Scary Tech Terms to Human so You Don't Have To
Tags: javascript, programming, computerscience, mentalmodel
Published: 2020-09-16 17:36:31

---
title: I Translated Big Scary Tech Terms to Human so You Don't Have To
published: true
description: I took a bunch of tech terms that freak me out and turn them into incredibly informal (not scary) language
tags: javascript, programming, computerscience, mentalmodel 
cover_image: https://bit.ly/2ZK9kh5
---
Jargon is freaky, yo. Let's demystify.

- scope: where you can find variables
- stack: the process of stepping through code and executing it (like the process of cooking a recipe). 
- heap: where all your individual objects and trash lives (like a pantry) 
- global scope: variables you can find everywhere
- block scope: variables you can only find inside a {piece} of a function
- function scope: variables you can find inside a function
- "foo" and "bar": data placeholders used w/ writing examples
- API: honestly, just a program's signature; what it can do
- for(i=0...): i is literally just a freakin counter.
  
There. All better.
Get a custom formatted email message with PR info using Github Actions
Tags: actionshackathon, github, opensource, showdev
Published: 2020-09-16 17:26:32

---
title: Get a custom formatted email message with PR info using Github Actions
published: true
description: Provides a well-formatted email subject and body using branch name used for Pull Request and other information obtained from the pull request.
tags: actionshackathon, github, opensource, showdev
---

[Instructions]: # (To submit to the GitHub Actions x DEV Hackathon, please fill out all sections.)


### My Workflow
I have built my very first Github action from scratch thanks to the Github Actions hackathon by [@devteam](https://dev.to/devteam). The action provides a well-formatted email subject and body using branch name used for Pull Request and other information obtained from the pull request.

I used Javascript to do string processing on the branch name and get a formatted email subject and body with PR info added to it.

The action's inputs and outputs are shown below:

```yaml
inputs:
  repo-name:
    description: 'Repository name'
    required: true
  groups:
    description: 'Branch groups (as CSV) for which you want to get email message data'
    required: true
  branch-name:
    description: 'Branch name'
    required: true
  pr-title:
    description: 'Pull request title'
  pr-url:
    description: 'Pull request url'
outputs:
  subject:
    description: 'Email subject'
  body:
    description: 'Email body'
```  

With the outputs shown above, you can use them as you like. I use them to send an email on pull requests of specific types using another [Github action](https://github.com/marketplace/actions/send-email). 

The mail that I received when I opened a PR with branch name `pattern/test` on the repo [Design-Patterns-And-Principles](https://github.com/Devansh-Maurya/Design-Patterns-And-Principles) is shown below:

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

### Submission Category: 

Maintainer Must-Have


### Yaml File or Link to Code

{% github https://github.com/Devansh-Maurya/Get-Email-Message-From-Branch-Action %}


### Additional Resources / Info

I am using my action in one of my repos that I am building while learning design principles and patterns in object-oriented programming. The repo is kind of a note-taking place where I am implementing each pattern that I study in Kotlin. The action sends a mail whenever a pull request is made to add a new design pattern or design principle. Check it out here:

{% github https://github.com/Devansh-Maurya/Design-Patterns-And-Principles %}

Hope you liked it. Thanks for reading.
Tales from the config rabbit hole - and some advice
Tags: linux, vim, vscode, github
Published: 2020-09-16 16:47:32

We've all been there before - as you stare at your screen with bleary eyes, you wonder why the 218397218th color scheme/plugin you've selected hasn't soothed your senses yet. Your plugin manager is crying for help. Not to mention, you've got absolutely zero work done!

Falling down the config rabbit hole like this is usually a huge time sink, and leaves you with zero motivation to actually get back to what you wanted to do. As people who've overcome this, **_what is your advice to beginners who often find themselves in this situation_**? Any stories would also be appreciated!

(also, feel free to leave links/screenshots to your own setup in the comments! In the event someone still in the rabbit hole chances upon this post, you might help end their indecision.)

Also, thank you all for the warm welcome to the dev.to community! This is my first post, so please be kind :smile:

~ <span>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Markus Spiske</a> on <a href="https://unsplash.com/s/photos/programmer?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span>
13 - Marketing to the right audiences in the right spaces with Robyn Spoto
Tags: marketing, startup, tampabay, mentor
Published: 2020-09-16 16:45:12

{% spotify spotify:episode:3xANPtW4k6iaGnyYNEG7d1 %}

In this episode, I have the pleasure of speaking with, actually(!) reconnecting with someone that I used to work for. Founder of SpotOn Digital Media, Co-Founder of MamaBear App and Co-Founder of ThingtoBring, Entrepreneur, Mentor, Digital Media Wizard and Tampa Bay Champion. Ladies and gentlemen, today’s guest is **Robyn Spoto**!

**SpotOn Digital Media Twitter**: [https://twitter.com/spotondigita]([https://twitter.com/spotondigital)

**SpotOn Digital Media**: [https://spotondigitialmedia.com]([https://spotondigitialmedia.com)

**ThingToBring**: [https://thingtobring.com](https://thingtobring.com)
Welcome Thread - v91
Tags: welcome
Published: 2020-09-16 16:39:15

---
title: Welcome Thread - v91
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
---

![sup seal](https://media.giphy.com/media/ypqHf6pQ5kQEg/giphy.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
How can I make my posts more discoverable? 
Tags: help, discuss
Published: 2020-09-16 16:37:56

I'm asking this because my [last post](https://dev.to/fennecdjay/github-discussions-in-your-terminal-4cbd) reached almost nobody. While most of the stuff I've been writing here is obviously low quality, I feel this particular post deserves some interest, and to be honest, I'm eager to get some feedback on this work.


<span>Photo by <a href="https://unsplash.com/@isaacdavis?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Isaac Davis</a> on <a href="https://unsplash.com/s/photos/discovery?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span>
🐘 Compare your PHP with job market 💰
Tags: php, beginners, career, discuss
Published: 2020-09-16 16:29:17

We have created a tool to view your strong and weakness: market comparer

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

To compare yourself with anonymous statistics:
 - Goto [PHP developer roadmap](https://infinite.education/expertise/PHP_Developer)
 - Mark all known skills
 - Profit! You will know you weakness

Need your feedback for this feature! Is it useful? Would you like to show link to your skills at CV?

Project page: https://www.facebook.com/InfEducation
🐧 Linux admin roadmap
Tags: linux, devops, career, beginners
Published: 2020-09-16 16:08:40

[Roadmap for linux admin](https://infinite.education/expertise/linux_administrator)

Project page: https://www.facebook.com/InfEducation

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mhd2w0tde5pq6uih7x6n.png)
Create Your Own Lumen Installer (2020)
Tags: lumen, bash, leenuksid
Published: 2020-09-16 15:59:27

***Bismillah***

Alhamdulillah, I can still provide knowledge that may be useful for my friends who read ..

Fine, according to the title. We will create our own version of the Lumen Installer. Not only that, this script will also immediately take the latest version of Lumen .. When this article was written Lumen was already version 8

# ⚡️Lumen
Little explanation. Lumen is a *Micro-Framework* belonging to **Laravel** which is devoted to creating APIs.

## 🔨 Creating Lumen Installer
To make Lumen Installer I use **Bash** so that we can customize more comfortably.

Oh, yes. I made it on **Linux**, if you are a **Windows** user, maybe I can adjust it for the settings .. Ok 😉

Next .. To create Lumen Installer, here are the steps

- Open Terminal **CTRL + T**

- Create a Folder with a free name .. For example I use the name "bashku"

```bash 
mkdir bashku
```

- Enter into the folder and create a file with the name "lumen"

```bash 
cd bashku
touch lumen
```

- Then edit with nano (If you want to edit with a text editor, go ahead)

```bash 
nano lumen
```

- Paste the following code

```bash
#!/bin/bash

if [ "$1" != "" ]; then
    echo "Sedang Dibuatkan Projectnya di Folder $1"
    composer create-project --prefer-dist laravel/lumen "$1"
else
    echo "Sedang DIbuatkan Projectnay di sini"
    composer create-project --prefer-dist laravel/lumen .
fi
```

- Press **CTRL + X** then **Y** and **ENTER**

- After that go back to the * Directory * initial

```bash
cd ..
```

- and edit ***. Bashrc***

```bash
nano .bashrc
```

- Paste the following code at the bottom

```bash
export PATH="$PATH:$HOME/bashku"
```

*The example above is because the folder I previously created was "bashku", it can be adjusted to the name of your folder

- If you have pressed **CTRL + X** then **Y** and **ENTER**

- then type **source .bashrc** in the terminal

```bash
source .bashrc
```

- After that, try when you are terminated by:

```bash
lumen myproject
```

_Will create project lumen in myproject directory (create a new folder)_

```bash
lumen
```

_Will create a lumen project in the current directory_

# ⛅️ Closing
How? If there are problems, please discuss it in the comments column... The **Bash** script above is a basic bash script and is very easy to understand. 😃

**That's all hopefully useful ...**

**Thank you** 👊
Personal startpages?
Tags: showdev, webdev
Published: 2020-09-16 15:55:50

### TLDR;
Share your startpage repos or links in the comments so others can find them.


[repo](https://github.com/sroehrl/startpage)

[demo](https://boot-me-up.herokuapp.com)

After switching to brave, I couldn't help but feeling thrown back a couple of years: The browser opens up a clean start-page with some basics like time and some stats over a wallpaper-background. It reminded me of the times where everyone used to have their personalized startpage (at least I had). 

# What do you really need?

Now, some of the concepts still around either offer all kinds of customization capabilities on a convoluted screen or simply aren't suitable for your needs. For me personally, a todo list, some quick access links and upcoming calendar events is what I wanted. And brave doesn't offer that. With neoan3, it should only take me an hour of my day to create my own startpage, right? Well, whoever tried to work throught the Microsoft Azure documentation before knows that something as simple as a calendar integration via API takes you from one page of the documentation to the next - daring to ask you if the information was helpful after each irrelevant paragraph. 

## Save yourself the trouble

However, as coders creating our own startpage is not only a fun little exercise, but makes total sense: who needs countless unnecessary options if you build what you need in the first place? In case the idea sounds appealing to you but you don't want to spend a lot of time on such a project as you currently don't need portfolio projects or lack the time otherwise (I can't blame you), I created a little [repository](https://github.com/sroehrl/startpage) to get you started.

I personally run a local apache so I can run the package as is, but feel free to host your creation online (like the demo on heroku) to share your creation. 


## Do share

Anyway, I would be interested to see other startpages from fellow devs. If you have a repository or link to such a project, please share so we can start somewhat of a collection.
Generating a Github Link Within Vim
Tags: vim, github, productivity, git
Published: 2020-09-16 15:46:12

I'm always on the hunt for ways to improve efficiency and reduce the amount of mouse movements and clicks I have to do. One task I find can come up from time to time is grabbing a link from github to a specific line or section of code to either share in a ticket or ask a question about. I despise going to github for this so took a quick look to generate these quickly.

A quick search brought up [knsh14/vim-github-link](https://github.com/knsh14/vim-github-link) which seemed to do exactly what I needed. This plugin adds three useful commands:

* `GetCommitLink`: commit which most recently modified the current file (permalink)
* `GetCurrentBranchLink`: active branch name
* `GetCurrentCommitLink`: most recent commit - URL will 404 if you haven't pushed it to the remote

What is really nice is that it copies the link in my clipboard, so I can just run `:GetCommitLink` (or map it to a shortcut key) and paste directly wherever I need to share it!