teleren/devto huggingface dataset:
unit testing python
Tags: python, beginners
Published: 2020-02-06 13:44:36

Unit testing is a software testing method to test functions in source code. Python has a module for unit testing, <a href="https://docs.python.org/3/library/unittest.html#module-unittest">unittest</a>. 

This is different from <a href="https://pythonspot.com/python-debugging/">debugging</a>, where you already know the program is not doing what you want. 

By testing the function (unit testing) you can prevent the program from doing unexpected things. The idea is that you test both good and bad input.

The unittest module uses the idea of <a href="https://pythonbasics.org/class/">classes and objects</a>.

## Example

The program below tests the function .upper(). It compares the output to the expected output 

```python
self.assertEqual('foo.upper()', 'FOO')
```

In code that looks like this:

```python
import unittest

class TestStringMethods(unittest.TestCase):
    def test_upper(self):
        self.assertEqual('foo'.upper(), 'FOO')

if __name__ == '__main__':
    unittest.main()
```

If you run the program, it executed the test automatically:

```python
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
```

You can test your own functions using the unittest module.

```python
import unittest

class TestStringMethods(unittest.TestCase):

    def hello(self):
        return "hello"

    def test_upper(self):
        self.assertEqual('foo'.upper(), 'FOO')

    def test_hello(self):
        self.assertEqual(self.hello(), "hello")

if __name__ == '__main__':
    unittest.main()

```

This outputs:

```python
..
----------------------------------------------------------------------
Ran 2 tests in 0.000s

OK
```

And so the tests in are all run automatically. This means that while you code, you can run the unit tests and verify that your code still works.

**Related links:**
* <a href="https://docs.python.org/3.8/library/unittest.html">Unit test module</a>
* <a href="https://pythonbasics.org/">Learn Python</a>
Static Type Checking in Ruby Video Series
Tags: ruby, testing
Published: 2020-02-06 13:36:48

---
title: Static Type Checking in Ruby Video Series
published: true
description: Static type checking has come to Ruby! Explore getting started with this 3-part video series.
tags: ruby, testing
cover_image: https://i.imgur.com/jd2Hm8l.png 
---

Ruby is a traditionally dynamically typed language. It is one of the reasons many Ruby developers love working with the language. Yet, static type checking is coming to Ruby, and with it comes many opportunities to make our code more explicit, more thoroughly understood by future developers and more resilient. 

[Sorbet](https://sorbet.org/) is an open-source gem that introduces static type checking to your existing codebase incrementally. It lets you reduce the pain in the process by gradually increasing the severity of the check you run. Using the sigil `# typed: ` you can designate a precise level of check, or none at all, on each file in your codebase.

In this three-part series, we walk through the first steps in introducing Sorbet to your code. Part 1 will take you through installation and initialization of the gem. Part 2 will take you through running the first code quality checks. Part 3 will introduce the first method signatures and run the first checks on types.   

## Part 1: Initializing Sorbet

{% youtube 2rvoDBzwOxI %}

## Part 2: Running the First Checks

{% youtube q3w6_ootlfs %}

## Part 3: Introducing Method Signatures

{% youtube T3bkmuv15yM %}

The state of static type checking in Ruby is a constantly evolving one. A solution now might not be applicable down the road as new approaches are developed. This is an exciting space to keep on watching and developing in. 

Are you working with static type checking in Ruby or in another traditionally dynamically typed language? How has it gone for you? What have you experienced? 

*Ruby Minutes is a new video series from [Nexmo](https://developer.nexmo.com) that looks at new and interesting things in the Ruby ecosystem. Have a topic you'd like us to feature? Let us know! We'd love to hear from you.*
Git - the big picture
Tags: git, overview, picture
Published: 2020-02-06 13:20:03

---
title: Git - the big picture
published: true
description: a git overview in a big picture
tags: #git, #overview, #picture
---


Nothing else to say, it's just a git overview in a big picture :

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2pqs3yfu5vh51uduuc1y.png)
My most awkward experience at work - featuring TypeScript
Tags: watercooler, typescript
Published: 2020-02-06 13:16:21

Have you ever had a really awkward moment at work? Here's mine.

I've been an Angular developer for about one year. I knew nothing about Angular, TypeScript and, in general, frontend development.

So I started learning TypeScript.

The language website is well done, and one interesting feature is the __Playground__ page.  [There](http://www.typescriptlang.org/play/) you can try TS features and see the result of the transformation of your code into plain JavaScript.

Cool resource, isn't it?

At work, I had a problem with TypeScript's syntax, and I remembered that that page was helpful. I knew that TypeScript is often shortened as "ts", so I googled __TS playground__.

__DON'T SEARCH FOR IT AT WORK!!__

I discovered that day that TS Playground is an adult video channel and that TS means also Transex & Shemale.

Terrible thing to discover at work!

Luckily I didn't try to guess the URL and navigate directly to the site!


What's your worst moment at work?
Daily Developer Jokes - Thursday, Feb 6, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-02-06 13:00:13

---
title: "Daily Developer Jokes - Thursday, Feb 6, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Thursday%2C%20Feb%206%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258922d1b9.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
I’ve been hearing news about this big boolean.

Huge if true.
 -->
A commenting system that is easy to self-host (and completely free)
Tags: security, showdev, webdev, vue
Published: 2020-02-06 12:56:45

I recently created a self-hosted commenting system, that is easy to deploy to Heroku and uses generous MongoDB Atlas storage -- <https://aloud-comments.herokuapp.com/>

It can be linked to allowed URLs including static websites.

{% github patarapolw/aloud no-readme %}

Before that, I have found [Hugo comments guide](https://gohugo.io/content-management/comments/) that says it recommends Disqus, but there are alternatives. I find that alternatives use filesystem storage, which not available on Heroku (which is ephemeral). I can use AWS or DigitalOcean... but if I over-credit, I will have to pay...

My favorite is Isso, Remark42 (which both needs permanent filesystem); and utteranc.es (which users strictly have to be GitHub user, which is not my general population.)

Now, I have security concerns regarding storing JWT token from `auth0-spa-js` on server side -- https://community.auth0.com/t/commenting-engine-based-on-nuxt-express-auth0-to-be-used-on-static-sites/37507 (I heard that storing in localStorage is bad...)

I also, I disallow anonymous users to comment. I don't know how to, if I have to...

I might rewrite it using non-Nuxt, and pure server / pure SPA, separated, but I am getting lazy...
Tankblade - First Game Jam!
Tags: gamedev, javascript, currying, pixijs
Published: 2020-02-06 12:48:25

"Ghouls! Frickin ghouls everywhere, just my luck!
Well, I best hop in this here spinning-top, blade-encrusted tank and start slashy smashin'."

[PLAY THE GAME!](https://entozoon.itch.io/tankblade)
[Source](https://github.com/entozoon/tankblade)

### ​Development
This game was built entirely by myself from scratch for [LOWREZJAM 2019](https://itch.io/jam/lowrezjam-2019)​ in a week, including all music, physics, graphics* etc and is completely open source​!

This is my very first Game Jam submission and was a brilliant challenge - to build a game with a true resolution of 64x64 - forcing my coding to improve and encouraging a fast-and-loose development style fitting with a jam so as to, you know, actually complete a side-project for once!

* The renderer itself is Pixi.js​ (a library underneath Phaser), which I can't claim to have built ^_-

## What I learnt
Game dev isn't my profession, but holy heck is a great way to improve skills! Utilising functional programming junk like currying that might not normally enter typical daily thought patterns. I highly recommend it, and especially in the context of a jam - working to that 'good enough' mentality all the while.
Sketchy Mk. I
Tags: electronics, node, scara
Published: 2020-02-06 12:37:07

{% youtube lWzbtICmNko%}

## What is it?
Real-time drawing robot. Using a SCARA arm and a web interface, it draws simultaneously to the user.

This was a quick prototype, built over the course of a few evenings to see what was possible with these relatively simple (or cheap, at least) pieces of equipment.

### Ingredients
Raspberry Pi Zero
PCA9685 Servo Motor Driver
MG996R Servos

### Method
I quickly designed the two arms using the brilliant Tinkercad website, screwing the 'shoulder' servo straight down onto an acrylic board and attaching the arms after 3D-printing.

The MG996R servos for the upper/lower arm sections are connected up to the PCA9685 which has its own separate power supply from the Pi. As this project was just a prototyping exercise, the pen is simply bolted in place with a little pipe ring clip style attachment.

A node server is run on the Pi which allows user interaction through a canvas web interface and Socket.IO connections. The SCARA angles for the arm joints in relation to the mouse (or finger on mobiles) position are calculated client-side (to spread the processing load), then sent to the server which sets the servo positions without hesitation via the PCA9685 node module.

In this instance there is no dampening, physical or mechanical (springs) so it's.. it's pretty intense in the way it moves but it does its job!

![Good nuff](https://dev-to-uploads.s3.amazonaws.com/i/ry1jda8hwoostgdkt2pn.jpg)

### Conclusions
I learnt a lot in building this and hope to re-build the project from scratch with a more professional-looking aesthetic. My original idea was actually for it to draw with a pencil that never lifts off the paper and just sketches over and over to darken the drawing where needed, hence the name 'Sketchy', but in actuality using servos isn't suitable for this. Servos move relatively quickly and with strength but aren't nearly precise enough to plot accurately in this fashion, so it could never sketch out a block with a pencil - the gaps between angles too large and inprecise (too 'sketchy', ironically).

However, the fact that it moves so pleasinly in real-time more than makes up for it so I'll build a more built-up version in future and possibly even a stepper-motor plotting incarnation one day.

## Pass or Fail?
Hard pass! As a quick prototype project it was both successful and taught me many a lesson.
Git process
Tags: discuss
Published: 2020-02-06 12:35:22

We have had a debate on our git process, how we branch and release into production. 

My preference is to continuously commit and release from master by tagging each release. Features can be branched from this and pushed for code review before merge. Generally I like to continuously deploy and have features which are not yet available behind configuration. 

The team I'm in prefers a different approach which I find messy. They would rather have a development branch along with the master branch. To build a feature  you branch from development, and merge back to development. On release in development will get merged into master. I think this is harder to maintain and allows issues to arise if master gets ahead of development due to a bug fix. 


What is your preferred git process?
Force web pages in DARK MODE in Firefox & Chrome 😎
Tags: webdev, productivity
Published: 2020-02-06 12:18:18

Midnight Lizard is the one which I came to know about recently while browsing for a dark mode extension. Midnight Lizard has a variety of colour schemes for the Developers(We love dark mode) as well as for casual web browsing purpose.

![](https://www.codingindian.codes/assets/uploads/md_lzrd.png)

Reading a web page which flashes light on our your face becomes irritating and eyes get tired, so you can turn on Midnight Lizard and enjoy you browsing, whatever it is :smile:

Link to download: [Click here](https://chrome.google.com/webstore/detail/midnight-lizard/pbnndmlekkboofhnbonilimejonapojg?hl=en)

### Pros

* 18 colour schemes available.
* About 11 are dark schemes.
* Shortcut to switch on and off extension.
* Small in size.

### Cons

* Increases page load time significantly.
* Sometimes freezes the browser
Interview small feedback
Tags: discuss, career, hiring
Published: 2020-02-06 12:10:27

Hey guys!

Just wondering something here...

When we are doing an interview, not with a random HR person, and at the final, the interviewer start to do a _small feedback_ about your resumé, the points that your experience fits on the company needs, the projects that are in Github, points during the interview, etc.

Summary, just telling that your get by this first step (or have _high/medium chances_) or some points are lacking and so on. Towards to the candidate to not have much expectations or just not wait for one job at time.

What are your thoughts? It is possible? Is too much invasive? In a real world scenario have a lot of candidates and is not fair or not have a substantial information to do at the moment of interview?

Thanks in advance!
Most frequently asked questions in PWA
Tags: pwa, issues, ios, angular
Published: 2020-02-06 12:04:47

I am writing this blog to share my findings on a question that I had during the developments of PWA. I went through many blogs and tutorials for this and I found few things are not working with IOS while Android has good support for PWA. 

Let's see them one by one. 

**Can PWA access camera?**

Yes, both the OS gives access to the camera, which allows image and video capturing in PWA. 
Android: YES
IOS: YES

**Can PWA work offline?**

PWA leverages data caching during your last interactions with the app, and by doing that it works offline while there is no internet connection. 
Android: YES
IOS: YES

**Can PWA access the file system?**

<input type="file"> is the only way you can access a regular storage file system, which will not have any event listener. PWA can't listen to regular file system changes except for the files of APP. 

**Can PWA access the Bluetooth?**

The web Bluetooth API is a low-level API allowing web applications to pair with the nearby Bluetooth Low Energy-enabled peripheral devices and access their services exposed. But it's not supported on all platforms. 
Android: YES
IOS: NO

**Can PWA access the phone’s GPS?**

A lot of browsers support this recent feature and these include Chrome, Edge, Firefox, Safari, and Opera. In IE, you’ll have to battle a few configurations to make it work 
Android: YES
IOS: YES


**Can PWA use advanced camera functionality?**

Advanced camera functionality is not available on all platforms. For example QR CODE scanning.  
Android: YES
IOS: NO

**Can PWA access contacts?**

No there is no way to access contacts in PWA, it is mainly restricted for security purposes. 
Android: NO
IOS: NO

**Can PWA check for new updates?**

Yes, in order to achieve this you have to check your cached files are changed or not. We can implement this by writing a hook in onupdatefound function on the registered Service Worker.

Here I found a detailed blog for this that explained each step in detail. 
https://medium.com/progressive-web-apps/pwa-create-a-new-update-available-notification-using-service-workers-18be9168d717

**Can PWA have Push Notifications?**

This is the most crucial part of any applications and many product owners avoid PWA just because of these limitations. Android support push notifications but IOS does not support. Maybe Apple can update in the next version 14. But we have to wait till that. 
Android: YES
IOS: NO
An easy and secure way to launch helper scripts in a project
Published: 2020-02-06 17:49:42

---
title: An easy and secure way to launch helper scripts in a project
published: true
date: 2020-02-06 11:59:00 UTC
tags: 
canonical_url: https://www.geewiz.dev/2020/02/06/an-easy-and.html
---

On one of my recent live coding streams, a viewer asked what my `abe` script does. I showed that it simply launched a Ruby command in my project's application container. Since I'm using Docker Compose to spin up most of my development environments, I have to run all development tasks within the application container. Typing `abe rake test` is much faster than typing `docker-compose exec app bundle exec rake test`, so I added this script to my project's `bin` directory:

```bash
#!/bin/bash
docker-compose exec app bundle exec $@
```

It's a nifty time-saver, but the smart part of this isn't the script itself but how I make helper scripts in the `bin` directory of my projects easy to launch without having to prepend every command with `./bin/`.

If you're familiar with how a Unix shell finds the right program to execute, you 'll probably suggest just adding `./bin` to the environment variable `PATH`. But that's a risky move because you don't want to accidentally launch a malicious script after checking out a repository that happens to have an executable `ls` command in its `bin` directory.

Once again, it was the talented devs over at [ThoughtBot](https://thoughtbot.com/blog/git-safe) who found a better solution. Instead of adding `./bin` to `PATH`, they recommend adding `.git/safe/../../bin`. With this entry, the shell descends into `.git`, further down into `safe`, all the way back to the repository root and only then into `bin`. What makes this seemingly roundabout way to find your helper scripts secure is that it only works if you've first manually created the subdirectory `safe` within `.git`. The latter is, after all, git's data directory which normally doesn't contain a directory named `safe`.

There you have it — easy access to your project's helper scripts is simple to achieve. And without any additional effort, it's safe as well!
Learn to Target the Upwork RSS Feed and Get Automatic Job Notifications
Tags: general, latestposts, productreviews, freelancer
Published: 2020-02-06 13:50:09

---
title: Learn to Target the Upwork RSS Feed and Get Automatic Job Notifications
published: true
date: 2020-02-06 11:55:04 UTC
tags: General,Latest Posts,Product Reviews,freelancer
canonical_url: http://robdoylecreative.com/learn-to-target-the-upwork-rss-feed-and-get-automatic-job-notifications/
---

Are you a freelancer on Upwork and get frustrated when you see a job that you feel qualified to do but then realize that 30 other people have already submitted proposals that kick you out of the running?. The main reason why this happens is that you have spotted the job too late. The key […]

The post [Learn to Target the Upwork RSS Feed and Get Automatic Job Notifications](http://robdoylecreative.com/learn-to-target-the-upwork-rss-feed-and-get-automatic-job-notifications/) appeared first on [Rob Doyle Creative](http://robdoylecreative.com).
Blogs are harmful and we are learning wrongly!
Tags: productivity, computerscience, news, discuss
Published: 2020-02-06 11:37:02

One of the common problems everyone is facing nowadays is "there is too much information on the internet". Every time you wake up, there are hundreds of articles throwing to your face.

Do you ever feel you read a lot of blogs like spending 4 hours per day on HackerNews and your level is still nowhere? or even you feel knowledge-wise and invincible after reading a lot about a topic and then got shut down in a discussion when the material going to deep.

It's because you are spending too much time reading blogs.

Why blogs are harmful:
- **The content is not written for you, it's for the writer**! The purpose of blogs mostly ends up in product promotion, technical advancement show-off. Writers rarely think about how much users can learn from it, instead, they tend to throw their experience and achievement to the post. Those typical blog types: How we migrate from X to Y. Why X is better than Y. How did we reach millions of users. Our journey to Y ...
- **Blogs create misinformation bias**. If you are new to the topic, you easily feel super convinced as you don't have any context as well as exposure. For example, when you read something like "Why does some *favorite company* choose Rust over Golang", it easily causes a subconscious that Rust is better than Go in most aspects because the favorite company did it. Then the next time you work on related stuff, you will prioritize Rust and find the reasons to choose it over Go.
- **Blogs are unstructured**. Blogs usually come up with only one post, so writers have to assume every reader has the same basic level of knowledge. Therefore, most blogs are shallow and duplicated. They cannot put a one-page explanation just for a difficult concept that is not so relevant to the post. Multiple misunderstanding gaps from unexplained material can accumulate to a **fragile knowledge foundation**, which can hinder you from learning a subject more organized next time.
- **Blogs are written by unprofessional writers**. Most of the tech blogs are written by software engineers or people working in tech. Some are good of course, but most are bad because our profession is not writing. Outlining the writing or giving concise knowledge is an art and it's not easily obtained for new writers after. Moreover, when you switch between different writing styles, your reading speed is also slow down due to context switch.
- **It consumes your time**. When you spent 30 mins reading blogs, you decided to give up your time reading a book chapter. Even if you cherry-pick blogs to read, you already waste time skimming all blogs.

For those reasons, I think we should reduce our time reading blogs and invest more in structured material like books or courses. If you cannot find the time or have less time for books, it's a red flag.

I still find tech blogs are helpful for the career: they bring you to the outside world, offers diverse perspective, keep you up-to-date with this fast-changing world... But if you are considering Blogs as your source of knowledge, you are learning technology wrongly!