teleren/devto huggingface dataset:
Foorbar: Find the Access Codes
Tags: foobar, google, python
Published: 2021-09-24 05:03:54

Find the Access Codes
=====================

In order to destroy Commander Lambda's LAMBCHOP doomsday device, you'll need access to it. But the only door leading to the LAMBCHOP chamber is secured with a unique lock system whose number of passcodes changes daily. Commander Lambda gets a report every day that includes the locks' access codes, but only the Commander knows how to figure out which of several lists contains the access codes. You need to find a way to determine which list contains the access codes once you're ready to go in. 

Fortunately, now that you're Commander Lambda's personal assistant, Lambda has confided to you that all the access codes are "lucky triples" in order to make it easier to find them in the lists. A "lucky triple" is a tuple (x, y, z) where x divides y and y divides z, such as (1, 2, 4). With that information, you can figure out which list contains the number of access codes that matches the number of locks on the door when you're ready to go in (for example, if there's 5 passcodes, you'd need to find a list with 5 "lucky triple" access codes).

Write a function solution(l) that takes a list of positive integers l and counts the number of "lucky triples" of (li, lj, lk) where the list indices meet the requirement i < j < k.  The length of l is between 2 and 2000 inclusive.  The elements of l are between 1 and 999999 inclusive.  The solution fits within a signed 32-bit integer. Some of the lists are purposely generated without any access codes to throw off spies, so if no triples are found, return 0. 

For example, [1, 2, 3, 4, 5, 6] has the triples: [1, 2, 4], [1, 2, 6], [1, 3, 6], making the solution 3 total.

Input:
solution.solution([1, 2, 3, 4, 5, 6])
Output:
    3

Input:
solution.solution([1, 1, 1])
Output:
    1

Solution:

```python
def solution(l):
    n = len(l)
    arr = [0] * n
    for i in range(n):
        for j in range(i+1, n):
            if l[j] % l[i] == 0:
                arr[i] += 1
    res = 0
    for i in range(n):
        for j in range(i+1, n):
            if l[j] % l[i] == 0:
                res += arr[j]
    return res
```
Flirting with Nyxt browser
Tags: browser, desktop, emacs
Published: 2021-09-24 03:26:16

## The browser is an OS

The web browser is the most important operating system inside your operating system. If it's not the most important software you use, it's probably a close second.

When a tool is that important, you better served having a deep level of control over it. It should behave exactly the way you want it, and the way you tell to behave should come in the form of code that's shareable.

That's what [Nyxt](https://nyxt.atlas.engineer/) is about. I've been fascinated by it since last year.

It's been progressing well, version 2 right now is a vast improvement over version 1.

To understand what Nyxt is trying to do, you have to first understand what emacs really is.

To understand what emacs really is you have to use it. And not just open it and take a look (there's nothing to look at), you have to dive in and use it. Give it four months and you may get the idea. Hearing people describe emacs is like reading the descriptions of a feeling. You really only get it when you feel it yourself.

Few people will get it but those who do will be die-hard about it.

## Trying it as a secondary browser

Switching browsers are typically a low cost move. Bring over bookmarks, install a handful of extensions and you're mostly done.

But Nyxt isn't like that and I know it. So I considered adopting it as a secondary browser. But I'm not sure what secondary even mean. At best I arrive at doing non-mission critical thing on Nyxt, like Twitter.

So I did that.

Nyxt so is not ready for prime time. It may get there eventually but probably by version 4 or so.

It sells itself as keyboard driven, but even on that aspect is clunkier than Firefox with Vim Vixen installed.

The built in dark mode is serviceable but nothing like Dark Reader can do.

Support for Chrome extensions are work in progress apparently.

And it doesn't even come with reader-mode yet. Now that's a deal breaker.

I know with enough custom code I can take care of all the above but the cost would be prohibitively high.

## If it ain't broken

I can't yet build a strong case on why I invested time on Nyxt other than wanting to play with new toys. Firefox is working very well, for now it's in no danger of being dethroned.

I don't mind that Nyxt falls short for now, the project has gotten enough traction that it will likely go on.

But I care about my tools. I want them to be powerful, and the less of them the better.

There's nothing out there like emacs, but Nyxt comes very close. It has the right intention, something completely unique in the browser space.
NASA Space Apps 2021 - Registrations now open!
Tags: hackathon, event, virtual, development
Published: 2021-09-24 04:40:40

---
title: NASA Space Apps 2021 - Registrations now open!
published: true
description: One week to the biggest hackathon on the planet!
tags: #hackathon #event #virtual #development
//cover_image: https://direct_url_to_image.jpg
---
The [**NASA International Space Apps Challenge**](https://www.spaceappschallenge.org/) is an international hackathon for coders, scientists, designers, storytellers, makers, builders, technologists, and others in cities around the world, where teams engage the National Aeronautics and Space Administration’s (NASA’s) free and open data to address real-world problems on Earth and in space.

**This year's event will take place on October 2-3 and will also mark the 10th year of this hackathon!**

For the second year, the event will be hosted completely remotely, but it will still be a lot of fun (I promise!) and will give you the chance to connect with like-minded people nearby, thanks to Space Apps's virtual locations. 
**If you're reading this from Berlin (or really anywhere in Germany)**, you're welcome to register for [our virtual location here](https://2021.spaceappschallenge.org/locations/berlin). Otherwise, you can browse the [location closer to you](https://2021.spaceappschallenge.org/locations) or register for the universal event. 

**Hope to virtually connect with a lot of you!**
UI Dev Newsletter #75
Tags: html, css, javascript, webdev
Published: 2021-09-24 04:38:51

## Links


[The Future of CSS: Cascade Layers (CSS @layer)](https://bit.ly/2XG3H5J)
Bramus Van Damme explains Cascade Layers, how we can use them, and what benefits they bring.


[Designing Beautiful Shadows in CSS](https://bit.ly/39mfdFU)
Josh Comeau describes all you need to know about box-shadows, from theory to practical examples.


[Autocapitalization](https://bit.ly/3EysBF5)
Manuel Matuzović explains how to control the virtual keyboard's capitalization of words and characters by default.


[Grainy Gradients](https://bit.ly/3hL0etq)
Jimmy Chion shows how to generate colorful noise to add texture to a gradient with only a tiny amount of CSS and SVG.


[Web Vitals patterns](https://bit.ly/3zizEOo)
Chrome Developers share a collection that includes patterns that are often tricky to implement without hurting your Core Web Vitals scores.


[Master Frontend Development By Cloning These Websites](https://bit.ly/2XCUGuc)
To become a better developer, Chris Hansen lists which sites you should try to clone and incorporate functionality, like modals and dropdowns.


[W3C Design System](https://bit.ly/3AvKS3G)
W3C team shares a design system that shows how the front-end assets (CSS and JavaScript) are organized and compiled for their site.


[Smooth Shadow](https://bit.ly/3EysBoz)
Philipp Brumm shares a helpful little tool to make a smooth shadow.


## Popular on Twitter

[Play your favorite tunes with Spotify in your terminal.](https://bit.ly/3klA16r)
GitHub shares a Spotify TUI — Spotify for the terminal written in Rust.


**Happy coding!**

[Subscribe to the newsletter here!](https://buttondown.email/starbist)
Learning Python- Intermediate course: Day 31, Coordinate positions
Tags: learningpython, python, tutorial
Published: 2021-09-24 04:31:17

Today we will cover the coordinate layout in Tkinter
---
____

Today we will make a program which will take in inputs of principle and discount and calculate the total price.


![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fnj495lupa6i400h39fa.png)
 
Here are the program specs 
- One label for the text principle
- One label for the text discount
- One label for the total value
- One button show.
- One slider for the discount values
- One spinbox for the principle amount

Now that we have got all the specs, let's start building the program-

```python
from tkinter import *
master=Tk()
master.geometry("300x200")

Lbl1=Label(master,text="Principle")
Lbl2=Label(master,text="Discount")
Lbl3=Label(master,text="Total. ",font="20px")
spinbox=Spinbox(master,from_=10, to=100)
slider=Scale(master,from_=0, to=100, tickinterval=20, length= 150, orient="horizontal")
def display():
    a=int(spinbox.get())-int(spinbox.get())*int(slider.get())/100
    Lbl3.config(text=str(a)+"$")
button=Button(master,text="Calculate",command=display)

spinbox.pack()
Lbl1.pack()
slider.pack()
Lbl2.pack()
button.pack()
Lbl3.pack()

mainloop()
    

```


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


The program works all right, but that's not how we want to display the widgets. We need to adjust the look and feel. We want the first two labels to be adjacent towards the spinbox and slider widgets. For that, we use the coordinate layout. The pack layout is not sufficient as it packs all the widgets into just a centre line. Hence, we will place them coordinately.  

We can set the coordinates of the widgets using the `place` method. Example `widget.place(x=30,y=20)`
Here is the final program, now with the power of place layout.

 
 
 
 
 ```python

from tkinter import *
master=Tk()
master.geometry("300x200")

Lbl1=Label(master,text="Principle")
Lbl2=Label(master,text="Discount")
Lbl3=Label(master,text="Total. ",font="20px")
spinbox=Spinbox(master,from_=10, to=100)
slider=Scale(master,from_=0, to=100, tickinterval=20, length= 150, orient="horizontal")
def display():
    a=int(spinbox.get())-int(spinbox.get())*int(slider.get())/100
    Lbl3.config(text=str(a)+"$")
button=Button(master,text="Calculate",command=display)

spinbox.place(x=100, y=0)
Lbl1.place(x=0,y=0)
slider.place(x=100, y=50)
Lbl2.place(x=0,y=70)
button.place(x=150,y=130)
Lbl3.place(x=150,y=170)

mainloop()
    
```

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rg0b7xsu1eywqtt7gvd.png)
 
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/65e8z6vn5qyqmp4qss02.png)
 

One thing to note is that the layouts remain the same even if the window is resized.

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t8u03skx2j8b91ru5hal.png)
First experience with Pull Request
Tags: beginners, opensource, webdev
Published: 2021-09-24 02:35:52

This is my third week get along with open source, and I realize that there are so much fun if we are not working alone. At first, I thought it was really hard to work and develop on someone's program until I give it a shot. Let me walk you through what I have done for this week.

This is actually my first time working with *Pull Request*, and once again I choose [Kien Nguyen](https://github.com/kiennguyenchi) as my partner for this lab. Based on the previous lab, I have noticed how he writes his program, as well as being familiar with the structure of Kien's program.I also check his [repo](https://github.com/kiennguyenchi/potato-generator) to see if he would make any changes in his code. And this time, I would love to add **Markdown Support Feature** in his program. More specifically, I will make some adjustments to process **.md** file and implement Markdown syntax for **Heading 1**. This time, I have to be extra careful when modifying his code, I am trying to make less changes as much as possible ^!^. Let see how I make changes to his code in order to support Markdown file mentioned above.

At first, if I want to process **.md** file, I have to make the program accpept it and then being able to open it. So, in his **pgprogram.cpp** file, I create a new variable named `mdFile`, then I create another `if/else` statement inside the `main` function to accept **.md** file. Another change is inside his `HTMLFile.cpp` file, I modify his `setHtmlBody` function to support making **Heading 1**. At this point, another `if/else` statement being used again to find the syntax **#** and replace it with the `<h1>` tag. I use method `find()` to look for the syntax **#**, and then using method `erase()` to delete it, then adding `<h1>` tag to the place where I delete the **#**.

After modifying his code, I create a pull request and politely ask [Kien](https://github.com/kiennguyenchi) to review it and let me know if he has any questions. We were having a long conversation discussing about the new feature between [my pull request](https://github.com/tcvan0707/txt2html/pull/8) and [his](https://github.com/kiennguyenchi/potato-generator/pull/3). After all, I have reviewed his pull request and I also make some changes based on his pull request for my program, everything works as exactly what we expect.

Overall, do not think you are not good enough to contribute to someone else's program. You are not alone, we are here to learn, there are so many things in IT fields for you to learn everyday. Contributing to other's code will allow you to explore new stuffs, understanding different logic as well as the way they write their program. [Github](https://github.com/) is a wonderful place for you when you want to be part of other's project. Let help us become better ^^.
Today I learned - Day 10/11 (22/23 SEP 2021)
Published: 2021-09-24 04:25:00

# Things I learned
## AWS
- git action
- vpc
- Security Groups (similar to a firewall)
- Elastic IP (when you want to reserve an IP)
- EC2
- ELB

## Started a group project
- Worked on our project's proof of concept 
- Started working on our minimum viable product
- My role: work with YouTube APIs to recommend videos that meet the users' need.  

## About our project
- Proposed to make a home workout website. When people select which body part they want to work out on a human figure, the website will recommend videos that shows corresponding workout.
Week 3: Getting comfort and a bit exciting about open source
Tags: opensource, github, senecacollege
Published: 2021-09-24 04:23:02

In the lab this week, I co-operate with an amazing classmate and you guys can check out his talented work at [Andre](https://github.com/AndreWillomitzer)

# Making changes to Andre repo
I would say the coding part of this lab is not that heavy and challenging like I think it would be. At first, I visit [Andre's repo] (https://github.com/AndreWillomitzer/textToHTML_V2) and file an [issue](https://github.com/AndreWillomitzer/textToHTML_V2/issues/8) to request implement markdown features for the project which support h1 and h2 tags. Then, I fork and clone his project to my local machine and create a new branch to work on.

For the implementation, I will check for the file extension name using 
```javascript
path.extname(file) === ".txt"
```
```javascript
path.extname(file) === ".md"
```
and for the file which have the extension end by ".md" I will use replace() to wrap the line in an corresponding html tags

```javascript
const html = data
            .split(/[\r?\n\r?\n]/g)
          .map((line) =>
            line
            .replace (/^## (.*$)/gim, '<h2>$1</h2>')
            .replace(/^# (.*$)/gim, '<h1>$1</h1>')
            .replace(/(^[a-z](.*)$)/gim, '<p>$1</p>')
            /*
            replace any line starting with # and a space with <h1> surrounding itself.
            replace any line starting with an alphabetical character followed by 0 or more of anything with <p> surrounding itself.
            */
          ).join('\n'); //this makes the content a string rather than array.
```
Then after update his README.md file I decide to create a pull request and it has been accepted with a few more comments on thing that I could fix it which are only small details

# The challenging
This time I was a bit wiser to choose people which using the same programming language and start a bit earlier than I did last week. But having to review and work on somebody logic is something different. Luckily, Andre and me keep communicate back and forth which make our lab a lot easier. We did spend time to explain our logic and working to solve the problem together so for me it is a pleasure to work with Andre.

# Git command line version is not that scary 
I used to work on many Android application project and I used to use Github desktop to host my code on Github. But whenever I try to did something with Git, every programming source that I could find always solve the problem using Git command line and for me Git command line was way too scary to start with. After last week and this week lecture I feeling like I'm gonna go for Git command line from now on since I understand about the staging area and looking git as a camera capturing snapshots of our project really help me to visualize the procedure. One week and already feeling better and a bit more comfortable to work with Git
Lab 2 - 6502 Assembly Language 
Tags: beginners
Published: 2021-09-24 04:20:44

In this blog, I am going to show some basic 6502 Assembly code examples and how do they work. It will shows how you can draw a green line across the top of the **bitmap** screen and a blue line across the bottom of the page. Moreover, I am also going to show you how to draw a yellow line down the left side of the screen and a purple line down the right side. Let's get started!

## Bitmap Code
![Bitmap Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26xvpsnudueuvkppc2yn.JPG) This code will make the whole page become *yellow* by increasing the index, which helps to indicate the location of the page and make that bit yellow. In order to make a green line across the top and a blue line across the bottom of the page, I need to make some changes in the code. ![Blue Green](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bu1gcgbt6e0ik2g7if8a.JPG) In order to make this, I have to indicate where the top green line will start and at the end of the page, I will change the color to blue. And there are also two yellow and purple line down the left and right respectively. ![Right Left](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9kx6hd6wzz3uugtdn1h.JPG)

Overall, this is the first time I have touched Assembly Language, compared to other languages such as Javascript, C++, everything is totally new to me. 6502 Assembly Language is basically about bits and bytes, the commands of this is a bit difficult to me personally since it is hard to remember the order of the command. However, I will try my best to remember them, so I do not have to switch to another page to see the command and come back to my program when coding.
How To Avoid TokenMismatchException On Logout In Laravel
Tags: laravel, laravel8, errors, beginners
Published: 2021-09-24 03:28:31

In this example we will see how to avoid TokenMismatchException on logout in laravel. Many time we faced TokenMismatchException error in laravel. this error occured If you stay too long time on one form or if your system stay on idle or you are not active on your computer, and then again try to fill this form.

At that time you may get a TokenMismatchException error, because the CSRF token won’t be the same. recently many time we found this problems in logout time. So, In this example I will show you to how to solved TokenMismatchException error in laravel.

Normally, if you are not active for long time in your system then you will get error like below screen print.

![How To Avoid TokenMismatchException On Logout In Laravel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rmrj9qj4htoxsxldyz7w.png)

To avoid TokenMismatchException error, we may add exceptions for the URLs that we don’t want to have CSRF protection. There are special array for that – in App/Http/Middleware/VerifyCsrfToken.php

```
class VerifyCsrfToken extends Middleware
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        //
    ];
}
```

So what we need do, just add logout into this array.

```
protected $except = [
    '/logout'
];
```

If you want to add more URLs then you can add here, but  CSRF protection is also important.

---

You might also like :

- **_[Read Also : How To Install TinyMCE Editor In Laravel](https://techsolutionstuff.com/post/how-to-install-tinymce-editor-in-laravel)_**

- **_[Read Also : How To Get Current User Location In Laravel](https://www.techsolutionstuff.com/post/how-to-get-current-user-location-in-laravel)_**

- **_[Read Also : How To Generate Barcode In Laravel](https://www.techsolutionstuff.com/post/how-to-generate-barcode-in-laravel)_**
dockerファイル作成
Tags: docker, 環境構築, キャッシュ
Published: 2021-09-24 02:51:45

## dockerファイルとは

Docker イメージというコンテナの土台となるファイルのこと.
- [イメージに関するドキュメント(ja)](https://docs.docker.jp/engine/userguide/dockerimages.html)

## dockerファイルの基本的なコマンド

- [コマンドに関するドキュメント(ja)](https://docs.docker.jp/engine/reference/builder.html)

- FROM
    OSを指定する.

    ```linux
    FROM ubuntu:latest
    ```

- RUN
    使用するパッケージの指定とパッケージ保守プログラムを記載.

    ```linux
    RUN apt-get update && apt-get install -y ruby ruby-dev
    RUN gem install sinatra
    ```

- CMD
    Dockerを起動した時に走らせるプログラム

    ```linux
    CMD ["/bin/bash"]
    ```

- COPY

     ```linux
    COPY something /new_dir/
    ```

## 実際に作成してみる

### ディレクトリ作成

```linux
mkdir docker
```

### dockerファイル作成

```linux
touch Dockerfile

# 今回の実習でCOPYするファイル
touch something
```

### dockerファイルにプログラムを書き込む

```linux
# OSを指定する
FROM ubuntu:latest

# パッケージをインストール 「\」は改行しても１行とみなされる.
# 「&&」は複数のコマンドを同時実行 １行でまとめることでレイヤーを少なくする.
RUN apt-get update && apt-get install -y \
    bzr \
    cvs \
    git \

RUN mkdir app
COPY something /app/

# run後に走らせるプログラム shellを起動させている
CMD ["/bin/bash"]
```

### buildしてイメージを作成

```linux
# .はカレントディレクトリを指定している.
docker build .

# 作成できているか確認
docker images
```

### runしてパッケージがインストールされているか && somethingファイルが存在するか確認

```linux
docker run -it <image id>

# docker内でパッケージとファイルを確認 パッケージはbin/〜
ls
```

### キャッシュをうまく使う

下記のように１行で記述すると、レイヤーの数を削減できるがパッケージの追加や編集の際にいちからbuildしてるとインストールに時間がかかってしまう。

```linux
RUN apt-get update && apt-get install -y \
    bzr \
    cvs \
    git \
```

ファイル編集時や構築時にはすべて１行づつ記述する.
キャッシュにより前回インストールしたものはインストールせずに進むため時間短縮になる。
すべてのプログラムが動くことを確認してから１行でまとめるのがベストプラクティス

```linux
RUN apt-get update
RUN apt-get install -y bzr
RUN apt-get install -y cvs
RUN apt-get install -y git
```

### exit code :100

一度buildした後、再度ファイルを編集してbuildすると、エラーが起こる.
理由は不明だが、updateを記述しない状態でbuildするとエラーが発生する.
updateを記述することで解決する.

```linux
RUN apt-get update
RUN apt-get install -y bzr
RUN apt-get install -y cvs
RUN apt-get install -y git
```