teleren/devto huggingface dataset:
My testing epiphany
Tags: testing
Published: 2018-04-11 13:15:12

---
title: My testing epiphany
published: true
description: A silly developer's realisation that testing is actually important
tags: testing
---

I've been making apps for about 2 years, and in that time I never understood the community's obsession with unit testing. I figured that if I can run the app and see it working, what's the point in taking loads of time to write automated tests?

The answer revealed itself to me recently.

> You don't write tests to make sure your code works now: you write tests so that you can spot your code breaking in the future.

![Mind blown](https://media.giphy.com/media/3o8dFn5CXJlCV9ZEsg/giphy.gif)

Here's an example. We've written a file in [RotaCloud](https://rotacloud.com/) for Android which contains a bunch of functions for working with time. Here's our method for formatting a timestamp - in seconds - as a 24-hour time:

```kotlin
fun Long.secondsToTime() {
    return SimpleDateFormat("HH:mm", Locale.UK)
        .format(this * 1000)
}
```

This function is pretty important to our app: if it breaks, suddenly everyone's rotas will be displaying incorrect information.

So what happens when a dev unwittingly changes this function like this?

```kotlin
fun Long.secondsToTime() {
    return SimpleDateFormat("HH:mm", Locale.UK)
        .format(this * 100)
}
```

This change will not cause a crash in the app, but it will mean that the whole system is pretty useless, and our users will *not* be happy.

So we wrote a test:

```kotlin
@Test
fun secondsToTimeTest() {
    val timeInSeconds = 1523451825
    val expectedTime = "13:03"
    assertEquals(expectedTime, timeInSeconds.secondsToTime())
}
```

This is a really simple test, but running it before a new release ensures that this vital functionality keeps working.

We can extend these tests to cover some other requirements too e.g. the hour should always be two digits: `09:30` is correct, but `9:30` isn't.


So that was my testing epiphany. It's pretty easy to manually determine whether or not something works, just by looking at it. What automated tests do, however, is ensure that *all* the app's functionality continues to work in the future, without you having to manually look through the whole thing.

Testing is also incredibly useful for collaborative development: simply require everyone to run the test suite before submitting a pull request, and you'll find yourself having to deal with a lot fewer broken implementations.
CopyMaker
Tags: java
Published: 2018-04-11 12:55:57

---
title: CopyMaker
published: true
description: 
tags: java
---

Hi people,
I wanted to show you a little utility I made and decided to publish on GitHub.

I work mainly with a legacy ERP with it's own database, and many times I need to create new records in tables. But in much cases, having to choose between map a 40+ fields table into one of my objects, with their own CRUD behaviour, or make raw SQL statements.
In the second case, one of my favourite strategies is to choose a model element of the table and build a SQL query like this one:


``` SQL
insert into TABLE
select Field1, Field2, Field3 from TABLE where Field1 = :Value

```

Having this SQL modified, replacing field names in the select with values:

``` SQL
insert into TABLE
select :NewId, 'New Value', Field3 from TABLE where Field1 = :Value

```

So here come this class, [CopyMaker](https://github.com/dcoturel/copymaker), wich allows you to:
1) Add String or Integer values informing wich field they override
2) Generate SQL for a specified table and a specified condition

I'm open to advice, improvements and anything on this.

Saludos,
What kind of Questions would you like to ask Recruiters?
Tags: career, beginners, discuss
Published: 2018-04-11 10:35:31

---
title:  What kind of Questions would you like to ask Recruiters?
published: true
description: 
tags: career, beginner, discuss
---

In my home country, Ghana, once you graduate from a tertiary institution, you need to serve the country for almost a year. As a computer science student who aims to be a strong software engineer one day, I am specific with choosing a company that I believe will help horn my skills within this time-frame. I was recently interviewed for a software developer role and during the interview, I was asked if I have a question for them? 

Since, I care my growth as well, I was like what measures do you have in place to ensure the growth of your developers in terms of skills, knowledge, staying up to with cutting edge technologies?

From their response, I felt like I am obsessed with growth than what I can give to the company. 

What if you are in my shoe, what kind of questions could you have asked?
Explain Dependency Injection Container like I'm five
Tags: explainlikeimfive
Published: 2018-04-11 07:53:58

---
title: Explain Dependency Injection Container like I'm five
published: true
tags: explainlikeimfive
---

I'm having a hard time wrapping my head around a DI package for PHP (PHP-DI). And why exactly would I want to use it?

Also, how it is different from simply instantiating a class wherever you want?

You can explain the title in regards or regardless to any particular language.
Deploy Java Application To Cloud Foundry In Less Than An Hour
Tags: cloudfoundry, java, spring, gradle
Published: 2018-04-11 02:52:24

---
title: Deploy Java Application To Cloud Foundry In Less Than An Hour
published: true
description: 
tags: cloudfoundry, java, spring, gradle
cover_image: https://thepracticaldev.s3.amazonaws.com/i/v7l2sxm7vnqgd5p9499i.png
 ---

#Introduction: 

This article talks about setting up PCF on your Local Workstation with PCF Dev and deploy a Java application.

Time :  45 mins 

##Prerequisites 

•	Virtual Box 5.0 or higher
•	Java JDK 7 or higher 
•	4GB Memory
•	10GB Space
•	Create account on PCF 

**Install The CLI**

Download and Install Cloud Foundry Command Line Interface (cf cli):

*MAC OSX* 
 https://packages.cloudfoundry.org/stable?release=macosx64-binary&source=github 

*Windows*
https://packages.cloudfoundry.org/stable?release=windows64-exe&source=github 

*Linux*
https://packages.cloudfoundry.org/stable?release=linux64-binary&source=github 



**Install The PCF Dev** 

Download the latest version of PCF Dev, navigate to https://network.pivotal.io/products/pcfdev 

Here I have used v0.28.0 for PCF 1.11.0 

![Alt text of image]
(https://thepracticaldev.s3.amazonaws.com/i/6i48cbpfmxsvbp705g1j.png)

**Unzip the downloaded zip file**

![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/1fqn0b9shvul8fiawplp.png)


**Install the PCF Dev Plugin**

![Alt text of image]
(https://thepracticaldev.s3.amazonaws.com/i/8xtnnc78tqb4wrwsrgrh.png)


**Start PCF Dev** 

![Alt text of image]
(https://thepracticaldev.s3.amazonaws.com/i/hnbj1l7eu9d6brdldcf6.png)


This Process takes somewhere from 10-20 mins depending on the workstation.


**Deploy Java Application** 

Now that you have PCF Dev Virtual Machine running on your workstation, next step is to deploy the sample Java application. 

**GIT Clone** 

$ git clone https://github.com/cloudfoundry-samples/spring-music

$ cd spring-music

![Alt text of image]
(https://thepracticaldev.s3.amazonaws.com/i/q66uyzzqn514vb73bqkr.png)


**Login to PCF Dev** 

![Alt text of image]
(https://thepracticaldev.s3.amazonaws.com/i/zi3qfky6m740h1h2nngx.png)

**Use Gradle to Assemble the app locally**

$ ./gradle assemble 

![Alt text of image]
(https://thepracticaldev.s3.amazonaws.com/i/z7lebir6gwoxhpbe0f5e.png)


**Push the App** 

$ cf push --hostname spring-music


![Alt text of image]
(https://thepracticaldev.s3.amazonaws.com/i/aouivl5fxwhgmnr7t2zk.png)


While App gets deployed you would see the route which would be used to access the app from your local browser. 

![Alt text of image]
(https://thepracticaldev.s3.amazonaws.com/i/nno5dmzfk8be1aqsnkwd.png)


requested state: started
instances: 1/1
usage: 512M x 1 instances
routes: spring-music.local.pcfdev.io

![Alt text of image]
(https://thepracticaldev.s3.amazonaws.com/i/bgbg76yaw8yq48lgbycx.png)


**To View Logs**

$ cf logs spring-music –recent


**To Check Running App Details**

![Alt text of image]
(https://thepracticaldev.s3.amazonaws.com/i/5j95pzhs1uqbbgl22ufj.png)
How to use Google Colaboratory with Local Runtime
Tags: deeplearning, colaboratory
Published: 2018-04-11 01:37:36

---
title: How to use Google Colaboratory with Local Runtime
published: true
description: gle Colaboratory has a feature to connect local runtime. This post introduces docker image look-alike Google colaboratory 
tags: deeplearning, colaboratory
---

# TL;DR

* I created [docker image](https://hub.docker.com/r/ikeyasu/colab-local/) look-alike Google Colaboratory
    * It is using the same OS version(Ubuntu17.10) as Google colaboratory.
    * It is installed the same python library as Google colaboratory. 
* You can use this docker image with “Local Runtime” feature of Google Colaboratory

### Step to connect

1. Setup [nvidia-docker2](https://github.com/nvidia/nvidia-docker/wiki/Installation-(version-2.0))
2. `$ docker run --runtime=nvidia -it --rm -p 8081:8081 --cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor=unconfined ikeyasu/colab-local:latest`
    * `--cap-add SYS_ADMIN`, `--device /dev/fuse`, `--security-opt` and `apparmor=unconfined` are necessary for mounting Google drive.
    * You need to change port number, please change `-p 8081:8081`. For example, `-p 8082:8081` if you want to use 8082.
3. Click ▼ on top right of Colaboratory(next to "CONENCT" button), and click
4. Input backend port to your docker instance like 8081. Then, click Connect button.

### If a host running jupyter notebook is not localhost

Colaboratory requires localhost to connect local instance. If you would like to run jupyter notebook on another host, you need to use port-forwarding as follows.


`$ ssh user@example.com -L 8081:localhost:8081`


If you are using windows, you can use PuTTY.


# What is benefit?

Google Colaboratory has many limitation, especially it could be ran by 12 hours only. In other hand, Google Colaboratory is good for first step of deep learning.

Thus, you can take a following step to move forward your project.

1. Use Google Colaboratory for rough investigation and testing. It has limitation of 12 hours.
2. If your model is looks good, launch Local Runtime. It does not have limitations. You can run a learning process for more 12 hours.

Docker image introduced this paper is looka-like Google Colaboratory. You don't need to concern a difference of environment between host runtime and local runtime.
TIL: rebeccapurple
Tags: css, color, human, honor
Published: 2018-04-23 06:53:45

---
title: TIL: rebeccapurple
published: true
tags: css, color, human, honor
canonical_url: https://markentier.tech/posts/2018/04/rebeccapurple/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/s7wm8usumzd3fphwm413.png
---

While polishing my theme, I discovered Rebecca. I love it, when technology gets some human touch.

I was just reading about the color data type in CSS [over at MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) when I saw that a new named color will be part of the [CSS Color Module Level 4](https://drafts.csswg.org/css-color/).

There was a link to [this Codepen blog post](https://codepen.io/trezy/post/honoring-a-great-man).

Rebecca was Eric Meyer's daughter. She was diagnosed with cancer. [On her sixth birthday she left us.](https://meyerweb.com/eric/thoughts/2014/06/09/in-memoriam-2/)

> This past Friday, June 19th, 2014, the community to which Eric has given so very much [has seen fit to name #663399 as rebeccapurple](https://lists.w3.org/Archives/Public/www-style/2014Jun/0312.html) with his permission.

Eric Meyer is probably most well-known for [reset.css](https://meyerweb.com/eric/tools/css/reset/).

* * *

More TIL: Btw the changes for CSS 3 to 4 are also interesting from a technical perspective: [https://drafts.csswg.org/css-color/#changes](https://drafts.csswg.org/css-color/#changes).
How do you like to unit test your code?
Tags: discuss
Published: 2018-04-10 22:38:21

---
title: How do you like to unit test your code?
published: true
tags: discuss
---

I've always been stuck on how I like to unit test my code. Sometimes I like to isolate with mocks and test pure units. Sometimes I like to do full integration testing. Meaning that I will not mock any dependencies. Except for external library dependencies. At the end of the day, the integrated testing seems to be more valuable.

How do you like to unit test? What seems to be more valuable for you?
Live: Mark Zuckerberg testifies before senate
Tags: privacy, hot, gdpr, discuss
Published: 2018-04-10 20:12:18

---
title: Live: Mark Zuckerberg testifies before senate
published: true
description: Mark Zuckerberg testifies before senate
tags: #privacy #hot #gdpr #discuss
---
With all the fuss over twitter with the #deletefacebook movement. The GDPR on its way and privacy in general. It is important to stay up to date with the latest news on data privacy.

Facebook CEO Mark Zuckerberg testifies on Facebook users' data before the Senate Commerce and Judiciary committees.

Watch the video from day 1 here:
{% youtube qAZiDRonYZI %}

Watch the video from day 2 here:
{% youtube QmA3TsQ_ULo %}

-Edited to add video from day 2
Welcome Thread - v11
Tags: welcome
Published: 2018-04-10 19:45:57

---
title: Welcome Thread - v11
published: true
description: Introduce yourself to the community!
tags: welcome
---

Hey there! Welcome to dev.to!

![A robot spinning a globe on its finger looks at you and winks.](https://media.giphy.com/media/5yLgocrb5JLqhq7pp3W/giphy.gif)

# Welcome!
1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋

```
tar -xvzf robot_welcomes_you_to_community.gif
```
Developing Web Apps with ASP.NET Core 2.0 and React - Part 3
Tags: react, javascript, aspnet, aspnetcore
Published: 2018-04-10 16:34:26

---
title: Developing Web Apps with ASP.NET Core 2.0 and React - Part 3
published: true
description: A practical tutorial showing how to setup and develop a modern Web application based on ASP.NET Core 2.0 and React.
tags: #reactjs #javascript #aspnet #aspnetcore
canonical_url: https://auth0.com/blog/developing-web-apps-with-asp-dot-net-core-2-dot-0-and-react-part-3/
---

This is the third part of the series about developing a Web application based on ASP.NET Core 2.0 and React. [In the first post](https://auth0.com/blog/developing-web-apps-with-asp-dot-net-core-2-dot-0-and-react-part-1?utm_source=dev&utm_medium=sc&utm_campaign=aspnet2_reactjs), you built a secured Web API application that provides a list of books with ASP.NET Core 2.0. [In the second post](https://auth0.com/blog/developing-web-apps-with-asp-dot-net-core-2-dot-0-and-react-part-2?utm_source=dev&utm_medium=sc&utm_campaign=aspnet2_reactjs), you created a Single Page Application (SPA) client based on React to consume this API. 

In this post, you will integrate the client-server system with scopes and authorization management by using Auth0.

[Read on 🛠](https://auth0.com/blog/developing-web-apps-with-asp-dot-net-core-2-dot-0-and-react-part-3/?utm_source=dev&utm_medium=sc&utm_campaign=aspnet2_reactjs)

![Developing Web Apps with ASP.NET Core 2.0 and React - Part 3
](https://thepracticaldev.s3.amazonaws.com/i/0ctgzmhp9pmyougl6i2t.png)
Qemu KVM Centos 7.0 install - build tmux 2.6 
Tags: linux, centos, install
Published: 2018-04-10 16:27:36

---
title: Qemu KVM Centos 7.0 install - build tmux 2.6 
published: true
description: Qemu KVM Centos 7.0 install - build tmux 2.6
tags: Linux, Centos, Install
---

```
   58  wget https://github.com/tmux/tmux/releases/download/2.6/tmux-2.6.tar.gz
   59  tar xzf tmux-2.6.tar.gz
   60  cd tmux-2.6
   61  ./configure && make
# Install it first 
   62  sudo yum install libevent-devel
   64  sudo yum install ncurses-devel
   65  sudo yum install glibc-static
# END  
   67  ./configure && make
   68  sudo yum install gcc
   69  ./configure && make
  
   74  sudo make install
 
   78  ps -u | grep tmux
   79  tmux -V
```
```
➜  tmux-2.6 sudo make install
make[1]: Entering directory `/home/psnebc/tmux-2.6'
 /usr/bin/mkdir -p '/usr/local/bin'
  /usr/bin/install -c tmux '/usr/local/bin'
make  install-exec-hook
make[2]: Entering directory `/home/psnebc/tmux-2.6'
if test xmdoc = xmdoc; then \
        sed -e "s|@SYSCONFDIR@|/etc|g" ./tmux.1 \
                >./tmux.1.mdoc; \
else \
        sed -e "s|@SYSCONFDIR@|/etc|g" ./tmux.1| \
                gawk -f./mdoc2man.awk >./tmux.1.man; \
fi
/usr/bin/mkdir -p /usr/local/share/man/man1
/usr/bin/install -c -m 644 ./tmux.1.mdoc \
        /usr/local/share/man/man1/tmux.1
make[2]: Leaving directory `/home/psnebc/tmux-2.6'
make[1]: Für das Ziel »install-data-am« ist nichts zu tun.
make[1]: Leaving directory `/home/psnebc/tmux-2.6'
➜  tmux-2.6 tmux --version
usage: tmux [-2CluvV] [-c shell-command] [-f file] [-L socket-name]
            [-S socket-path] [command [flags]]
➜  tmux-2.6 tmux -v
[exited]
➜  tmux-2.6 ps -u | grep tmux
psnebc    5786  0.0  0.0 112672   984 pts/0    S+   18:21   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn tmux
➜  tmux-2.6 tmux -V
tmux 2.6
```
Secure Outsourcing
Tags: gdpr
Published: 2018-04-23 11:01:48

---
title: Secure Outsourcing
published: true
tags: GDPR
canonical_url: https://perfectial.com/blog/secure-outsourcing-protect-data-achieve-gdpr-compliance/
---

While there are obvious benefits to outsourcing software development, there are also risks.

Software vendor you’re partnering with is effectively an extension of your team. You might grant it access to your company’s sensitive data and clients’ records, allow it to acquire a deep understanding of your infrastructure and internal business procedures and even learn the flaws and limitations your IT-systems.

[We’ve all heard stories](http://searchsecurity.techtarget.com/news/2240228287/Goodwill-breach-highlights-need-for-service-provider-due-diligence) of firms getting into engagements with shady offshore companies only to discover, much too late, that the latter’s security standards were inadequate and the code they wrote was poor (either flawed or purposefully written with logic bombs and backdoors).

Each business that hires offshore software engineers potentially puts itself in a vulnerable spot. And yet the likes of Oracle and Microsoft, the titans of the IT world, have been using outsourced development for years successfully.

![Secure Outsourcing: Before the work begins](https://perfectial.com/wp-content/uploads/2018/04/img1-4.jpg "Secure Outsourcing: Before the work begins")

_So, what’s the secret?_

Whether you’re seeking to take advantage of regional economies in developing countries (cut costs by utilizing cheap labor) or find hungry, well-trained experts with specific skills that you are currently in need of, you must address responsibly the risks associated with contracting out software development. In light of looming [GDPR regulations](https://perfectial.com/blog/gdpr-compliance-brief-guide/), this means not only picking carefully who to work with (based on reviews, etc.) but also going through the vendor’s security management processes and ensuring everything they do is congruent with your company’s policies.

In this post, we’ll give you a few tips on how to stay on the safe side while using outsourced development.



_If you’d like to learn more about the risks of outsourcing development and how we establish security when working with our clients, contact our expert right now._

The post [Secure Outsourcing: How to Protect Your Data and Achieve GDPR Compliance](https://perfectial.com/blog/secure-outsourcing-how-to-protect-your-data-and-achieve-gdpr-compliance/) appeared first on [Software Development Company Perfectial](https://perfectial.com).
Prototyping in playground
Tags: swift, ios, ui, animation
Published: 2017-07-31 02:33:58

---
title: Prototyping in playground
published: true
description: Prototyping iOS apps with XCode Playground and free OpenSource tools
tags: swift,iOS,UI,Animation
---

Prototyping UI/UX with XCode Playground and Animator a new animation .framework I'm building. The best part? You get native code you can use when building your apps. And it's [OpenSource](https://github.com/gitsync/AnimLib) .  Check out the examples bellow:

### 7. Let's add some design to it:

<img width="226" alt="img" src="https://raw.githubusercontent.com/stylekit/img/master/video_iphone.gif?maxAge=2512168">

### 6. Peek & Pop is now complete (added dismiss):

<img width="195" alt="img" src="https://raw.githubusercontent.com/stylekit/img/master/modal_complete.gif?maxAge=2512168">

### 5. Modal now remains idle if in prompt state:

<img width="195" alt="img" src="https://raw.githubusercontent.com/stylekit/img/master/modal_idle.gif?maxAge=2512168">

### 4. Modal now reveals prompt buttons:

<img width="195" alt="img" src="https://raw.githubusercontent.com/stylekit/img/master/modal_w_prompt.gif?maxAge=2592022">

### 3. Modal now has boundaries w/ log10 (aka slippery friction):

<img width="195" alt="img" src="https://raw.githubusercontent.com/stylekit/img/master/modal_log10.gif?maxAge=2592003">

### 2. Modal is now draggable w/ easing:

<img width="195" alt="img" src="https://raw.githubusercontent.com/stylekit/img/master/modal_drag.gif?maxAge=2592001">

### 1. Deep click button to activate peek:

<img width="195" alt="img" src="https://raw.githubusercontent.com/stylekit/img/master/modal_pop.gif?maxAge=2592000">

### Prerequisites: (Figure out how ForceTouch works)

<img width="195" alt="img" src="https://raw.githubusercontent.com/stylekit/img/master/ForceTouchEvent_anim.gif">

### Resources:

[Using Framework files in playground](http://eon.codes/blog/2017/01/16/playground-and-framework/)

This article was originally published on my blog [http://eon.codes](http://eon.codes)
First Developer Conference, Suggestions?
Tags: discuss, rails
Published: 2018-04-10 13:45:41

---
title: First Developer Conference, Suggestions?
published: true
tags: discuss, rails
---
I'm attending my first develop conference next week, RailsConf in Pittsburgh. I'm pretty excited because the ruby community is always talked about as being so awesome.  Anyone have any tips on making the most of my first conference?  Anyone else going?
Detecting deadcode in your project
Tags: javascript, react, webpack, discuss
Published: 2018-04-10 13:21:44

---
title: Detecting deadcode in your project
published: true
description: 
tags: javascript, react, webpack, discuss
---

Our frontend stack is using react (webpack) and after one year, our codebase becomes quite huge. My company is a startup, you know as startup we might change our flow quite often, it leads to a lot of code are not used anymore and we want to clean them as much as possible. After spending few weeks to research, I found several approaches to attack that problem, therefore, I wrote this blog
https://medium.com/@MQuy90/wtf-is-deadcode-elimination-how-to-do-it-by-yourself-d1e1e26b0ed0

What do you think about those approaches?
What do you use to detect deadcode in your project?