teleren/devto huggingface dataset:
How to test in Haskell: HSpec setup
Tags: haskell, beginners, testing
Published: 2019-12-15 08:42:09

---
title: How to test in Haskell: HSpec setup
published: true
date: 2019-12-14 00:00:00 UTC
tags: haskell,beginner,testing
canonical_url: https://dannypsnl.github.io/docs/how-to-test-haskell/
---

Before you start to read, ensure you're using Cabal >= 3.0 to manage your project.

For a **Haskell** project, I usually use Cabal, do not have any special reason. In the `xxx.cabal` file, we can define some common dependencies by `common` block:

```
-- just let you know how does the file should look like
-- with full content people can understand the structure better
cabal-version:       3.0

name:                your-module
version:             0.1.0.0
license:             MIT
license-file:        LICENSE
author:              your-name
maintainer:          your-name@email.com
-- Extra files to be distributed with the package, such as examples or a
-- README.
extra-source-files:  CHANGELOG.md

-- Common block
common shared-properties
  default-language: Haskell2010
  build-depends:
    base == 4.*, mtl >= 2.2
  ghc-options:
    -Wall
```

Then we can add `test-suite` block like this:

```
-- common block at here
library
  import: shared-properties
  exposed-modules:     YourModule
  other-modules:
  -- Directories containing source files.
  hs-source-dirs:      src
  default-language:    Haskell2010

test-suite spec
  import: shared-properties
  type: exitcode-stdio-1.0
  other-modules: YourModuleSpec SpecHelper
  hs-source-dirs: test
  main-is: Spec.hs
  build-depends: hspec >= 2.7
                 , hspec-discover >= 2.7
                 , your-module
  default-language:    Haskell2010
```

Create `$project-path/test/Spec.hs` and put:

```hs
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
```

And create `$project-path/test/SpecHelper.hs` and put:

```hs
module SpecHelper (
  module Test.Hspec
) where

import Test.Hspec
```

Finally, create `$project-path/test/YourModuleSpec.hs` and put:

```hs
module YourModuleSpec where
import SpecHelper
import YourModule

spec :: Spec
spec = describe "Your module" $ do
  context "has a function add can add two nature numbers" $ do
    (add 1 2) `shouldBe` 3

main :: IO ()
main = hspec spec
```

Then run commands:

```bash
cabal new-update
cabal new-install --only-dependencies
cabal install hspec-discover
cabal new-configure --enable-tests
cabal new-test
```

We finish the setup of testing now.
neo.mjs - the webworkers driven UI framework
Tags: javascript, css, framework, webworker
Published: 2019-12-13 23:26:01

I just donated 1.5 years of my full and unpaid working time to the open source community and would love to gather some feedback!

https://github.com/neomjs/neo


![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/fv5zjnl96on1lk31wve6.png)
I still have to Google...
Tags: discuss, programming, codenewbie, beginners
Published: 2019-12-13 23:15:39

Javascript foreach loop syntax.

```JavaScript
for(var x as y) {
```

No...

```JavaScript
foreach(var x in y) {
```

Nope...

*... checks...*

```JavaScript
x.forEach(function(y) {
```

That’s the one I’m after!


Hi, I’m Jake, a lead developer. I’ve been programming for 15 years, 10 of those professionally.

This is something I continually try to get over to students/new developers. Even after all these years there are things I can’t remember and have to look up.

So, what do you have to google?
Find Factors of A number
Tags: python
Published: 2019-12-13 23:14:45

In this post I am going to share with you guys how to find the factors of a number using python.

This may help a lot of you with the for loops on action. 

So what we are going to create is a function that will take a number that we want to find its factors as a parameter and then return all the factors as a list. 

E.g:

```python
   factors = factors_of(10)
   print(factors)
```

Results:
```
   [1,2,5,10]
```

Let us get into this function.

>Step 1: Define a function

___

*Is very important to give your function an meaningful name.*
```python
   def factors_of(number):
```
The reason I chose *factors_of* is because it gives saves you time and energy to put a comment. Using meaningful name can save you from writing a comment to explain what does a function does.

___

>Step 2: Create a temporary list

___

This list is the one that is going to be returned carrying all the factors. 

```python
   temp = list()
```

Sorry I migrated to python from c#, so I am used to instantiating a data type hence I said *temp = list()* instead of *temp =[]*. But I think for memory cache purposes, list() is better than [] just append is better than +=. If I am wrong with this please feel free to comment.

___

>Step 3: Create A loop from 1 to the number

This loop must with the number we are looking it's factors. We are going to use the built-in function *range(seed,max-1,step)

```python
   for i in range(1,number+1):
```
Plus 1 because we want the number itself to be included because according to the formula of a range, the number is excluded. 

___

>Step 4: Use a condition with % operator

For us to find if a number is a factor we must find a remainder of 0 if we devide with it. Lucky we will just % to find remainder. Then we append the number to the list

```python
   #line for the loop
       if number%i==0:
           temp.append(i)
```

___

Then lets return the list.

Code is full:
```python
   def factors_of(number):
       temp = list() 
       for i in range(1,number+1):
           if number%i==0:
               temp.append(i)
       return temp
```

So if we go back to our example but with a different number let's check the results

```python
   factors = factors_of(20)
   print(factors)
```

Results:
```
   [1,2,4 5,10,20]
```

I hope you enjoyed the post and it was helpful for you. Cheers
It's obvious
Published: 2019-12-13 23:12:52

We don't discard physics because it can't reconcile what's on the other side of a black hole.

We don't discard the spherical nature of the planet because we can't see the curve from sea level.

Perspective sheds light on what may become _obvious_ later on. An _obvious_ solution is only an option with perspective. Otherwise, it's blind faith. 

Our reality - _what's obvious_ - is the result of an ever-growing account of perceptions. The larger the list, the more _obvious_ things appear to be. However...

The earth was _obviously_ flat, for thousands of years, until humanity gained a better perspective. The electron was _obviously_ theoretical until it became observable. The Black Death (plague) was _obviously_ the "fury of God" until we discovered a pathogen being spread through rodents and a lack of hygiene.

In other words, what's _obvious_ is only that way until we have the opportunity to see the world from a new - better - perspective.
My side project in Svelte
Tags: javascript, showdev, svelte
Published: 2019-12-13 22:59:56

# A community list of personal sites for inspiration

After some weeks I finished my side project.

I was thinking in a new project to start, and get the opportunity of test svelte.
Suddenly I thought about the idea of a _site where you could upload pages especially from designers, collaboratives, developers to show_.

On the site the pages sent do not pass through a filter, it is automatically uploaded. My idea was to do this and that those sites that were not in line with the page were reported for review.

![sitesshowcase](https://thepracticaldev.s3.amazonaws.com/i/uf8q34lw8lg0iz8d27ma.jpg)

I used **svelte** integrated with sapper, but I didn't give much use to the latter.
The most important thing I have to say is that they **use svelte**, it's really simple and with a lot of potential!

## Are you a designer, developer, creative or a simple curious looking for inspiration?

Take a look
🌐 [sitesshowcase](sitesshowcase.com/?ref=devto)

## Github repo:

{% github agustinl/sitesshowcase %}

**All suggestions, recommendations and criticisms will be well accepted** 🙌
And this is my first post in dev.to too 🎉
The Nightmare Before Blazor
Tags: development, blazor, c, cadvent
Published: 2022-06-15 17:24:18

---
title: The Nightmare Before Blazor
published: true
date: 2019-12-13 22:35:00 UTC
tags: Development,Blazor,C,CAdvent
canonical_url: https://barretblake.dev/2019/12/the-nightmare-before-blazor/?utm_source=rss&utm_medium=rss&utm_campaign=the-nightmare-before-blazor
---

"What better way to celebrate this C# Advent on a Friday, the 13th, than to talk about the nightmare that is web development. Devs have more ways than ever to write applications for the web. And now, into the vast wasteland of web development, rides Blazor.

The post [The Nightmare Before Blazor](https://barretblake.dev/2019/12/the-nightmare-before-blazor/) first appeared on [Barret Codes](https://barretblake.dev).
Set an inaction timeout in JavaScript
Tags: javascript, beginners, todayilearned
Published: 2019-12-13 21:50:20

I posted a question here yesterday regarding being able to set an "inaction" timeout that would reset a JS game:

https://dev.to/sehardwick/help-js-scripting-question-2cda

Happy to say that with a little guidance, Stack Overflow research, and testing, I was able to come up with a solution! 

After declaring `<script>` variables, I created a setTimeout method that called a function that was then defined with an alert and the necessary code to reset the game, and I ended up with:


```
setTimeout(functionName(), 15000) //to set a 15 second inactive period
  function functionName() 
    {
    alert("text message along with counter displaying how many correct guesses the player had")

//Remainder of code to reset the game 

    }
```


Super-psyched I finally got this to work!
What is Optional Chaining in JavaScript?
Tags: javascript, es2020, esnext
Published: 2019-12-13 21:44:00

At the time of writing this blog post, optional chaining is reached stage4 in TC39 proposals and probably will be included in ES2020. Optional chaining is a new feature that can make your JavaScript code look more clear.

When you want to reach a property of an object, usually you can use `&&` operator to avoid getting errors when the object is null or undefined.

```javascript
const city = user && user.address && user.address.city;
```

With this new JavaScript feature this syntax become better and more clear than the one above.
You can just use `?.` instead of adding `&&` operator for each level of the tree.

Code above can be written as:

```javascript
const city = user?.address?.city;
```

If user or address is undefined or null, then the value of city become undefined.
If you want to experiment this feature, you can use [this Babel plugin](https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining).

Another new feature I liked is Nullish Coalescing feature. It is kind of a complementary feature for optional chaining and also planned to be released in ES2020.

--------

You can also read this post in [my blog](https://blog.ahmetkapusuz.com/what-is-optional-chaining-in-javascript/).
Will I Reach Santa's Orbit In Time?? Advent Of Code 2019 - Day 6
Tags: challenge, adventofcode, javascript, video
Published: 2019-12-13 21:37:25

---
title: Will I Reach Santa's Orbit In Time?? Advent Of Code 2019 - Day 6
published: true
description: JavaScript walkthrough of Advent of Code 2019 (day 6)
tags: challenge, AdventOfCode, javascript, video
series: Advent of Code 2019 in Javascript
---

{% youtube nGCiUJkn_Wc %}
Best practice for Python returns
Tags: python, help
Published: 2019-12-13 21:17:07

Hi.
I have a function that should return the result of a query.
It works, but my question is related to what is the best practise.

The return value in this case is a response object from an API, that contains a value which indicate whether the query failed or not. The first question then is, should I have my function return the result of the query as it is?

For the cases where the return object says nothing about how the execution of the function went, should it also return a boolean to indicate if things went as it should?

And lastly, if I would need to return more than one variable, should they be returned as a tuple, a dictionary, or in some other way?

I haven't been programming with Python for long. I know a bit, but I lack a lot of knowledge about how to write good/nice code.
How to declare a variable? Kotlin Tutorial
Tags: kotlin, android, beginners, java
Published: 2019-12-13 20:53:42


A program is nothing without data. Let's find out how to declare a variable in Kotlin.
Stop 🛑 Do you want to learn Kotlin with me? I will post multiple times per week new things I've learned about this programming language.

There are two ways to declare a variable in Kotlin:

#1. Using the "val" keyword#
<code>// constant, immutable, read-only & final
val city: String = "Paris"</code>

Basically once we declare it we can't change it.
<code>city = "Rome" // will throw an error</code>

#2. Using the "var" keyword#
<code>// mutable variable
var country: String = "Italy"</code>

Now we can re-use the same variable. We can mutate the object.
<code>country = "France"</code>

Kotlin is smart and can guess the type for a declared variable. I think this will make you a negligent programmer in the long run.
<code>// type inference
var language = "Java"
// the compiler will know it's String</code>

Once the type is established we can't change it
<code>language = 12 // will throw an error</code>

I want these articles to be living entities, so I will edit them along the way with new/interesting I find about a particular subject.

Image by [_ferh97](https://unsplash.com/@_ferh97)
Just Start
Tags: codenewbie, growthmindset, 100daysofcode
Published: 2019-11-05 04:26:56

---
title: Just Start
published: true
description: Sometimes the best way to get things done is to lower the bar.
tags: codenewbie, growth mindset, 100daysofcode
---

I have been interested in web development and coding for a while now. Every time in my life that I've felt lost or uncertain about my future, I find my way back into coding and building upon my dev skills.

And then life happens, and I fall out of the habit, and I forget how much I enjoy learning and building new things.

Getting back into the habit can be really discouraging, especially if it's been months since I've last touched a line of code. I found myself trying to revisit old projects, but beating myself up about how much better the final product could have been if I had just stuck with it.

I've tried to build my personal website many, many times. I start working on it, envisioning a beautiful final product, and I quickly get discouraged because at this point, my skill level doesn't meet the bar I've set for myself.

It wasn't until recently that I realized it doesn't need to be perfect, I just need to do it.

I'm reminded of this excellent quote from Ira Glass:

>“It is only by going through a volume of work that you will close that gap, and your work will be as good as your ambitions. And I took longer to figure out how to do this than anyone I’ve ever met. It’s gonna take awhile. It’s normal to take awhile. You’ve just gotta fight your way through.”

I never connected with "fighting my way through" because I never gave myself the chance. Once I lowered my self-imposed expectations, I was able to build a site, work through the challenges I was facing and get something working. It may not be pretty (yet!) but I'm beyond proud of it.

My advice to you if you're in a similar situation: keep it simple, keep moving forward, your skills will get better over time.

-----------------
I originally posted this on my blog at [LaurenFosgett.com](https://laurenfosgett.com/posts/just-start/).
Foundation v6.6.1 Shipped
Tags: foundation
Published: 2019-12-13 20:49:40

I shipped v6.6.0 last week. It was a huge release. I probably should have posted about it here as well. You can get the full details [here](https://github.com/foundation/foundation-sites/releases/tag/v6.6.0).

Foundation 6.6.1 has fixes for issues introduced with 6.6
Check out the details below:

### Bug Fixes
- 🐛 [#](https://github.com/foundation/foundation-sites/pull/11925) - Fix sticky breakpoint check
- 🐛 [#](https://github.com/foundation/foundation-sites/pull/11936) - Update composer.json for packagist.org
- 🐛 [#](https://github.com/foundation/foundation-sites/pull/11938) - add missing foundation.js reference comment

### Contributors

Thanks to the amazing people who contributed code or documentation to the 6.6.1 release. Foundation wouldn't happen without you!

* [Daniel Ruf](https://github.com/DanielRuf)
* [Kai](https://github.com/SassNinja)
* [Joe Workman](https://github.com/joeworkman)
* [phpfui](https://github.com/phpfui)
Cannot filter posts by ACF relationship values
Tags: php, wordpress, advancedcustomfields, acf
Published: 2019-12-13 20:37:17

The question belongs to Wordpress and Advanced Custom Fields.

I have created two post types i.e., 'courses' and 'universities'. In courses, I created a relationship 'related_university' that connects courses to universities. However, I could not filter my courses by relationship values (title or any other field).

the following method works for me when I print the title of the related university:

$result[] = array(
            "id" => get_the_ID(),
            "title" => get_the_title(),
            "rel_university_name" => get_field("related_university")[0]->post_title,
            );

However, I get no results when I use the same method to filter my posts by the title:

$args['meta_query'][] = array(
        'key' => get_field('related_university')[0]->post_title,
        'value' => $related_university_title,
        'compare' => 'LIKE'
        );
About Jim L. McEnerney
Published: 2019-12-13 20:34:07

Jim L. McEnerney was not only an outstanding Financial Advisor, he was an exceptional leader. Jim McEnerney loved the business but especially loved to coach FA's and see them succeed. 

Jim L. McEnerney was an innovator and a great teammate. Jim McEnerney helped to introduce the Supernova Model to Districts all over the country. Jim McEnerney gave personal testimonials as to the benefits that this best practice model brought to his team. 

Jim L. McEnerney was able to not only simplify his practice by reducing his client list to under 200, but he was able to double his business in 12 months. Jim McEnerney was a great Supernova Pioneer. Jim L. McEnerney is honest and insightful. 

Jim McEnerney is a deeply devoted family man, whose character and loyalty are unwavering at home and in business. Jim McEnerney has a permanent seat on a personal board of trustees. Jim McEnerney is just a good, All-Around person that has High Integrity and Core Values!
Send Notification to Inactive User with Task Scheduling in Laravel using Custom Command
Tags: laravel, notifications
Published: 2019-12-13 20:08:30

In this tutorial, i would like to show you how to setup task scheduling cron job in laravel 5.8 application. we will create laravel custom cron schedule and you can run cron every seconds, every minutes, every hours or every days. you can also write database logic or send email notification using laravel cron job. i will give step by step example of laravel 5 task scheduler tutorial.

In this tutorial we will see how we can create our laravel custom command and using this command and using task scheduling with cron job, how we can send notification to our inactive user from our application.

https://codechief.org/article/send-notification-to-inactive-user-with-task-scheduling-in-laravel-using-custom-command
Firebase 101: Authentication
Tags: google, firebase, softwareengineering, programming
Published: 2020-01-15 00:00:42

---
title: Firebase 101: Authentication
published: true
date: 2019-12-13 19:52:52 UTC
tags: google,firebase,software-engineering,programming
canonical_url: https://medium.com/swlh/firebase-101-authentication-6aaa874aa7c4
---

[![](https://cdn-images-1.medium.com/max/1280/1*zBQVmiIFy8EoIIU5bZczGA.jpeg)](https://medium.com/swlh/firebase-101-authentication-6aaa874aa7c4?source=rss-5676ca6163ee------2)

One of the things that I am most grateful for about being a software engineer in 2019, is the incredible breadth of SDKs, platforms, and…

[Continue reading on The Startup »](https://medium.com/swlh/firebase-101-authentication-6aaa874aa7c4?source=rss-5676ca6163ee------2)
atmosphere-kafka problem very hard
Published: 2019-12-13 19:42:15

Hi to all.
I have a problem with atmopshere-kafka and i'm desperate.

I'm trying to use atmosphere-kafka lib for balancing 2 tomcat.
I added this dependency to the my pom.xml.
<dependency>
  <groupId>org.atmosphere</groupId>
  <artifactId>atmosphere-kafka</artifactId>
  <version>2.5.2</version>
</dependency>


in place of
<dependency>
  <groupId>org.atmosphere</groupId>
  <artifactId>atmosphere-runtime</artifactId>
  <version>2.5.4</version>
</dependency> 

With the second dependency i don't have problem.

I commit my file with change here.
https://github.com/costaluisa/costaluisa

The problem, as you can see from the attached image, is that the AtmosphereResources is lost due to a null pointer in the AtmosphereResourceImpl.notifyListeners method that causes the removal of the resource, and being sent in the DefaultBroadcaster.deliverPush method, line 658, the resource is empty [].

Without lib kafka this not a problem.
From the attached files do you see any configuration missing or incorrect?

I use kafka e zookeeper service in windows (they run correctly) 

Can you help me?
thank
Marco
Learning To Write Your Own Test Cases Part 1 - Why You Should Care and Where to Start
Tags: testing, javascript, mocha, jest
Published: 2019-12-13 19:22:43

Recently, in the last 2 months or so since I graduated from Flatiron School, I've been looking for ways to push myself to continue to grow. At first, I wanted to try my hands at building larger side projects but found that to be very draining in addition to a job search and family life. So I've been pushing myself in new, smaller yet extremely meaningful ways. One of those ways was to teach myself how to write my own test cases, specifically for JavaScript. 

<h2>Why Test Cases?</h2>

Writing test cases is one of those things developers at all levels seem to think is a good idea...but rarely ever make the time to do. In my experience as well, you can convince yourself very easily that your time and energy is better served tackling ***one*** more error or bug.

After going through a whole curriculum with the tests all written for you, switching over to a project with nothing to work with is a bit of a rude awakening. Sure, you can decypher errors fairly easily with some experience & familiarity, but having a quality functioning test suite is definitively more convenient 100% of the time (especially if you don't have to write it yourself!).

But, there is one more reason why learning this subject was something I felt was worth my time: I have a passion for teaching and educating people. Rather than walk people through some online coding lessons/challenges, wouldn't it be cool as hell to actually be able to teach them a few lessons that I wrote out myself entirely?   

<h2>All Well and Good! But Where to Start!?!?</h2>

Good question! And one with no real answer! I mean, you should have an idea of what kind of tests you want to write first right? Maybe get a solid readme in place?  Probably, but I jumped right into which testing frameworks were most practical for what I wanted to do. There are 2 testing programs that stood out instantly with a quick Google search: Mocha and Jest.

I had familiarity with Mocha as it was the primary testing framework at Flatiron, and it was a very comprehensive program. However, Mocha can be very intimidating with all the additional installs you have to do plus the additional code injected int your project. Jest, on the other hand, I had no experience with at all but stood out on how simple it was to get rolling. Zero experience **plus** easy set up? Jest was an easy choice for me to begin this part of my coding journey.


<h2>Next Time on JavaScript Testing Z!</h2>
Part II I'll dive into my experience with the Jest testing framework, complete with pro's, con's, & how to's!