teleren/devto huggingface dataset:
Scala vs Ruby - Creating a while loop DSL
Tags: scala, ruby, dsl
Published: 2020-02-15 12:22:01

I'm learning Scala. It's a powerful language with lots of features. One such thing is called the [by-name parameters](https://docs.scala-lang.org/tour/by-name-parameters.html)

In most languages, a while loop will look like this:

```rb
while (condition) {
  # statements
  ...
}
```

Ruby implementation of this would look like this:

```rb
# Define the method first
def my_while(cond, &block)
  if cond.call
    yield
    my_while(cond, &block)
  end
end

i = 0
cond = -> { i < 10 }

# and then call it
my_while(cond) do
  puts "i: #{i}"
  i += 1
end
```

This is the best I could do. The `condition` has to be declared explicitly as an anonymous function ([proc/lambda/block whatever!](https://npras.in/tech/ruby-blocks-with-js)). It doesn't quite give you the native `while` look.


But in Scala we could have a function that looks exactly like the native `while`. Here's how:

```scala
// Define the method first
def my_while(cond: => Boolean)(body: => Unit): Unit =
  if (cond) {
    body
    my_while(cond)(body)
  }

var j = 0

// and then call it.
my_while(j < 10) {
  println(s"j: ${j}")
  j += 1
}
```

This is because the first argument to the function - `cond` - is declared as a by-name parameter. This means the compiler will treat it as an anonymous function. And then whenever the `cond` is referred in the function definition, this anonymous function will be executed and it's return value be put in its place.

The tradeoff here is, when someone looks at the calling code, especially the condition `j < 10`, they might think of it as a simple boolean expression and think that it's evaluated immediately on first call. It might trip them. They'll have to see the method definition to really know that it's a by-name parameter instead of a normal boolean one.

With Ruby, the tradeoff is that the calling code doesn't look like the native dsl. But the great part is that anyone coming across the calling code anywhere will know exactly what the method is going to do with the anon function that was passed.

I prefer the Ruby way, but was really impressed that Scala could do it exactly as per the DSL.
Can you separate DEV from POLITICS ?
Tags: discuss, politics
Published: 2020-02-15 12:20:32

IMHO the short answer is NO ! BUT whats your opinion ?

Some recent examples
* GitHub & ICE
* Google & Weaponisation of AI

Some long standing +VE (dev/tech/political?) campaigns 
* [ONE](https://www.one.org/international/) - Join the fight against extreme poverty
* [RED](https://www.red.org/) - Join the fight against AIDS
Reading Snippets [46 => Objects] 📔
Tags: javascript, beginners, oop, codenewbie
Published: 2020-02-15 12:08:00

The only way to remove a property from an object is to use the delete operator. Using null or 0 only removes the value associated with the property but not the key. 

The keyword may need to be notated as a string literal in order for it to be properly interpreted by older JavaScript engines. 

<code>
var test = {
    'case': 'I am a keyword, so I must be notated as a string',
    delete: 'I am a keyword, so me too' // raises SyntaxError
};
</code>

<kbd><small>Source:<a href="http://bonsaiden.github.io/JavaScript-Garden/">JavaScript Garden
</a></small></kbd>
What CLI utilities/commands do you use when creating a new project?
Tags: beginners, cli, discuss, productivity
Published: 2020-02-15 12:05:17

Let's all share the commands that we run when bootstrapping a new project, maybe we can all get to know a few new tools that can help us create our future projects!

Here's my list:

## `git init`

I always use git, so this is usually the first command I run.

## `yarn init`

Most of my projects are related to web development and this is an easy way to create a `package.json` file.

## `npx tsc --init`

If my project uses TypeScript, this command generates a `tsconfig.json` with great documentation about all the configuration properties.

## `npx gitignore`

As I use git in every project, I need to have a `.gitignore` to prevent committing some files. For example, running `npx gitignore node` will generate a `.gitignore` file for this kind of project.

There are multiple types supported, you can check the list by running `npx gitignore -types`


## `npx licensed`

This one allows you to choose a license for your project and then it will generate its corresponding `LICENSE` file, and that's great if you want to make your project open source.

---

That would be it for me, now it's your turn to share with us the commands you use the most when you start a new project.


![Cat typing](https://media1.giphy.com/media/uzglgIsyY1Cgg/giphy.gif?cid=790b7611a21bcda86c47b8c463b751cb6504a24cfb87995a&rid=giphy.gif)
My experience with Test Driven Development (TDD) and how to implement it in a project
Published: 2020-02-15 11:53:40

### **Introduction**


Test-driven development (TDD) is a development technique where you first have to write a test that fails before writing a passing code.  It relies on the repetition of a very short development cycle: requirements are turned into very specific test cases, then the code is improved so that the tests pass. 

*“For my first-time using TDD, I asked myself why should we write code to test other code that we don’t even have.`”*

TDD starts with designing and developing tests for every small functionality of an application. It ensures that the source code is thoroughly unit tested and leads to modularized, flexible and extensible code. It focuses on writing only the code necessary to pass tests, making the design simple and clear.


### **Activities involved in Test-Driven Development (TDD)**


**1. Coding** 

The first activity that you do in TDD is to write a unit test case which is a single test that describes a feature of a program. To write a test, the developer must clearly understand the feature's specification and requirements. The developer can accomplish this through use cases and user stories to cover the requirements and exception conditions.
 

**2. Testing**

Run the test and see if all test cases now pass, the programmer can be confident that the new code meets the test requirements, and does not break or degrade any existing features. If they do not, the new code must be adjusted until they do. And then you write the simplest code possible to make the test pass.

**3. Refactoring** 

Refactoring is an activity where you make the code efficient. You do not change the functionality, but rather alter the internal dynamics to enhance the performance. Some examples include identifying and removing duplicate and dead pieces of code, simplifying nested classes.

###**The benefit of using TDD**

With TDD you get fewer bugs in code because you have tested out the main features. The other thing is the focus, what I am trying to say here is that your focus is narrowed to making the test passes. The third benefit of using TDD is that test act as documentation if you don’t know what a bit of code do you can read it and see what it does.


###**Conclusion**


In test-driven development (TDD), a test is written first before writing the functional code. This doesn’t mean that TDD can replace traditional QA, but instead, it ensures effective unit testing. An effective unit test will ensure better code coverage.
My experience with Test Driven Development (TDD) and how to implement it in a project
Published: 2020-02-15 11:41:53

### **Introduction**


Test-driven development (TDD) is a development technique where you first have to write a test that fails before writing a passing code.  It relies on the repetition of a very short development cycle: requirements are turned into very specific test cases, then the code is improved so that the tests pass. 

*“For my first-time using TDD, I asked myself why should we write code to test other code that we don’t even have.`”*

TDD starts with designing and developing tests for every small functionality of an application. It ensures that the source code is thoroughly unit tested and leads to modularized, flexible and extensible code. It focuses on writing only the code necessary to pass tests, making the design simple and clear.


### **Activities involved in Test-Driven Development (TDD)**


**1. Coding** 

The first activity that you do in TDD is to write a unit test case which is a single test that describes a feature of a program. To write a test, the developer must clearly understand the feature's specification and requirements. The developer can accomplish this through use cases and user stories to cover the requirements and exception conditions.
 

**2. Testing**

Run the test and see if all test cases now pass, the programmer can be confident that the new code meets the test requirements, and does not break or degrade any existing features. If they do not, the new code must be adjusted until they do. And then you write the simplest code possible to make the test pass.

**3. Refactoring** 

Refactoring is an activity where you make the code efficient. You do not change the functionality, but rather alter the internal dynamics to enhance the performance. Some examples include identifying and removing duplicate and dead pieces of code, simplifying nested classes.

###**The benefit of using TDD**

With TDD you get fewer bugs in code because you have tested out the main features. The other thing is the focus, what I am trying to say here is that your focus is narrowed to making the test passes. The third benefit of using TDD is that test act as documentation if you don’t know what a bit of code do you can read it and see what it does.


###**Conclusion**


In test-driven development (TDD), a test is written first before writing the functional code. This doesn’t mean that TDD can replace traditional QA, but instead, it ensures effective unit testing. An effective unit test will ensure better code coverage.
Go for Beginners - Introduction
Tags: go, beginners, webdev
Published: 2020-02-15 11:33:45

This series is aimed at beginners who are new to GoLang which is termed as a promising language according to JetBrains. We will look at some aspects which make the language nice and simple. So let's start off!

__WHY GO__? 
Let's consider the basics. According to the official golang.org website, _Go is an open source programming language that makes it easy to build simple, reliable, and efficient software_. The language comprises of a simple syntax and it's less verbose compared to Java. It is easy to read and understand but yet powerful. Did you know? Docker is written in Go. That sounds cool right? Which makes learning Go worth it in my own opinion. Also, it supports dynamic type system as well as type safety which results to fewer errors during compile time. 

This is an introduction to my series on Go, stay tuned and if you have any questions, feel free to drop the questions. Let's all learn together!
My experience with Test Driven Development (TDD) and how to implement it in a project
Tags: introduction
Published: 2020-02-15 11:30:25

Test-driven development (TDD) is a development technique where you first have to write a test that fails before writing a passing code.  It relies on the repetition of a very short development cycle: requirements are turned into very specific test cases, then the code is improved so that the tests pass. 

“For my first-time using TDD, I asked myself why should we write code to test other code that we don’t even have.`”

TDD starts with designing and developing tests for every small functionality of an application. It ensures that the source code is thoroughly unit tested and leads to modularized, flexible and extensible code. It focuses on writing only the code necessary to pass tests, making the design simple and clear.

Activities involved in Test-Driven Development (TDD)


1. Coding 

The first activity that you do in TDD is to write a unit test case which is a single test that describes a feature of a program. To write a test, the developer must clearly understand the feature's specification and requirements. The developer can accomplish this through use cases and user stories to cover the requirements and exception conditions.
 

2. Testing

Run the test and see if all test cases now pass, the programmer can be confident that the new code meets the test requirements, and does not break or degrade any existing features. If they do not, the new code must be adjusted until they do. And then you write the simplest code possible to make the test pass.

3. Refactoring 

Refactoring is an activity where you make the code efficient. You do not change the functionality, but rather alter the internal dynamics to enhance the performance. Some examples include identifying and removing duplicate and dead pieces of code, simplifying nested classes.

The benefit of using TDD

With TDD you get fewer bugs in code because you have tested out the main features. The other thing is the focus, what I am trying to say here is that your focus is narrowed to making the test passes. The third benefit of using TDD is that test act as documentation if you don’t know what a bit of code do you can read it and see what it does.


Conclusion 


In test-driven development (TDD), a test is written first before writing the functional code. This doesn’t mean that TDD can replace traditional QA, but instead, it ensures effective unit testing. An effective unit test will ensure better code coverage.
#KnowYourWorth - Are you really being valued?
Tags: discuss, career, rant
Published: 2020-02-15 11:29:59

During the past days, a new trending hashtag appeared on Twitter, calling to all the devs/designers around the world to mention what do they earn, what did they study, and for how long have they been working in the software/design sector.

You can spot things like this: 
_________________
{% twitter 1228247484591476736 %}

or

{% twitter 1228341690362191874 %}
_________________
But there are also many several case where you see **totally the opposite**, like:
_________________

{% twitter 1228465847661887488 %}

or, well, myself:

{% twitter 1228602383363706880 %}
_________________


What concerns me the most, it is not the huge difference between salaries per country, as the expenses are different. It is, for example, that, your salary is completely worse than others in the same country. That you have to bear spending **60%-65% of your salary only for the monthly rent**...

You can more about my rant here: {% twitter 1228627734823305216 %}

**What is your situation?**
**What do you think?**
**Do you need help?**

Let us know in the comments, or [Twitter](https://twitter.com/brownio_)!

Want to share your state? Here you have a template:

🏫: Studies
⏳: Experience
🏷: Role
🌎: Country / City
💸: Salary


A user I don't know (if you do, please share), created [this spreadsheet](https://docs.google.com/spreadsheets/d/1Ukk1I_voBALZrBNznMfCLF6QMIlEdROdv06T3zdIppg/edit#gid=0) with many of the salaries posted, in case you are curious.
Первые таблицы и списки в HTML
Tags: codepen
Published: 2020-02-15 09:07:42

<h2>5 самых известных людей мира</h2>
<ul>
  <li>Мартин Лютер Кинг</li>
  <li>Роберт Оппенгеймер</li>
  <li>Альфред Хичкок</li>
  <li>Чарли Чаплин</li>
  <li>Коко Шанель</li>
</ul>
<h2>ТОП-5 списка Forbes</h2>
<ol>
  <li>Билл Гейтс ($75 млрд)</li>
  <li>Амансио Ортега ($67 млрд)</li>
  <li>Уоррен Баффет ($60,8 млрд)</li>
  <li>Карлос Слим Элу ($50 млрд)</li>
  <li>Джефф Безос ($45,2 млрд)</li>
</ol>
<h2>Заказ аниматоров</h2>
<table>
  <thead>
    <tr>
      <td>Персонаж</td>
      <td>Время выступления</td>
      <td>Цена</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Белоснежка</td>
      <td>12.00</td>
      <td>1 500 руб.</td>
    </tr>
    <tr>
      <td>Лунтик</td>
      <td>12.30</td>
      <td>4 800 руб.</td>
    </tr>
        <tr>
      <td>Маша и Медведь</td>
      <td>13.15</td>
      <td>8 400 руб.</td>
    </tr>
        <tr>
      <td>Бэтмен</td>
      <td>13.45</td>
      <td>5 200 руб.</td>
    </tr>
        <tr>
      <td>Джек Воробей</td>
      <td>14.30</td>
      <td>3 300 руб.</td>
    </tr>
            <tr>
      <td>Аватар</td>
      <td>14.50</td>
      <td>4 000 руб.</td>
    </tr>
            <tr>
      <td>Энгри Бердс</td>
      <td>15.20</td>
      <td>2 150 руб.</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td colspan="2">ИТОГО</td>
      <td>29 350 руб.</td>
    </tr>
  </tfoot>
</table>
<section>
  <h2>Звезды мировой эстрады</h2>
  <table>
    <thead>
      <tr>
        <td colspan="2">ФИО</td>
        <td rowspan="2">Возраст</td>
        <td rowspan="2">Знак зодиака</td>
      </tr>
      <tr>
        <td>Имя</td>
        <td>Фамилия</td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Майкл</td>
        <td>Джексон</td>
        <td>51</td>
        <td>Дева</td>
      </tr>
      <tr>
        <td>Адриано</td>
        <td>Челентано</td>
        <td>78</td>
        <td>Козерог</td>
      </tr>
      <tr>
        <td>Шарль</td>
        <td>Азнавур</td>
        <td>94</td>
        <td rowspan="2">Близнецы</td>
      </tr>
      <tr>
        <td>Пол</td>
        <td>Маккартни</td>
        <td>74</td>
      </tr>
      <tr>
        <td colspan="2">Мадонна</td>
        <td>58</td>
        <td>Лев</td>
      </tr>
    </tbody>
  </table>
</section>
Face enhancer‏ - Denoising Auto Encoder by Tensorflow , Keras and skimage


Tags: deeplearning, python, machinelearning, opensource
Published: 2020-02-15 11:21:33

# [Auto Face Photo Encaher](https://github.com/loaiabdalslam/FC) 
It is a simple example of how restructuring and Denosing works within the Auto Encoderes model , we used the dataset of faces you can reach it from [Download Link](https://drive.google.com/drive/u/0/folders/1tZUcXDBeOibC6jcMCtgRRz67pzrAHeHL)
by [Tero Karras](https://research.nvidia.com/person/tero-karras)


[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/loaiabdalslam/FC/blob/master/face-enhancer%E2%80%8F.ipynb)


# Requirements
- [tensorflow](tensorflow.org)
- [keras](http://keras.io/) 
- [open cv](https://pypi.org/project/opencv-python/) 

# Table Of Contents
-  Importing Data
-  Nosie Fliters using skimage
-  Image2Image Auto Encoder
-  HyperParams Tunning Tips


# MLP Encoder
![Results](https://github.com/loaiabdalslam/FC/raw/master/media/model.png)



# Results
![Results](https://github.com/loaiabdalslam/FC/raw/master/media/res1.png)
![Results](https://github.com/loaiabdalslam/FC/raw/master/media/res2.png)
![Results](https://github.com/loaiabdalslam/FC/raw/master/media/res3.png)
![Results](https://github.com/loaiabdalslam/FC/raw/master/media/res4.png)




# Contributing
Any kind of enhancement or contribution is welcomed.
Cara supaya bisa khatam Quran dalam sebulan
Tags: quran, khatam, trick, reading
Published: 2020-02-15 11:14:25

---
title: Cara supaya bisa khatam Quran dalam sebulan
published: true
description: Cara supaya bisa khatam Quran dengan cepat
tags: quran, khatam, trick, reading
series: Catatan Penghapal Quran
---

Cara mudah untuk bisa khatam Quran dalam sebulan adalah dengan mengaji _satu hari satu juz_. Nah, supaya lebih seru, **juznya disesuaikan dengan tanggal**. Misalnya tanggal 3, maka baca juz 3. Begitu pula dengan tanggal lainnya.

Dengan Quran yang berisi 30 juz, maka tentu saja bisa diselesaikan dalam waktu 30 hari atau sebulan.

Apakah berat sehari sejuz? Harusnya sih nggak. Soalnya, hanya memerlukan waktu 30 menit untuk menyelesaikan 1 juz.
How to change screen orientation in Flutter
Tags: flutter, dart, programming, mobile
Published: 2020-02-15 10:28:47

---
title: How to change screen orientation in Flutter
published: true
description: change screen orientation in Flutter
tags: flutter, dart, programming, mobile
cover_image: https://mightytechno.com/wp-content/uploads/2020/02/Flutter.png
canonical_url: https://mightytechno.com/screen-orientation-in-flutter/
---

The mobile application usually develops to support both in portrait and landscape mode without any issue. But in some special case, you may need to set the orientation of the application to fix direction to get proper real state space to each component

#Set the orientation in flutter

First, you have to import the services package.

```dart
import 'package:flutter/services.dart';
```

Next, you can set orientation by setting the value to setPreferredOrientations method in SystemChrome class. In the Flutter the application entry point is the main method. So you can set orientation before call the runApp method in the main method. But if you need to call a binding before the runApp method, you must call the ensureInitialized method in WidgetsFlutterBinding class

```dart

 void main() {
    WidgetsFlutterBinding.ensureInitialized();   SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]).then((_){
    runApp(MyApp());
   });
 } 
```

#Set landscape orientation only

```dart
SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft,DeviceOrientation.landscapeRight])
```
You can set either landscapeLeft or landscapeRight to make it work in one way.

#Set portrait orientation only

```dart
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitDown,DeviceOrientation.portraitUp])
```
If you set both portraitUp and portraitDown as orientation when you tilt your phone upside down it will rotate the app. If you don’t like to work in upside-down orientation, you can just set only the portraitUp.


#Change orientation dynamically
This is the same as above, you just need to use the same method when clicking a button or trigger some action.

```dart
RaisedButton(
              child: Text("Portrait"),
              onPressed: (){
              SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
            })
    
```

#Get device orientation
It quite easy to get current orient in flutter app using MediaQuery

```dart
MediaQuery.of(context).orientation
```

This will return Orientation object and you can check is the portrait or landscape like below

```dart
 MediaQuery.of(context).orientation == Orientation.landscape
```


Originally published at [mightytechno](https://mightytechno.com/screen-orientation-in-flutter/)

Connect with me - [Instagram](https://www.instagram.com/mighty_techno) |[Blog](https://mightytechno.com/) |[Youtube](https://www.youtube.com/channel/UCwxiHP2Ryd-aR0SWKjYguxw)
learning to code some starter project ideas !
Tags: beginners, smn, api, discuss
Published: 2020-02-15 10:12:39

ive seen a lot of people asking how to start learning to code ? what sort of project should i start with ? what language should i use etc etc

well i dont want to get into the endless which language should i start with argument (hehe in the good old days it was easy it was C but now id use js/node or python)

but i would recommend starting with an API based project 

you can write a thick client, thin client or a mobile app you can add as much or as little front end or back end functionality (3D charts or a txt table) and back end functionality (history, stats) as you like 

the most important thing is to chose an API in an area your are interested and PASSIONATE about for example films, movies, photography, railways, smn, bmn, food or weather

some shortcuts
1 look at [github](https://github.com/osde8info?tab=repositories), gitlab & [github gists](https://gist.github.com/osde8info) dont be afraid to abandon a git project if make fails just move on to the next one

1 look at official mozilla, chromium docs

1 look at a preexisting commercial offering such as [TweetBinder](https://www.tweetbinder.com/pricing/) can you make it better ? can you  save money by writing your own BTW i really want that TweetBinder functionionality im that close to paying them the £75 

once you are hooked (sic) to the world of API coding you will never run out of coding ideas and maybe you can have fun, save money or maybe even make money on your journey