teleren/devto huggingface dataset:
The Ideal Stocking Stuffer
Tags: adventofcode, algorithms, programming, javascript
Published: 2022-09-22 15:19:31

## [Advent of Code 2015 Day 4](https://adventofcode.com/2015/day/4)

## Part 1
1. How about *another* game of Chess?
2. Re-writing...
3. Waiting...

### How about *another* game of Chess?
- This puzzle is déjà vu!
- I solved it eight times as part of [2016 Day 5](https://adventofcode.com/2016/day/5)!
- So...solving it once should just be another waiting game!

### Re-writing...
My algorithm in pseudocode:
```
Import my MD5 library
Set index to 0
Do as long as the first five characters in the generated hash are not zeros
  Increment index by 1
```

My algorithm in JavaScript:
```js
const MD5 = require('crypto-js/md5')
let index = 0, input = 'abcdef'
while (MD5(input + index).toString().slice(0,5) !== '00000') index++
return index
```

### Waiting...
- It took a couple of seconds to run
- Then generated the correct answer!

## Part 2
### Six zeroes? No problem!
My algorithm in JavaScript:
```js
const MD5 = require('crypto-js/md5')
let index = 0, input = 'abcdef'
while (MD5(input + index).toString().slice(0,6) !== '000000') index++
return index
```

- It took several seconds to run
- Then generated the correct answer!

## I did it!!
- I solved both parts!
- Using a snippet of an algorithm I wrote in a nearly-identical puzzle from the prior year!
- I wrote what may be my shortest Advent of Code program yet, at just four lines when condensed!
The list problem
Tags: programming, python, testing, algorithms
Published: 2022-09-22 15:18:43

I've been working on this algorithm since I learned how to write arrays in C, and I can't seem to see through what I'm missing. The algorithm is an attempt to make all the possible fixtures in a 20-teams League (EPL) if all teams are to play each other home and away once a week. That'll make 10 matches a week if all teams play, 38 games per team (38 weeks) that's 380 games total. 

## The challenge

- A team can't play twice in a match week (20 teams can only make 10 matches), 
- No same fixture is to be repeated. 

## The problem
In other to avoid any repetition, I check if the fixture and both teams have not been previously selected, But then the result shows 10 games each for the first 6 weeks, 8 for the next 9, 10 for the next 3, to 4 games for the last 2 weeks, and a total of only _320 fixtures is selected_.

## Observation
Over the years I've tried different implementations in different languages, ranging from java, python, php, javascript, and c with no solution. 
**Then I decided to shuffle the fixtures and the selected fixtures were in a range of 360 to 369 in 10 different runs**. Why the change of heart?

**_Is this a list problem or there is simply a better way?_**

```
teams = ["ARS", "AVL", "BRE", "BOU", "BRI",
        "BUR", "CHE", "CRY", "FUL",
        "EVE", "LEE", "LEI", "LIV", "MCI", "MUN",
        "NEW", "TOT", "WHU", "WOL", "WAT"]

#All 380 possible fixtures len(fixtures) prints 380
#Shuffle this to see the change
fixtures =  [f"{home} - {away}" for home in teams for away in teams if home != away]

#38 match weeks if 10 matches are played every week. Each team plays only once per week
match_weeks = []

#Fixtures played // no same fixture is to be played twice
#i.e ARS - CHE can appear only once per season, but CHE - ARS only
s_fixtures = []

#Making fixtures for all 38 weeks
for i in range(38):
    match_week = [] #should be exactly 10 unique games every week = 20/2
    s_teams = [] #teams already selected in the current week // 20 teams every week
    for fixture in fixtures:
        if len(match_week) == 10: #to save some iterations/time 
            break
        if fixture not in s_fixtures:
            home, away = fixture[:3], fixture[6:]
            if home not in s_teams and away not in s_teams:
                s_teams.extend([home, away]) # add teams to selected list
                print(len(s_teams))
                match_week.append(fixture)
                s_fixtures.append(fixture) #add fixture to selected list
    match_weeks.append(match_week)
```
Wanxiang Blockchain kicked off a 7-day blockchain summit
Tags: web3, blockchain
Published: 2022-09-22 14:56:34

# Summit
A lot of Web3 leaders will be sharing at the summit, non-exhaustive list:

- Dominic Williams: Founder & Chief Scientist at DFINITY Foundation

- Juan Benet: Protocol Labs Founder and CEO

- Miguel Palencia: COO & Co-Founder at Qtum Chain Foundation

- Illia Polosukhin: NEAR Protocol Co-Founder

- Sergey Nazarov: Chainlink Co-founder

- Sam Williams: Arweave CEO

The summit will last from Sep 20 to 28, join the livestream and enjoy the inspiring sharing from our speakers at:
https://www.wxblockchain.com/week2022/live?lang=en-US#/

# Bonus
Before the summit, Wanxiang Blockchain held a Hackathon, and will announce the results at the end of the summit.

The 47th team called Wonderful developed a project named  Metaworship. They want to build a Metaverse for worship, aiming to reduce the land waste, to reduce the air polution caused by traditional Chinese worship practices, to save time for people to travel to places of worship, and to construct a metaverse that is complementary to reality.

Get points from watching summit live, and vote for team **Wonderful**, you will have the probability to get wonderful prize, including DJI Air 2S Drone, Mi Smart Projector 2, Switch oled etc.
Reading stdin per character in NodeJS (asyncConfirm)
Tags: node, javascript
Published: 2022-09-22 14:39:06

I bumped into this problem while I was writing a simple confirmation function. Looking to the documentation, I could not find any helper function that allows me to read only a single character from stdin. Therefore, I build a simple asyncConfirm function that allows user to confirm based on user input.

Here is the gist that contains the complete very basic example and a little description can be found below the example.

{% embed https://gist.github.com/tevfik6/823aa33a585b6b1c793050b9768e1a83.js %}

Basic idea behind my approach reading stdin with a specific limit(3 bytes) of buffer using Promises to allow async functionality. Based on giving yesOptions returns boolean false or true.

The example is tested only in unix platforms. You might need to tweak it for other platforms.
Big O Notation in summary 💪.
Published: 2022-09-22 14:33:35

---
title: Big O Notation in summary 💪.
published: true
description: 
tags: 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

O(1) = runs a constant operation once.

O(n) = repeats a constant operation n times.

O(logn) = runs a constant operation on a fraction of the input

n^2 = repeats O(n)  n times.

2^n = doubles the current operation by the next operation

Examples:

O(1) = an operation with no loop or recursion.

O(n) = an operation with a loop.

O(logn) = binary-search

O(n^2) = 2 nested loops.

O(2^n) = Fibonacci with recursion & without memoization.
Create a countdown using recursion (FreeCodecamp notes)
Tags: javascript, programming, tutorial, recursion
Published: 2022-09-22 14:19:52

Below is an example on how countup is down using recursion

```javascript
unction countup(n) {
  if (n < 1) {
    return [];
  } else {
    const countArray = countup(n - 1);
    countArray.push(n);
    return countArray;
  }
}
console.log(countup(5));
```

The above function is best explained here https://www.youtube.com/watch?v=p-cj4Vh8cMg

**The important thing to note is , that the array elements start adding from 1 onwards , the countup(4) waits till countup(1) is done.**

Use the above as an example and create a countdown function so it returns n to 1 numbers in an array when we pass n in countdown(n) 

Things to consider, if you have no idea about unshift, you would try to add an element to an array by declaring a new array everytime the function is called , and it is not gonna work, but if you have an idea on how to use arguments you could solve this as follows 

```javascript
function countdown(n, newArr=[]) {
    if (n <= 0) {
        return newArr;
    }
    newArr.push(n);
    return countdown(n - 1, newArr)
}

console.log(countdown(5));
```
So thats how you pass the argument array with its elements in the recursive function.

Now the shortest /imo best solution is using unshift in array methods as below , unshift does the same as push but in the opposite order , so it works out well.

```javascript

function countdown(n) {
  if (n < 1) {
    return [];
  } else {
    const arr = countdown(n - 1);
    arr.unshift(n);
    return arr;
  }
}
```
[GDB-Quick] Using Eclipse Standalone debugger GUI
Tags: debug, cpp
Published: 2022-09-22 14:08:09

---
title: [GDB-Quick] Using Eclipse Standalone debugger GUI
published: true
description: Eclipse Debugging CDT for C/C++ source code
tags: debug,cpp
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---
GDB is debugger that comes with basic functionality of doing everything command line. GDB-TUI provides basic Text UI for debugging source codes with minimum dependencies. At times, Window-GUI is much help to look at much information at snapshot, edit it, view it without explicitly typing all commands and shortcuts.
Here is how we can use eclipse-cdt as standalone debugger.
No need to create projects!

>> Download Eclipse-CDT package
>> Unzip  Eclipse-CDT.zip
>> switch to unzipped folder eclipse\plugins\org.eclipse.cdt.debug.application_*\s
cripts
>> /bin/sh  ./cdtdebug.sh

This will install debugger into your $HOME/cdtdebugger/ area  

Now Connect to local process with GUI prompt. No need to list process on terminal then type process id!
$HOME/cdtdebugger/cdtdebug.sh  -a

Connect Remote Process
$HOME/cdtdebugger/cdtdebug.sh  -r address:port

Debug binary
$HOME/cdtdebugger/cdtdebug.sh  -e executable


Read More at [https://wiki.eclipse.org/CDT/StandaloneDebugger]
[https://www.infoq.com/presentations/best-practices-cdt-debugger/]
Enjoy!
HTH!
Simple Implementation of a Trie data structure.
Published: 2022-09-22 13:35:28

Trie is a type of k-ary search tree, a tree data structure used for locating specific keys from within a set. 

Trie is implemented as a nested dictionary. Every insert a new temp dictionary is created for nesting, and Trie is a dictionary of dictionaries.  Trie can be identified as data structure with four building blocks.

Here are the components of our trie building block

**make_trie.**

Input: list of words
Output: Trie
Process: Creates a top of dictionary, and calls add_word to the dictionary for each word.


**add_word**

Input: A trie, and a word to add.
Output: A nested dictionary with the word added.
Process: Make a copy of the dictionary in the parameter. For each character of the word, nest further either by getting value dictionary or creating a new value dictionary. Add a Marker to signify end of word addition.

**is_word**

Input: A trie and a word to test
Output:  True if the word is present in the dictionary.
Process: Work with a copy to keep nesting until the end of word. If a character is not found return False. Finally, end of word should have "end_marker" key.

**is_prefix**

Input: A trie and a word to test
Output: True if a word is a prefix
Process: Same as is_word, all characters must exist, but the end_marker need not be present when we complete traversing the word.

Building a Trie using Python.

```python

import json

_end_marker = "*"

def add_word(trie, word):
    word_trie = trie
    
    for ch in word:
        if ch in word_trie:
            word_trie = word_trie[ch]
        else:
            word_trie[ch] = {}
            word_trie = word_trie[ch]
    
    word_trie[_end_marker] = _end_marker

    return word_trie

def make_trie(*words):
    trie = dict()

    for word in words:
        add_word(trie, word)
    
    return trie

def is_word(trie, word):
    word_trie = trie
    for ch in word:
        if ch in word_trie:
            word_trie = word_trie[ch]
        else:
            return False
    return _end_marker in word_trie

def is_prefix(trie, word):
    word_trie = trie
    for ch in word:
        if ch in word_trie:
            word_trie = word_trie[ch]
        else:
            return False

    return True

def print_trie(trie):
    print(json.dumps(trie, sort_keys=True, indent=2))

trie = make_trie("hi", "hello", "help")

print_trie(trie)

print(is_word(trie, "hello"))
print(is_word(trie, "he"))
print(is_prefix(trie, "he"))
```
**Output**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u1ouas6jf1qkwibmpsd9.png)


Here is a visualization that will help us understand the state, when "hi", "help" and "hello" are inserted into the trie. "*" is the end-word marker, so after hi and help, the pointer leads to "*", but the characters h, e, l, will extend further to create "hello".


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2w68ghh12e2w9s0b7ov5.png)
Shipping to Production - Product
Tags: management, productivity, architecture
Published: 2022-09-22 13:12:47

At [Woovi](https://www.woovi.com), we focus in to deliver the best cost x benefit for new features. And, with our core principles in mind, even before coding, we start to sharpen the best solution for our clients.

The following content will focus on giving a piece of context about the sipping to production process inside Woovi.

To assist us during this series we thought we'd have an example close to what we have in a real production case, I picked up an original Woovi product to use in this blog post.

**Product**
The first step is understanding if the feature makes sense for our customers and if it aligns with what we want for our product.

Most of the time, customers ask for features they don't need. In other cases, for features, the platform already has but doesn't know.

Based on this, we start to abstract what the customer needs or the new feature even before coding and understanding our next steps.

For example, when we started our startup, our payment plugin was one of the top products we needed.

What we need:
- Be able to create a new Pix Charge or Pix QrCode
- Show the necessary information
- Real-time
- Updates when receiving the payment to be completed
or updates the UI to expired if not paid at the time

With the MVP in mind, we start to build our product and you will follow the process in these series.

If you like this blog post, come work with us, we are [hiring](https://www.woovi.com/jobs)!

**Woovi**
[Woovi ](https://www.woovi.com)is a Startup that enables shoppers to pay as they like. To make this possible, Woovi provides instant payment solutions for merchants to accept orders.
7 Mistakes to Avoid Before Outsourcing Web Development
Tags: webdev, devops, beginners
Published: 2022-09-22 12:45:06


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nz7ekvnm0nqfdx2xtkbu.jpg)
A great web project needs perfect execution. Web development is one of the most popular outsourced IT services. It is rightly perceptible as about 300,000 jobs get outsourced out of the US each year.
 
However, the projects for web development face different challenges at some or the other step of the development cycle.
 
So, here arises a big question.
Is it Easy to Choose a Trustworthy Web Development Outsourcing Partner?
 
Well, good outsourcing partners aren’t easy to find. But, knowing the right process makes it quite easy. For any business that outsources web development, it impromptu renders its accountability. Substantially, it is a long-term, contractual relationship that needs thorough research to hand-pick a trustworthy and accurate partner for web development. 
 
There are several pitfalls, that you should be aware of before selecting an outsourcing web development company.
The 7 Biggest Mistakes to Avoid Before Outsourcing a Web Development Project
 
The following are the 7 most common mistakes businesses make when outsourcing web development:
 
Ambiguity in the project concept 
Loss of Project Control
Not checking for the needed skills in your resources
Unplanned budget and deadline setup
Not paying attention to client recommendations
Reluctant communication with the service provider
Avoiding official documentation
JavaScript: Closure, variables & hoisting
Tags: javascript
Published: 2022-09-22 12:40:17

**Closure**

I will try to get a shot at explaining these three things because these are mostly asked during interviews so hang around a bit.

Closure is, to simply say is the boundary of each function on JavaScript between the two curly braces or "mustaches" for its own variables.

Consider this example.

`let name = 'Sally';`

`function greeting() { 
    let message = 'Hi';
    console.log("Greeting:",  message + ' '+ name);
}`

That function will log "Hi Sally" because "name" is a global variable and it is accessible inside the function. 

But if you try:

`let name = 'Sally';`

`function greeting() { 
    let message = 'Hi';
}
console.log("Greeting:",  message + ' '+ name);`

It will put out "ReferenceError: message is not defined" error because the message variable is not referenced outside of its enclosing function. No leaking out it is.

You can find more advanced closure explanations [here].(https://www.javascripttutorial.net/javascript-closure/) 


**Variables**

Variables in JavaScript are just like any variables in other language but much more simple. It is declared by using "var", "const" or "let" keywords.

**var** is the oldest kid in the JS world. It can hold any variable type and can be changed inside a function when declared globally but it cannot be referenced outside its parent function. (See closure above) 

**const** is a variable that cannot be changed throughout your code.

**let** is block scoped to the function, expression or statement that is used.

`for(let i=0; i<10; i++){
    console.log(i)
}
console.log(i)`

The variable "i" in the above for loop will console.log fine but outside it will be undefined.
 
`for(var i=0; i<10; i++){
    console.log(i)
}
console.log(i)`

Using "var" instead of "let" lets you use "i" outside the loop so it has some uses.

**Hoisting**

MDN says: 
JavaScript Hoisting refers to the process whereby the interpreter appears to move the declaration of functions, variables or classes to the top of their scope, prior to execution of the code. Hoisting allows functions to be safely used in code before they are declared.


`console.log(i); //undefined
var i=0`

Considering the code above, log will output undefined because the variable was hoisted up prior to execution.

`console.log(i); //ReferenceError: can't access lexical declaration 'i' before initialization
let i=0`

`console.log(i); //ReferenceError: can't access lexical declaration 'i' before initialization
const i=0`

Hoisting does not work for const or let keywords so keep that in mind.

That's it for now folks! Happy coding.
freeCodeCamp New Responsive Web Design Curriculum.
Published: 2022-09-22 12:33:03

# All you need to know...

Presently I am revising CSS styles from @freeCodeCamp, and I want to commend them for improving how they tutor the new Responsive Web design curriculum. I’m currently enjoying the CSS challenges, and my experience is being enhanced by

  1. **About coursework** – First, the old coursework for the Responsive Web Design Curriculum is still intact and renamed to Legacy Responsive Web Design right at the bottom of the curriculum ladder board. In addition, your progress in the Legacy Responsive Web Design is still intact, and your certification is still valid. The new curriculum coaching has improved. That is the big difference and game changer from my end.

  2. **New editor** – The new editor works similarly to an external editor, for example, (visual studio code or sublime text) used on local computers. You must link your styles.css file to your HTML for your code to run. Additionally, you have access to both index.html and styles.css files while working. The latter provides learners with room for tracking practice progress.

  3. **Seek help** – The new version help link redirects you to a read-search-ask method which implies you can read the documentation or error, google, or ask friends. Equally, you can join the @freeCodeCamp community forum and post your issues. The old version provided a watch video when seeking help which the new curriculum does not. These improve the ability of newbies to google and develop strong problem-solving skills.

  4. **Certification** – The certification is similar to the older version, which you get upon completing five (5) certification projects. In addition, you can still claim certificates from the old version curriculum if you completed the projects or intend to finish the curriculum if already in progress.

  5. **About Project** – Five projects are done in both versions. The big difference here, however, is that in the new curriculum, you build your project after completing a given section of the CSS course and not the whole course. For example, after finishing forms, you will match onto the next CSS challenge (flexbox) before undertaking another project. I feel the latter way gets newbie devs to complete projects unlike stacking the whole five (5) projects at the end of the CSS curriculum.
WSL on Windows Server 2019
Tags: wsl, windowsserver2019, wsl2
Published: 2022-09-22 12:01:09

Did you try to install WSL2 on Windows Server 2019 through `wsl --install`?
Did you try to install Microsoft Store?

**Unfortunately it doesn't work on Windows Server 2019.**

But it has soluction.

The solution was based on the link below:

1. [Microsoft](https://learn.microsoft.com/en-us/windows/wsl/install-on-server);

**Just follow the steps:**
Those steps below needs to be done other and Administrator
```
cd C:\Users\Administrator\
```
Enable the Windows Subsystem for Linux 
```
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
```
Download a Linux distribution 
```
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx -UseBasicParsing
```
Extract and install a Linux distribution 
```
Rename-Item .\Ubuntu.appx .\Ubuntu.zip
Expand-Archive .\Ubuntu.zip .\Ubuntu
```
Add your Linux distribution path to the Windows environment PATH 
```
$userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")
[System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:\Users\Administrator\Ubuntu", "User")
```
Start installation (change directory to directory where is ubuntu.exe)
```
ubuntu.exe
```

If is it usefull, please leave your comment or suggestion.
If it doesn't work, let's try together