teleren/devto huggingface dataset:
Goldbach Conjecture Calculator
Tags: python, computerscience, programming, functional
Published: 2021-09-17 21:11:12

```python
# goldbach_conjecture.py
#   The Goldbach conjecture asserts that every even number larger than 2 is the sum
#   of two prime numbers.
#   This program gets a number from the user, checks to make sure that it is
#   even, then finds two prime numbers that add up to the number inputted.
# by: Scott Gordon

from math import sqrt


def is_prime(n):
    """Determines whether number (n) is prime or not"""
    if n % 2 == 0 and n != 2:
        return False
    factor = 3
    while factor <= sqrt(n):
        if n % factor == 0:
            return False
        factor += 2
    return True


def goldbach(x):
    cand = 3
    while cand < x/2:
        other = x - cand
        if is_prime(cand) and is_prime(other):
            return cand
        else:
            cand = cand + 2


def main():
    print("Goldbach Conjecture Calculator\n")

    num = int(input("Enter an even natural number: "))
    if num % 2 != 0:
        print(f"{num} is not even!")
    else:
        prime1 = goldbach(num)
        prime2 = num - prime1
        print(f"{prime1} + {prime2} = {num}")


if __name__ == '__main__':
    main()
```
Photo by <a href="https://unsplash.com/@jeswinthomas?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Jeswin Thomas</a> on <a href="https://unsplash.com/s/photos/math?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
What is the DRY/ KISS Principle
Tags: beginners, programming, computerscience, cleancoding
Published: 2021-09-17 20:59:26

If you learned something new feel free to connect with me on [linkedin](https://www.linkedin.com/in/albert-bennett/) or follow me on dev.to :)

I feel like this is one of those topics in clean coding that doesn't get talked about too much, it's almost as if it's a little old fashioned and yet, once every so often I get asked about it in an interview or it comes up in conversation. So, I'm taking the opportunity to talk about it now.

Both DRY (Don't Repeat Yourself) and KISS (Keep it Stupidly Simple) are software design principles. When followed they can lead to better designed and easier maintained code. Now with adhering to any principles, I have found that they each have a time and a place and that time isn't every-time. The reason I say this is that there can be situations when following them to strictly can lead to unnecessary complexity or even OVER-KILL (think trying to swat a fly with a bazooka). We don't want that.


**The DRY Principle**
Some might have seen it as WET (Wasting Everyone's Time). To say that something is DRY is to make sure that the code written, is as reusable and small as possible. Code re-usability can be better achieved by introducing abstractions, and by refactoring the code into smaller more manageable pieces. The overall goal should be to reduce, reuse and recycle. The benefits of this is firstly to make the code look better, and easier to maintain. Also it helps to reduce the number of bugs in your software, and should help with identifying where bugs are if any occur. Again it is possible to make something overly DRY such as abstracting an already small object with little reusability, so watch out!


**The KISS Principle**
Essentially, keep methods small <20 lines. Also each method should do one thing, and only one thing (single responsibility). The benefits of using KISS is that it, again makes your code easier to maintain and also helps with readability. The simpler, more Englishly reading your code can be the better. You are coding so that someone else will read it after all. Easier to read code == easier to maintain. I'd like to think that when writing code if someone looked over my shoulder they should be able to tell what is going on like in a book... well maybe a complex book with variables in it. Also for the love of all things codey, watch out when using magic strings/ numbers. I'd avoid them altogether if you can. And that methods at most have 4 parameters in them, anymore and it is clearly is doing more than what it needs to be or you need to pass in a object that incapsulates the parameters of the method.


In conclusion each principle should be used where appropriate, and each of them should be in the forefront of your mind when developing/ maintaining software.
Collaborating via Github
Tags: opensource, osd600
Published: 2021-09-17 16:02:37

After developing my new Static Site Generator [static-dodo](https://dev.to/menghif/dodo-static-site-generator-v0-1-d5b), I was tasked to work with a classmate to review each other's code.

Hung Nguyen posted on slack that he was looking to collaborate and that he wrote his code in Node. I quickly jumped on the opportunity since my code is also written in Node and I was very interested to see how someone else approached the same assignment.

### Providing Feedback

Hung's program is called [OSD600-SSG](https://github.com/nguyenhung15913/OSD600-SSG) and it is similar to mine in functionality. I found the process of testing the program pretty straightforward. I cloned it, I followed the instructions on the README and everything worked as expected.

I found and filed some issues in his code and also messaged him on slack to understand his point of view. One example is this [issue](https://github.com/nguyenhung15913/OSD600-SSG/issues/2): the program allows as input all types of files instead of allowing only `.txt` files. It turns out that he misunderstood the instructions and so he wrote the program like that on purpose.

### Receiving feedback

This was my first time sending my code for review to a classmate instead of submitting it to a professor. I like the fact that this activity is made to learn from others and to hopefully improve each other's code.
I received some helpful feedback such as this [issue](https://github.com/menghif/static-dodo/issues/1). Using the option `-v` or `--version` on my program only showed the version number without anything else. I took that feedback and I improved the output to be:
```bash
~/repos/static-dodo (main) % static-dodo -v
static-dodo version: 0.1.0
```

### Learnings

It took me some time to go through Hung's code and to clearly understand all the logic behind it. Since the beginning of my studies at Seneca, I have done a lot of code writing but very little code reading. Everyone has a different coding style so I understand why big projects tend to use clear guidelines when it comes to code formatting (for example using [Prettier](https://prettier.io)).

Overall it was a great experience collaborating with Hung and it allowed for the both of us to go back and look at what we could have changed in our code.
Are you a Unity mobile developer? If you have a game you are looking to make PVP or Social, we might have the program for you! 
Tags: unity3d, mobile, gamedev
Published: 2021-09-17 20:55:11

Ready Games’ VIP Developer Program allows unity mobile developers a chance to take their mobile game and add PvP and social features like matchmaking, friends lists, achievements, in-game currency, and much more with ease! On top of that? WE’RE PAYING YOU TO DO IT!

What do you get: 
- $3000 participation payment to help market your game
- Marketing collateral for your game, including a logo design by one of our designers
- Initial dev fee waived for all games turned RGN for the next year
- Game promoted to 1,300,000+ RGN players on Ready Game Network
- Help from one of our Ready devs to make sure its a smooth experience
- 1$ for every RGN user that comes through and signs up to the network through their game (up to 10K) - model will change to a revenue share model once program is launched. 
 
Plus more!

 Interested? Learn more about the opportunity and apply now: https://www.thereadygames.com/dev
Building A math community.
Tags: math, javascript
Published: 2021-09-17 20:21:51

#Introduction
- This series is going to be dedicated to building and launching my first web app. Join me and let us try to to make our way through this.

###Why am I building a math community?
- Lately I have been reading a lot about neural networks and the bottom line about neural networks is if you want to understand and build your own(I do), you need to understand math. Now, one of the main ways I learn is to create blog posts. Creating a blog post allows me to take a topic and break it down into something that I understand. This is awesome with software development because the markdown syntax allows me to organize everything. However, not so awesome when it comes to math. The problem is, I haven't found a community with LaTeX support in their blog post editor. Without the LaTeX support, I can't write LaTeX notation, which really makes writing math related content hard and not an optimal experience.

###My mission statement
- With this app I want to create a community that has the ability to easily create math related math blog posts and then make those posts available to the community at large. So people like me can create posts about math, neural networks and ultimately learn from each other.

###Technology
- For the technology I am going to use React and Express for the technological infrastructure. I am unsure what I am going to use for the math related structure but I am leaning towards [MathJax](https://www.mathjax.org/). If you are unfamiliar with MathJax, don't worry I am making a blog post explaining what it is.


#Conclusion
- Thank you for taking the time out of your day to read this blog post of mine. If you have any questions or concerns please comment below or reach out to me on [Twitter](https://twitter.com/TristAndroidDev).
Reviewing Someone's Code! - OSD600 - Lab 01
Tags: opensource, javascript, node
Published: 2021-09-17 20:07:42



# Hey,

This time I want to talk about my first experience reviewing someone else’s code. My friend for this adventure was Andre Willomitzer. I found him not through our slack channel, but he contacted me personally as we know each other for some semesters already.

This lab was really interesting, because we used the same language I though our code would be similar but instead we had a lot of different logics and different optional features implemented.

# What I found checking Andre’s Code:
# [textToHTML]( https://github.com/AndreWillomitzer/textToHTML_V2)


•	**“npm install” not working.**
His json packages were not working properly, to make it work I had to install yargs manually.

•	**Check if -i input is present. If not, handle the error.**
In his program, when running it without -i arguments like: ”node textToHTML_V2.js -i ”, the program was breaking.

•	**His program was accepting only one argument as input.**
While in the release 0.1 note step 9, it says that “your tool should generate one .html output file for each input file.”. If I entered as input two .txt files, only one was generated. He claimed this was a feature, but in my opinion, it didn’t meet the release 0.1 step 9.

•	**Feature -o accept only folders on the project folder. Folders in another directory are not working.**
The -o option only worked for directories inside the root folder, if outside like in the Desktop, then the program would break.

•	**Check if -i input exist. If not, handle the error.**
If I use an inexistent file as input for his program, the program will break.


# What Andre found on my code:
# [GMOT-SSG]( https://github.com/GMOTGIT/GMOT-SSG)


 On his end, while review my project he also found some bugs on my program: 
•	**I had an unused variable on my code.**
•	**The title of my files was coming from the first line of the txt file instead of the file name.**
 
He also suggested an improvement on my -o feature, to create an output directory in case it didn’t exist, besides not being a bug, I decided to implement it while correcting the other bugs.

# Conclusion

This lab was really interesting, seeing how other people use different logic for the same problem is makes programing even more interesting. How many ways there was to make a program like this?

Besides some bugs, Andre’s program was transforming a single .txt file in HTML file with paragraphs inside <p> tags as intended and when working with a single directory, it would do the same with each file as intended. Options like -v for version and -h for help also were working fine.


Thank you for reading again!
Meet My Mentor: Kyle Simpson, Author "You Don't Know JS"
Tags: javascript, codequality, webdev, books
Published: 2021-09-17 20:06:55

When I was a junior developer totally new to the industry, I didn’t have the advantage of extensive project and internship opportunities to sharpen my skills and foster a true understanding of JavaScript. 

Kyle Simpson (aka @getify) and his _You Don't Know JS_ book series accelerated my career trajectory and so many other successful engineers in the industry.

I’d love for you to join me in helping him accelerate the trajectory his goal to publish the remaining books and his mission to keep his content free for ever. 

Join the [Kickstarter Campaign](https://bit.ly/3CkZO51) and help my mentor succeed in his dream to bring a wealth of knowledge to those eager to become JS Masters. 

You can also show your support and get **a serious discount** on the first 2 books in the _You Don't Know JS Yet_ series and his essential yet practical _Functional-Light JavaScript_ book through the following links: 

[You Don't Know JS Yet: Get Started](https://leanpub.com/ydkjsy-get-started/c/coding-career-fastlane)

[You Don't Know JS Yet: Scope & Closures](https://leanpub.com/ydkjsy-scope-closures/c/coding-career-fastlane)

[Functional-Light JavaScript](https://leanpub.com/fljs/c/coding-career-fastlane)
Inspector, a better way to debug Elixir Code
Tags: elixir, programming, debugging, debug
Published: 2021-09-17 20:03:10

**EDIT**: Since Elixir 1.14, there is a new macro [`dbg/2`](https://hexdocs.pm/elixir/main/Kernel.html#dbg/2) that substitute the Inspector package.

I have been tinkering with better ways to improve my Elixir workflow and during this journey I realized that I am, somehow, [trying to bring things](https://dev.to/marciol/execute-and-watch-elixir-tests-from-iex-3gf8) which I'm used with from other environments, the same way a foreign citizen does when living in a different country. 

Elixir prizes highly the Developer Experience, so that we have the astounding tools to generate documentation, first quality package management, and an excellent and mature build tool, and a REPL, `iex` that allows fast experiments, but I think that may I have pushed a lot the expected usage of it, in a not intended way as it was planned by the creators.

We can feel it during a `IEx.pry/0` usage, it's a pretty limited tool, if you are accustomed to use Ruby pry for example, but given that Elixir doesn't hold mutable state, maybe it isn't necessary at all, so I started to think about the root cause of my dissatisfaction and I found it.

## Debugging

Elixir is blaze fast, and we can notice it clearly when running a test suite with a lot of tests, they run really fast and the maintainers [are working hard](https://github.com/elixir-lang/elixir/issues/10983) to make it even faster, so the so called Puts debugging is more than enough.


{% twitter 690689000617603072 %}


But what really hurts is to type always and everyplace the same think, `IO.inspect/2`, passing ad-hoc variables. It's not uncommon to make several calls to `IO.inspect/2` during a debugging session, so if we improve it, enhancing the `IO.inspect/2`?




This is how [Inspector](https://hexdocs.pm/inspector/0.1.0/Inspector.html) was born, a library that makes debugging less annoying. You need only to place it in the calling site, like this:

```elixir
# If this code is on lib/my_module.ex
defmodule MyModule do
  def my_function(args) do
    awesome_var = :foo
    amazing_var = :bar
    require Inspector; Inspector.i
  end
end

MyModule.my_function(:hey)
```

And you will see in the `stdout`:

```
inspector: %{
  bindings: [
    args: :hey,
    awesome_var: :foo,
    amazing_var: :bar
  ],
  file: "lib/my_module.ex:5",
  location: "MyModule.my_function/1"
}
```

If you uses Vim or Neovim, like me, you can even make it better with a key-map:

```vimscript
nnoremap <Leader>i orequire Inspector; Inspector.i<esc>
```

I hight recommend use it running this simple command:

{% twitter 1363791170745348097 %}

Or with `mix test.watch` found [here](https://github.com/lpil/mix-test.watch)

That is it folks. Happy debugging!
Jest And Angular, Install
Tags: angular, jest, config, install
Published: 2021-09-17 21:20:59

---
title: Jest And Angular, Install
published: true
date: 2021-09-17 19:52:02 UTC
tags: angular,jest,config,install
canonical_url: https://medium.com/@redin.gaetan/jest-and-angular-cb70ad78ee3d
---

A powerful combination, you should install and try it

Hey you know we all desire to work with the best libraries. For months, I only use Jest in my Angular projects. It’s faster, less unexpected behaviors and it offers the snapshot feature which is really a must-have.

Try it yourself, you will see that you will leave Karma/Jasmine for it.

Angular 12.2 / Jest 27.2.0

### Step 1: Just install the essential

```
npm install jest jest-preset-angular --save-dev
```

### Step 2: Create a small setup file

```
cd src
touch setupJest.ts
```

### Step 3: Add only this as config

```
// setupJest.ts

import 'jest-preset-angular/setup-jest';
```

### Step 4: Add entry to the package.json

```
// package.json
{
  ...
  "jest": {     
    "preset": "jest-preset-angular", 
    "setupTestFrameworkScriptFile": "<rootDir>/setupJest.ts"
  }
  ...
}
```

### Step 5: Replace the test(s) script(s)

```
// package.json
"test": "jest",
"test:watch": "jest --watch",
"test:ci": "jest --runInBand"
```

### Step 6: Uninstall Karma/Jasmine

```
npm uninstall karma karma-chrome-launcher karma-coverage-istanbul-reporter karma-jasmine karma-jasmine-html-reporter
```

### Step 7: Test it

```
npm run test

> XXX@0.0.0 test <my-project-path>
> jest

PASS src/app/app.component.spec.ts
  AppComponent
    √ setup (2 ms)

Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 2.069 s
Ran all test suites.
```

That’s all, I hope this tutorial will help someone.

Thanks for reading. Feel free to comment.

### Learn More

[Angular for everyone: All about it](https://medium.com/@redin.gaetan/angular-for-every-one-table-of-contents-d24232940dd4)
My very first collaboration - Lab 1
Tags: opensource, webdev, beginners
Published: 2021-09-17 19:37:40

At the beginning of the course, I was introduced to Slack, which was a great app to communicate with other students in IT field. And I found [Kien](https://github.com/kiennguyenchi) writes his program in another language, which is C++ and different from my program. I end up with asking him to be my partner for this lab.

I am very interested in testing and reviewing someone's code, it is totally a new experience for me. I have a chance to know how he does his code, thoughts, logic, etc. I review his code and I come up with some [issues](https://github.com/kiennguyenchi/potato-generator/issues/1) he has. When I try to run his program based on his instruction, it takes a while because he gives improper syntax. We already discuss about how we could get rid of it. The reason why it happens is because he initially puts **pgprogram fname** instead of **./pgprogram fname**, the machine does not know where to execute the command.

Additionally, he uses *Visual Studio* to do his code, so when I clone his code to my machine and open it in *Visual Code*, I have to install **C/C++** extension, but he does not mention it in his instruction. Other than that, his code is short and explained, which is easy for me to catch what is happening in this program.
Kien also comes up with some [issues](https://github.com/tcvan0707/txt2html/issues/1) I have in my program. Initially, I put all the text file into a single paragraph tag, I fix this one by correcting regex in my function, I mix up **[]** and **()** in my program.

Overall, this is my first time reviewing and testing my peer's code, which is an interesting experience for me and I think for Kien as well.
The day in the life of a new consultant
Tags: javascript, career
Published: 2021-09-17 19:36:36

I am at my core a developer, always have been, always will be, my role at ForgeRock, a company largely focused on identity management, is the only one of its kind, I am, 🥁 a "web development consultant" which means,due to popular demand, I am the JavaScript guy.

What we do is so vast, it's often said that you would take 10 years to learn all of ForgeRock inner workings, and I think it's true, people frequently stay for years and they are happy too, we are a family and I am glad of that, family values means that I can maintain my complex home life with the work life.

"What do I do?" No seriously, that's a question I ask myself almost hourly, I mentioned the complexity, well, I may have a customer call coming up, so I tend to swat up, but I'm not a big reader, experience goes a long way so I ask around, the solution may have already been found..  so ask, ask until your blue in the face, if your team is truly a team, they will be more than happy to help.

"What do I know?", Being an ex developer means that I have worked on some of the features I now tell customers about.. for better or worse, that can have some advantages. I landed this role because like everything I have done so far has been to go above and beyond, dive into anything, make opportunities and emmerse myself in every aspect of the business, it's a little overwhelming but it's okay to be.

"What do I like about my job", I see lots of different frontend projects wrote by other companies, that means, I have to know React, Angular and Vue and vanilla, I will switch all day which is really fun. our customers make decisions that are often cool to observe, I learn some good tricks too.

"Do I develop?", yes, oddly enough I do inovate and am designing a bunch of SDLC tooling so everyone can extend our platform, launching that into the community will become a great source of inspiration.

"Can I talk to you" as a developer with introvert tendencies, I do tend to panic but I have learned to take charge of situations and appear confident just by talking slowly, calmly and taking my time, a lion doesn't rush to pounce and all that. Take your time.

In summary, I have so so much to learn, and sometimes I miss just being in a silo protected by managers but being a consultant is challenging and when I grew tiered of development on a sprint treadmill, this filled that need, and then some. Maybe consultancy is for you?

Regards
Adam 🤘
What was your win this week?
Tags: discuss, weeklyretro
Published: 2021-09-17 19:11:18

---
title: What was your win this week?
published: true
description: Got to all your meetings on time? Started a new project? Fixed a tricky bug?
tags: discuss, weeklyretro
cover_image: https://cl.ly/188e843c2985/download/Image%202019-02-15%20at%202.36.37%20PM.png
---

Hey there! 


Looking back on this past week, what was something you were proud of accomplishing?

All wins count — big or small 🎉

Examples of 'wins' include:

- Starting a new project
- Fixing a tricky bug
- Trying out a new creative hobby... or whatever else might spark joy ❤️ 

---

Happy Friday — and congrats on your wins! 🎊 

![Kip from Napoleon Dynamite](https://media.giphy.com/media/nXxOjZrbnbRxS/giphy.gif?cid=ecf05e47p2rkuxal6lhee9m9es30pnlge97qyw36vbj3r4s7&rid=giphy.gif&ct=g)
React Datatable
Tags: react
Published: 2021-09-17 19:01:04

Hello, I'm learning React and wondering if anyone can point me to a datatable that I can use that is similar to JQuery Datatable or can I use that exact one in my project? I'm calling my data from an WebAPI and getting JSON back. I'm trying to use the react-datatable, but with no luck. I need to add checkboxes, and some dropdowns, however, I can't see how I can. Can anyone point me to some examples or a working React Datatable component that allows checkboxes, edit, delete, sorting, paging, etc. ?