teleren/devto huggingface dataset:
Advent of code - Day 18
Tags: javascript, typescript, adventofcode
Published: 2020-12-19 11:14:59

Are you participating in the [Advent of code](http://adventofcode.com) this year?

If you don't know what the advent of code is, it's a website where you'll find a daily challenge (every day it gets harder). It's a really fun event, you should participate!

I try to solve the exercises using either JavaScript or TypeScript and will share my solutions daily (with one day delay so no one can cheat!). I only share the solution for the second part.

This one was super fun! I't just a question of priorities and RegEx, but it took me a while to have it working properly.

Not going to lie, I took the easy way and used `eval` to calculate the expression as soon as I had them in the right order!

Here is my solution for day #18:
```js
function run(str) {
  // + operations
  if (str.match(/\d+ \+ \d+/)) {
    const substr = /\d+ \+ \d+/.exec(str)[0]
    return run(str.replace(substr, eval(substr)))
  }
  // if there is a number alone in a parenthesis, remove the parenthesis
  if (str.match(/\(\d+\)/)) {
    const aloneNumber = /\(\d+\)/.exec(str)[0]
    return run(str.replace(aloneNumber, aloneNumber.slice(1, -1)))
  }
  // otherwise extract the content of a parenthesis
  if (str.match(/\(\d+( [\*,\+] \d+)+\)/)) {
    const parenthesisContent = /\(\d+( [\*,\+] \d+)+\)/.exec(str)[0]
    return run(str.replace(parenthesisContent, run(parenthesisContent.slice(1, -1))))
  }
  return eval(str)
}

console.log(input.reduce((acc, str) => acc + run(str), 0))
```

Feel free to share your solution in the comments!

________________________

Photo by [Markus Spiske](https://unsplash.com/@markusspiske?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText)
More than 9 hours spent on dev work so far in this dohackathon
Tags: dohackathon
Published: 2020-12-19 11:14:31

---
series: Building GoGreen on DigitalOcean App Platform Hackathon Series
cover_image: 
---
 

Last modified 2020-12-19 19:10 SGT


I don't want to write a lot today. Just want to update how I have been spending my time on this #dohackathon. More updates next time.

## Time spent thus far 🕒

For first-time reader, this is the section where I explicitly share the time spent. This is to set realistic expectations for readers and myself. 

Total time so far: 12.95 hr
Dev work so far: 9.1 hr
Writing so far: 3.85 hr

| Date | Work      | Time |
| ------------ | ----------- | ----------- |
| 2020-12-19 Saturday    | Writing | 0.1 hour |
| 2020-12-19 Saturday    | Dev work | 0.5 hour |
| 2020-12-18 Friday    | Dev work | 0.1 hour |
| 2020-12-17 Thursday    | Dev work | 1.25 hour |
| 2020-12-16 Wednesday    | Writing | 1.25 hour |
| 2020-12-15 Tuesday    | Dev work | 2.25 hour |
| 2020-12-14 Monday    | Dev work | 1.5 hour |
| 2020-12-13 Sunday    | Writing | 0.5 hour |
| 2020-12-13 Sunday    | Dev work | 2 hour |
| 2020-12-12 Saturday    | Writing | 2 hour |
| 2020-12-12 Saturday    | Dev work | 1.5 hour |

### 2020-12-19 Saturday
1. Separate requirements.txt into base.txt, local.txt, and production.txt (0.5 hr)
2. Write up time spent (0.1 hr)

### 2020-12-18 Friday
1. Make code changes to include the github provider using allauth (0.1 hr)

### 2020-12-17 Thursday
1. Try out the DO support suggestion on how to customize the `dockerfile_path`. Failed 🛑
2. Install `django-allauth` in preparation to add github login to my app. Success ✅
3. Try out the theory on using doctl to update the app sec and success
3. Total spent is (1.25 hr)


### 2020-12-16 Wednesday
1. Write a 3rd post in the series in DEV (1.25 hr)

### 2020-12-15 Tuesday

1. Add a `frontpage` app, `static`, and `staticfiles` folder in codebase to experiment (1.25 hrs)
2. Make the landing page to work finally (1 hr)

### 2020-12-14 Monday

1. Work on environment variables and gunicorn successfully. Fail to get the admin page up though (1.5 hrs)

### 2020-12-13 Sunday
3. Trying out Nate suggestion involving Docker and Django on DOAP (0.5 hrs)
4. Writing second post on DEV (0.5 hrs)
5. Trying out the codefresh example as suggested by Dikshith (1 hr)
6. Wrote a new ticket and purchased a managed DB cluster on DigitalOcean (0.25 hr)

### 2020-12-12 Saturday
1. Trying out how to deploy from GitHub to DOAP and other engineering stuff (1.5 hrs)
2. Writing on DEV and figuring out how to write in DEV (2 hrs)
no operator found which takes a right-hand operand of type
Tags: cpp, oop, programming
Published: 2020-12-19 11:11:33

The binary error occurs when the programmer forgets to include a string which is a sequence of characters, variables, or symbols. When a string is not used, the compiler indirectly imports parts of a string into its iostream which renders the process unreliable. The iostream can also break because the operator lacks strings to implement the algorithm. An operator is a symbol that tells the compiler to perform a specific mathematical function or a logical operation. There are different operators in the C++ programming language:

---
title: no operator found which takes a right-hand operand of type
tags: cpp
canonical_url: https://kodlogs.com/blog/1923/no-operator-found-which-takes-a-right-hand-operand-of-type
---

* Arithmetic operators 
* Relational operators 
* Logical operators 
* Bitwise operators
* Assignment operators 
* Misc operators

##More info
A programmer is always supposed to include and specify the operator in the syntax for a program else the error of no operator found. 

Another reason you can get such an error is that the operator is overloaded, which results in user codes behaving abnormally. Sometimes when there is a mismatch or the rules of operators are not observed between the left-hand and right-hand operands, similar errors occur and user codes cannot run. 

The basic concept when using operators is that they should be assigned and defined to a class and the former should have a copy of the constructor and an assignment operator defined.

Illustration; 
`
Point :: Point (const Point&);

and

Point& Point :: operator= (const Point &);
`

##Example
```
#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
    string title = "THE WORLD OF PIRATES";
    cout << title << endl;
    cout << " Welcome to the world of pirates";

    cin.get();

    return 0;
}
```
Error is defined as 

```
binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
```
###Solution
Here we forget to #include <string>

std::string can work without including header file in some compilers because they directly import parts of <string>. They can also break when we try to output the string since they only include a part of the implementation and the operator « was missing from the implementation.

Hope this helps.
Difference Between var and let in Javascript
Tags: javascript
Published: 2020-12-19 11:02:48

Before es6, we would only have 'var' to declare variables. But now we are given `var', 'let', and 'const', but we will only talk about differences between 'var' and 'let' in this.

There are issues with 'var' that may have led to the development of 'let'. They both are variable assignments but 'let' is more strict.

Using 'var' allows you to declare, redeclare, and update all within the same scope.

```javascript
var num = 0
var num = 1
num = 2
console.log(num)
// prints out 2
```

'var' will not throw an error for reassignment. We may overwrite an important variable.
If we used 'let'

```javascript
let num = 0
let num = 1
```
this will throw a redeclaration error. The case of updating using 'let' will not throw an error though.
```javascript
let num = 0
num = 1
```

Another difference is how they work with scope. 

```javascript
var tool = "hammer"
var num = 0
if (tool == "hammer"){
    var num = 3
}
console.log(num)
// num will output 3
```
In this example, the variable is reassigned and the output is taken from inside the function which may not be what we want.

In 'let' we will keep within our scope.

```javascript
let tool = "hammer"
let num = 0
if (tool == "hammer"){
    let num = 3
}
console.log(num)
// num will output 0
```
24 Days of #JavaScriptmas.
Tags: javascriptmas, javascript, challenges, scrimba
Published: 2020-12-19 11:01:29

---
title: 24 Days of #JavaScriptmas.
published: true
description: 
tags: #JavaScriptmas #JavaScript #challenges #scrimba
cover_image: https://images.unsplash.com/photo-1544323785-2b4de8044afc?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=2550&q=80
---
Hi 👋🏻
This is Mani Kiran. (aka [@nmanikiran](https://github.com/nmanikiran))

I always wanted to start writing articles and share what I know but never thought that I would start my writing journey like this but all thanks to [@Scrimba](https://scrimba.com) and their [#JavaScriptmas] (https://scrimba.com/learn/adventcalendar) challenge.

on December 1st I joined this challenge called [24 days of #JavaScriptmas](https://scrimba.com/learn/adventcalendar) in which every day there is a project that you must solve with JavaScript, a bit of CSS, and a bit of HTML. I thoroughly enjoy doing it.

#### Here is the journey (solutions)

**Day 1.** [Candies](https://scrimba.com/scrim/co87c4e4485358dd68a7afe70)

**Day 2.** [Deposit profit](https://scrimba.com/scrim/codb94025b5c74b2a52af7e34)

**Day 3.** [Chunky Monkey](https://scrimba.com/scrim/co4914496ac1e6c067715f305)

**Day 4.** [Century from year](https://scrimba.com/scrim/co4b443feb968ed521c636d81)

**Day 5.** [Reverse a string](https://scrimba.com/scrim/co0eb4c85998a5b41069d3d8c)

**Day 6.** [Sort by length](https://scrimba.com/scrim/cod8848bd86bc0cbd118b1235)

**Day 7.** [Count Vowel Consonant](https://scrimba.com/scrim/co9a248f08d6663b8cce314b4)

**Day 8.** [The Rolling Dice](https://scrimba.com/scrim/co603417693d70fb5fb0abb94)

**Day 9.** [Sum odd Fibonacci numbers](https://scrimba.com/scrim/cofa24abfb5f61a6c18830f36)

**Day 10.**  [Adjacent elements product](https://scrimba.com/scrim/coeb7428e8fc80367895a360a)

**Day 11.**  [Avoid obstacles](https://scrimba.com/scrim/coc724526bb267d069df7768f)

**Day 12.**  [Valid time](https://scrimba.com/scrim/coc584ecd86965b162937cb7c)

**Day 13.**  [Extract each Kth](https://scrimba.com/scrim/co7b9444c9e2c67d364d44482)

**Day 14.**  [Maximal adjacent difference](https://scrimba.com/scrim/co4544712b3401d78b5e4c2d2)

**Day 15.**  [Carousel](https://scrimba.com/scrim/co69349338d4ca357bb22a7f5)

**Day 16.**  [Insert Dashes](https://scrimba.com/scrim/coe8b45f9aa1d905ca32abe0b)

**Day 17.**  [Different Symbols Naive](https://scrimba.com/scrim/co2584c7bbe410f0f345e9bc0)

**Day 18.**  [Array Previous Less](https://scrimba.com/scrim/cof2544a9a25dcb74521793c5)

**Day 19.** [Alphabet Subsequence](https://scrimba.com/scrim/co91b4090af488ec357d5d990)

**Day 20.** [Domain Types](https://scrimba.com/scrim/co3d341a9b9f89f31c0d416e8)

**Day 21.** [Sum of Two](https://scrimba.com/scrim/cof0c4b5297b0d8af4563b811)

**Day 22.** [Extract Matrix Column](https://scrimba.com/scrim/co4c945a09ded43603369fc3a)

**Day 23.** [Social Media Input](https://scrimba.com/scrim/co0034142932185a5b45d3eb7)

**Day 24.** [Test your agility](https://scrimba.com/scrim/co34b4f4cbf35f74dc6c7bfc7)
Google outage: Official explanation from Google
Tags: googlecloud, googleoutage, explanation
Published: 2020-12-19 10:59:56

You might be aware that Google had a global level outage recently which impacted all their services from YouTube, GDrive to GCP and everything in between, infact even the Google oAuth was down, that means if you tried to login/signup into any website that uses Google oAuth then it would have failed during those 47 minutes of downtime.

Some on the Twitter rightly claimed that everyone could access YouTube without login, i.e browsing from the incognito window. 
The reason why people could access YouTube without logging in was

```The Google User ID Service maintains a unique identifier for every account and handles authentication credentials for OAuth tokens and cookies. It stores account data in a distributed database, which uses Paxos protocols to coordinate updates. For security reasons, this service will reject requests when it detects outdated data.```

So what this basically means is that their central Authentication management system was affected and thats why everyone could stream YouTube videos from an incognito window since YouTube allows its users to view YouTube without logging in.


Check [this](https://status.cloud.google.com/incident/zall/20013) blog for the official transcript from Google and detailed explanation of the outage. 

---
Were you online at the time of the outage? Are you a developer? How did you do your work for those 47 minutes without Google😁? Come let's chat about this below✌️
Create a new branch and checkout immediately
Tags: git, webdev, codenewbie, beginners
Published: 2020-12-19 10:53:43

`git checkout -b <branch_name>`  
`git checkout -b bugFix`

---

**Thanks for reading 💙**  
Follow **@codedrops.tech** for daily posts.  
[Instagram](https://www.instagram.com/codedrops.tech/) ● [Twitter](https://twitter.com/codedrops_tech) ● [Facebook](https://www.facebook.com/codedrops.tech/)

Micro-Learning ● Web Development ● Javascript ● MERN stack ● Javascript  
**[codedrops.tech](https://www.codedrops.tech/)**
Kotlin, classes inside interface, interface inside classes, sealed classes, data classes and so on.
Tags: kotlin
Published: 2020-12-19 10:34:23

I recently started reading kotlin docs, it has a lot of features in oop. Its cool but at the same time i can't help but wonder why do we need this? I was doing fine with `data class`, `sealed class`, `inner class` and such but interfaces inside classes, classes inside interfaces and so on just blew my fuse. 

```
interface AnInterfaceIsJustAContractNothingMore {
    class WaitUntilYouCodeInKotlin {
        fun OhNo(): String {
            return "I cant even tell the difference anymore. Its like blending diff realities."
        }

        interface ThisWorksToo {
            class EvenThis {
                val why = "Why do i need this?"
            }
        }
    }
}
```

I am writing this to express my opinion at the same time have some opinions on how other people feel about this?
Best Google-Chrome extensions, highly recommended for Devlopers
Tags: productivity, webdev, todayilearned, discuss
Published: 2020-12-19 10:25:08

Browser extensions change the way one works. They alter facets of one's job by changing the user interface of the apps on which one relies on!
<b>A developer's complete ruckus involved in selecting an extension that could boost one daily basis productivity</b>. There are in fact a ton of extensions, which will help one deliver better websites faster.
<br>
Google Chrome, is without a doubt, the most popular browser in the world. In terms of user share, Google Chrome is well ahead of other major browsers like Mozilla Firefox, Safari, Opera, Microsoft Edge, etc. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/li96hc02y2d823z5jqt1.png)
<b>It offers a library of extensions as vast as it does, it becomes a bit troublesome for its users to handpick the extensions for their daily needs.</b>
<br>
<b>
In this article, I am going to highlight the meticulously crafted Best Google-Chrome extensions for developers!</b>

<ul>
<li>
<b><a href = "https://chrome.google.com/webstore/detail/window-resizerkkelicaakdanhinjdeammmilcgefonfh?hl=en">Window Resizer for Developer</a></b></li>


 Window Resizer lets you resize the browser window in order to emulate viewing at different screen resolutions. It’s a very useful tool, when testing if your design works on a range of screen resolutions.
<br>


<li><b><a href = "https://chrome.google.com/webstore/detail/check-my-links/ojkcdipcgfaekbeaelaapakgnjflfglf"> Check My Links</a></b></li>


So this chrome extension is great when I want to make sure that all my links are working for my blog (or other web pages for that matter).
<br>


<li><a href = "https://api.daily.dev/get?r=xenikh_32"><b> Daily Dev</b></a></li>

daily.dev is the easiest way to stay updated on the latest programming news. With daily.dev, you will get the best articles from the best tech publications on any topic
<br>

</ul>

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

<h2>I hope you like the list.</h1>
A newer version of Microsoft visual C++ 2010 Redistributable has been detected on the machine.
Tags: cpp, windows, programming, oop
Published: 2020-12-19 09:57:02

**Where?**
“A newer version of Microsoft Visual C++ 2010 redistributable has been detected on the machines'' error occurs at the installation of software that installs Visual C++ 2010 or installation of Visual C++ 2010. Microsoft Visual C++ 2010 redistributable includes CRT, standard C++, MFC, ATL, OpenMP and MSDIA libraries.

---
title: A newer version of Microsoft visual C++ 2010 Redistributable has been detected on the machine.
tags: cpp, windows
canonical_url: https://kodlogs.com/blog/101/version-microsoft-visual-redistributable-detected-machine
---

**Why?** 
The installation shows this error due to the genuine presence of a higher version of the redistributable on the system. You’re getting this error even when it isn’t installed on the machine,  why is it happening even when it is not installed on the machine? What’s the reason behind it? There is a possibility that it had been installed at some point in the past. So, there may be a remaining file of the installation that can cause unexpected behaviour.

**How?** 
There are ways of resolving this problem given below:
Uninstall any later updates by going to programs and features in the control panel. Check the installation, if it is still failing then follow the next step.
Check the logs. For a more detailed examination, enable verbose. If you don’t know how to? Don’t worry Microsoft got you here. Just follow the instructions http://support.microsoft.com/kb/223300 
Find the log formed by verbose, it is probably in ‘%LOCALAPPDATA%\temp’. File name will be as “Microsoft Visual C++ 2010 x86 Redistributable Setup_<some random numbers>.html”

There will be some lines which are responsible for indicating a newer version installed. Just go to the registry and rename it or delete it.

**Sample Log Excerpt**
```
…

BlockIf: A newer version of Microsoft Visual C++ 2010 Redistributable has been detected on the machine....
[7/10/2014, 9:44:0]A newer version of Microsoft Visual C++ 2010 Redistributable has been detected on the machine.
[7/10/2014, 9:44:0]evaluating BlockIf:

[7/10/2014, 9:44:0] And: evaluating...
[7/10/2014, 9:44:0] Equals: evaluating...
[7/10/2014, 9:44:0]Current Operation value is Installing

[7/10/2014, 9:44:0] Equals evaluated to true

[7/10/2014, 9:44:0] LessThan: evaluating...
[7/10/2014, 9:44:0]RegKeyValue: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86\Bld contains '40219'
[7/10/2014, 9:44:0]all numeric characters - canonicalizing

[7/10/2014, 9:44:0] LessThan evaluated to true

[7/10/2014, 9:44:0] And evaluated to true

[7/10/2014, 9:44:0] BlockIf evaluated to true

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

**Note:** 
If you edit the registry wrong then you can cause some serious problems and you have to reinstall OS. 

**Precaution**
Backup the registry before any modification.
Connascence - a methodical way to detect code smell
Tags: codenewbie, discuss, codequality
Published: 2020-12-19 09:51:25

At first I wanted to choose the title as "Connascence - the most intriguing concept I've heard". Because Connascence is by far the most interesting concept I've read about in the last 5 years of my career. I talked s lot about it and I'm just waiting for it to be embraced by a large part of the dev community.

Now I wrote a 3 part series about connascence here:
Part I: A methodical way to detect code smell
https://levelup.gitconnected.com/connascence-a-methodical-way-to-detect-code-smell-part-i-5450c104fea5?source=your_stories_page-------------------------------------

Part II: Connascence types
https://levelup.gitconnected.com/connascence-part-ii-types-of-connascence-35ce49f7c1b0

Part III: Connascence applied
https://pandaquests.medium.com/connascence-part-iii-connascence-applied-c1cc85ba6a5a

Read it! And then tell me what you think about it. I was totally hooked when I first heard about it. I hope you too.
Podcast Listings
Tags: healthydebate, help, podcast, productivity
Published: 2020-12-19 09:49:35

So I'm looking for your recommendations for podcasts about:
- Leadership
- Tech Leads
- Technology
- Startups
- Personal Development

I know I could Google it, which I have, but I'd like to know about individuals' opinions rather than simple "Top 10" articles based on one person's opinion.
Insert multiple rows into MySQL with PHP using foreach arrays
Tags: mysql, php, programming, webdev
Published: 2020-12-19 09:48:58

#Solution:
---
title: Insert multiple rows into MySQL with PHP using foreach arrays
tags: php, mysql
canonical_url: https://kodlogs.com/blog/448/insert-multiple-rows-into-mysql-with-php-using-foreach-arrays
---
##Code: foreach array
```
$row_data = array();
foreach($_POST['name'] as $row=>$Name) {
$issuedate=('Y-m-d');
$issuetime=('h:i:s');
$name=mysql_real_escape_string($Name);
    $id=mysql_real_escape_string($_POST['id'][$row]);
    $icno=mysql_real_escape_string($_POST['icno'][$row]);
    $route=mysql_real_escape_string($_POST['route'][$row]);
    $price=mysql_real_escape_string($_POST['price'][$row]);
    $date=mysql_real_escape_string($_POST['date'][$row]);
    $time=mysql_real_escape_string($_POST['time'][$row]);
    $username=mysql_real_escape_string($_POST['username'][$row]);
    $pax=mysql_real_escape_string($_POST['pax'][$row]);
$paxcur = $pax - $row;

$row_data[] = "(',', '$name', '$icno', '$route', '$price', '$date', '$time', '$username', '$issuedate', '$issuetime')";
}
if (!empty($row_data)) {
    $query = 'INSERT INTO issue(id, name, icno, route, price, date, time, username, issuedate, issuetime) VALUES '.implode(',', $row_data);

if (mysql_query($query))
    echo 'Successful inserts: ' . mysql_affected_rows();
else
    echo 'query failed';
} 
``` 

###The Complete Code 
```
foreach ($service as $value) {
    $stmt = $connection->prepare('INSERT into services_list (servicename) values (?)');
          $stmt->bind_param('s',$value);  
          $stmt->execute();
          $stmt->close();
                        }          
          }
 ```
```
 foreach ($service as $value) {
          $stmt = $connection->prepare('INSERT into services_list (servicename) values (?)');
          $stmt->bind_param('s',$value);  
          $stmt->execute();
          $stmt->close();
 ```
```
  foreach ($price as $euro){
          $stmt = $connection->prepare('INSERT into services_list (price) values (?)');
          $stmt->bind_param('s',$euro);  
          $stmt->execute();
          $stmt->close();   
                    }          
      }
```