teleren/devto huggingface dataset:
Integrate Ad SDK in Golang games
Tags: go, game
Published: 2018-08-31 06:39:35

---
title: Integrate Ad SDK in Golang games
published: true
description: A way to add third-party java code to golang project 
tags: golang,game
---

Days ago, I wrote an article about porting Golang project to Android with `gomobile build` command. These days, Our team has developed a new game, and we are going to integrate AD SDK to make money.  

It's not easy to add java code to a Golang project, but if you think in the other way, we can simply copy the go binary to an Android project, that we can take this project as a normal Android project.

So here is the main step:
1. Create a new Android project
2. Copy the `GoNativeActivity.java` file to project (you can find the file in gomobile package)
3. Copy the `.so` to project
4. Configure the `AndroidManifest.xml` file to use your new Acitivity

That's all, Build and Run, you can see that the Android project has been running our Golang code. But where can I get these `.so` files?  I just unzip the `.apk` built from `gomobile build -target=android ./` command. 

The next step is to add ads. Adding ads to this special project is no different from any Android project. Here, we add the Ad code in `GoNativeActivity`. Note that, GoNativeActivity has no view tree, we can't just add AdView as a subview. A way to solve this problem is to use a `PopupWindow` to contain the adview.

In fact, it's very simple:
```
// load adview
popup = new PopupWindow(this);
popup.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
// banner
AdView adView = new AdView(this);
popup.setContentView(adView);

// show ad at bottom of screen
popup.showAtLocation(getWindow().getDecorView(), Gravity.BOTTOM, 0, 0);
```

In my project, I integrated AdMob's Banner SDK. It works very well with test ad-uint-id. Here are screenshots of my game:
![Shoot Stack](https://thepracticaldev.s3.amazonaws.com/i/fdxs3gr7uivx4polaox7.png)

I have released the MAC version and Android version. You can get MAC version from itch.io: https://ntop.itch.io/shootingblock or download from GooglePlay: https://play.google.com/store/apps/details?id=io.korok.shootingblock

It's casual game, I really like the art style. (PS: Is there a way to close the ad remotely, it shows always. It seems AdMob doesn't provide a way to control frequency)
Invert your ifs!
Tags: refactoring, devtips
Published: 2018-08-31 06:27:00

---
title: Invert your ifs!
published: true
description: Refactoring when having to deal with multiple exception cases
tags: refactoring, devtips
---

You've all seen the literal **side mountain of code**, here's a refresh:
```javascript
if (candies.length > 0) {
    if (store.isOpen()) {
        if (store.allCandyIsLow()) {
            for (let candy of candies) {
                store.refill(candy);
            }
            notification('Store ' + store.Name + ' had its candies refilled.');
        } else {
            console.error('There is still candy in the store');
        }
    } else {
        console.error('No stores to put the candy into');
    }
} else {
    console.error('No candies');
}
```

This becomes really difficult to manage because 
 * code block's main purpose is nested inside all if statements while 
 * the exceptional/error cases are right in your face and
 * their condition and error are as far away from each other as possible

This hurts the code's **readability**, **flexibility** and **maintainability** (adding or changing the condition's order becomes tough).

Here's a practical solution that can be applied at any moment in development you want with doing these simple steps until there are no longer any exception cases nesting the main code:
 * take the code out of the if statement
 * invert the condition
 * bring the code inside else in the if block
 * add a return statement (or whatever comes after the large block)

The code from above should now look something like this:
```javascript
if (candies.length <= 0) { // or === 0 in this case
    console.error('No candies');
    return;
}
if (!store.isOpen()) {
    console.error('No stores to put the candy into');
    return;
}
if (!store.allCandyIsLow()) {
    console.error('There is still candy in the store');
    return;
}

for (let candy of candies) {
    store.refill(candy);
}
notification('Store ' + store.Name + ' had its candies refilled.');

```

Albeit, the code block itself became larger but 
 * there are no longer any nested if statements
 * the main code comes right after all the exception cases
 * you can see what each exception case does and add/modify as needed



What do you think? Are there any better solutions? Does this one have some critical flaws we missed? Ask away!
Native HTTP Debugging Proxy for macOS
Tags: showdev, testing, ios, webdev
Published: 2018-08-31 06:22:39

---
title: Native HTTP Debugging Proxy for macOS
published: true
description: Proxie is a native HTTP Debugging Proxy for macOS
tags: #showdev, #testing, #ios, #webdev
---

Several years ago when I started to use Mac, I was happy to see so many native and polished apps for developers, but also a little disappointed of the absence of a native alternative to Fiddler.

As the time went by, more and more apps were electron-based and I saw little hope that someone would build a native Fiddler so I decided to do it myself.

So here comes [Proxie](https://proxie.app/), a native HTTP debugging proxy for macOS. It's got a nice filtering system, breakpoints, scripting and so on.

Hope you guys like it;)
Hi Every one how we can compare the AngularJS ( 1.x) and Angular(2+) Performance by chrome dev tool  or any other method ?
Tags: angular, javascript, chrome
Published: 2018-08-31 06:10:31

---
title: Hi Every one how we can compare the AngularJS ( 1.x) and Angular(2+) Performance by chrome dev tool  or any other method ?
published: true
description: Hi Every one how we can compare the AngularJS ( 1.x) and Angular(2+) Performance by chrome dev tool  or any other method ?
tags: angular , angularjs , javascript, chrome 
---
What make Boss? What make Leader?
Tags: discuss
Published: 2018-08-31 06:01:00

---
title: What make Boss? What make Leader?
published: true
description: 
tags: #discuss 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/qc7kulltyo6rsd79s1bm.png
---

Why **BOSS** can be **BOSS**?

What make you become BOSS? What make you become Leader?

What make a Leader become BOSS?

I know there are many reason for a BOSS to be a BOSS. But sometimes, a leader can be in **BOSS mode**. What make it?

I know there are so many reasons below them such as culture, knowledge, personal characteristics and so many reasons. I would like to state what I think why cause it.

# Time

It requires time to let your supervisor to know the issue well and then he could help you but not blame. Time is a special factor in a workspace. It may make your leader in **BOSS mode** as he does not have time to cater your issue.

# Knowledge 

Your supervisor may not have the knowledge to be your leader. He is just a person assigned to monitor the progress. It is the worst case if the monitor tried to blame the workers.

# Responsibility

Different people may be assigned a different role in an organisation. Some people may think it is not his responsibility to help other people. The failure of a project or task is not his business. 

In some case, the project is on fire. If someone tried to help you, it would make him on fire too. Therefore, he would like to blame you instead of getting fire. 

# Other Factors

The above reason is just what I think. Actually, there are a lot reason behind it such as culture, personal emotion and relationship.

# What you can do

BOSS is a unavoidable. What you can do is just to equip yourself to fight with them.


# Reference

* https://dev.to/imben1109/what-is-management-b7i
React Native Simple ListView Component Android Example
Tags: react, reactnative, android, mobileapp
Published: 2018-08-31 04:20:53

---
title: React Native Simple ListView Component Android Example
published: true
description: React Native Simple ListView Component Android Example
tags: #react #reactnative #android #mobileapp
---

Post Link : <a href="https://www.skptricks.com/2018/08/react-native-simple-listview-component-android-example.html" > React Native Simple ListView Component Android Example </a>


Today we will see <a href="https://www.skptricks.com/2018/08/react-native-simple-listview-component-android-example.html" >how to use ListView in react native android application</a> and apply set onPress event on ListView to get value from selected list item. ListView is a core component designed for efficient display of vertically scrolling lists of changing data. The minimal API is to create a ListView.DataSource, populate it with a simple array of data blobs, and instantiate a ListView component with that data source and a renderRow callback which takes a blob from the data array and returns a renderable component.

<img src="https://2.bp.blogspot.com/-g4jEwHkfAag/W4gx5c4f4EI/AAAAAAAAB2o/woBmE9VIkwcEW_s4KSvlTIt0gVe6-SqxwCLcBGAs/s400/ss.jpg" />

In this example we are going to create simple ListView layout, where we will display hard coded values from state and when user click on any of these list items, then it will display selected item in alert dialog box.

{% youtube hr9FraCGuFs %}

<a href="https://www.skptricks.com/2018/08/react-native-simple-listview-component-android-example.html" > Download Source Code </a>
Help for writing a proposal (RoR side-project)
Tags: help
Published: 2018-08-29 21:32:22

---
title: Help for writing a proposal (RoR side-project)
published: true
tags: help
---


Hello, 

I am a new Web Developer working primarily with Ruby on Rails. I have been working with a Dev Team for over a year developing Web Apps, and I recently decided to start taking side-projects on my own in order to build my portfolio and get some experience. 

I got in touch with a client that is willing to pay me for building a basic CRUD App. 

I have a general idea of what my client wants, but he would like to have a proposal (with an estimate price) before moving forward. 

I would like to be very professional and transparent throughout the whole process (starting with the proposal) and I was wondering if you have any advice or elements that I MUST include on the proposal. 

So far, I found Thoughtbot's Playbook very helpful, and it mentions that it is better to not have a very detailed fixed bid (since the project might change or take longer) but to work under a budget and breaking the product into stages (Sprints). 

My client understands this, but he would like to have at least an estimate. 

Any advice? How do you calculate your hours? Do you include hosting (Heroku) prices as part of the proposal? Do you normally charge a monthly maintenance fee?

** I am planning on building a PWA using Ruby on Rails. 

Reading articles from dev.to has become part of my routine, but this is the very first time I write something here. I appreciate your help! :)
Weather App built in pure javascript
Tags: javascript, es6, webpack
Published: 2018-08-30 23:26:07

---
title: Weather App built in pure javascript
published: true
description: Weather forecast app, built in pure javascript to put into practice what I learned in my studies.
tags: javascript, es6, webpack
cover_image: https://thepracticaldev.s3.amazonaws.com/i/z45usha5xpas794vd87a.png
---

# Weather App

Weather forecast app, built in pure javascript to put into practice what I learned in my studies. 

## Built with

- ES6 
- javascript
- webpack.
- Sass
- [openweather]

![Example running](https://thepracticaldev.s3.amazonaws.com/i/9hl1l257g76399wi56u5.gif)

### Prerequisites

What things you need to install the software and how to install them

* node.js
* NPM Package Manager
* Create token in [openweather] and include in the file "/src/js/token.js"

### Installing

Clone this repository

```
git clone https://github.com/mariorodeghiero/weather-fetch-api
```

Installing the dependencies from the NPM Package Manager

```
npm install
```

To start the development environment, run the following command:

```
npm run dev
```

**Note:** This command also performs a clear in the **dist** folder and build again.

```
npm run server
```

After run, the browser open window automatically at http://localhost:8080

## Deployment

Run the command below to deploy, minimizing All Files.

```
npm run prod
```

If you liked this Theme, visit repository on [GitHub](https://github.com/mariorodeghiero/weather-fetch-api)  ⭐️ 
Thank you, I hope you like it 😊

[openweather]: https://openweathermap.org
ASP.NET Core 依存性の注入 (DI)：同一インタフェース複数実装サービスの解決方法
Tags: dependencyinjection, ioc, dotnetcore, aspnetcore
Published: 2020-08-14 13:19:08

---
title: ASP.NET Core 依存性の注入 (DI)：同一インタフェース複数実装サービスの解決方法
published: true
tags: dependencyinjection,ioc,dotnetcore,aspnetcore
canonical_url: https://medium.com/@joni2nja/asp-net-core-%E4%BE%9D%E5%AD%98%E6%80%A7%E3%81%AE%E6%B3%A8%E5%85%A5-di-%E5%90%8C%E4%B8%80%E3%82%A4%E3%83%B3%E3%82%BF%E3%83%95%E3%82%A7%E3%83%BC%E3%82%B9%E8%A4%87%E6%95%B0%E5%AE%9F%E8%A3%85%E3%82%B5%E3%83%BC%E3%83%93%E3%82%B9%E3%81%AE%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%B3%95-474d0b88b34
---

#### 依存性の注入 (Dependency Injection) で同一インタフェースで複数実装サービスの解決方法を紹介します。

![](https://cdn-images-1.medium.com/max/1024/1*yFWyZFLSdc-Td-CgWrLdGQ.png)<figcaption>一つのインタフェースで複数実装するサービス例</figcaption>

これまでASP.NET MVC/Web APIプロジェクトをゼロから作る案件があった場合、必ず最初に入れるのはIoCコンテナでしたが、ASP.NET CoreはデフォルトでIoCコンテナをサポートされていますので、IoCコンテナを入れる作業が任意になりました。もちろん用途により[Autofac](https://autofac.org/)や[Simple Injector](https://simpleinjector.org/)等、好みのIoCコンテナに変更することも可能です。

本投稿では一つのインタフェースで複数実装するサービス（クラス）がある場合、どういった解決方法があるのかをいくつか紹介したいと思います。

サンプルとしてインタフェースとその実装するサービスは下記を使用します。

{% gist https://gist.github.com/jo-ninja/f695eb81a22a5a41df8578591cf99d81 %}

サービスの解決方法を見ていきましょう。

### ■パターン①

IServiceProvider を使用します。

{% gist https://gist.github.com/jo-ninja/6047e04dc5e4f568cf130013ea9108c2 %}

### ■パターン②

IEnumerable\<T\> を使用します。

{% gist https://gist.github.com/jo-ninja/526293ad66c0a29f0ac73bd246499a23 %}

### ■パターン③

ファクトリーパターンを使用します。

{% gist https://gist.github.com/jo-ninja/aa92c15077cbb848d5d2df3f6eb9a6f5 %}

{% gist https://gist.github.com/jo-ninja/fc6a35ebdd32ac68f3f5eef2cff7b187 %}

### ■パターン④

Func\<string, T\> を使用します。

{% gist https://gist.github.com/jo-ninja/07a4f511556f276528a1dbbc07af48c8 %}

Startup クラスの ConfigureServices にはこんな感じで登録します。

{% gist https://gist.github.com/jo-ninja/4e4e2449d9c450b4e7f24b7edc8bc6c8 %}

### ■パターン⑤

正式名称わかりませんが、_中間_インタフェースを使用します。

{% gist https://gist.github.com/jo-ninja/1f0095cc1599620a9edeeb08679ca9d0 %}

### ■パターン⑥

IPoopService\<out T\> パターンを使用します。

{% gist https://gist.github.com/jo-ninja/e4d07b922e0949689cbcc981591cc69d %}

このようにいくつかパターンがありますので、必要な時に是非思い出して活用してみてください。
Beginner's Mistakes:  Variables, Functions & Objects. . . Oh my!
Tags: beginners, javascript
Published: 2018-08-30 22:14:38

---
title: Beginner's Mistakes:  Variables, Functions & Objects. . . Oh my!
published: true
description: beginner's tips for JavaScript terminology and syntax
tags: beginners, javascript
---

Beginner’s Mistakes: JavaScript’s Variables, Functions & Objects. . . Oh My!

JavaScript post-class four of coding bootcamp, I find my head a bit ‘dazed and confused’. . . a far cry from HTML’s elements, CSS’s selectors and properties, and, yes, even CSS grid.  Instead, variables, functions, objects, properties, methods, events, conditions and loops are swimming around in my brain.  So, I do what any normal noob would do, look for misery. . . I mean. . . company, googling “beginner common mistakes” in JavaScript . . . I find myself.  Sigh.  OK.  Common mistakes are universal, save the random coding savant.  

Among the most cited common mistakes, syntax issues seem to rank the highest.  This includes: missing or mismatched brackets, parentheses, curly brackets, commas and semicolons; failure to camel case when naming variables; and naming variables with JavaScript reserved words . . .  to name a few.  

Another favorite of those new to JavaScript, is confusing assignments and comparisons. I can personally attest to this one.  There is a difference between assignment “=” and comparison “==” (forgiving equality) and “===” (strict equality), and the difference is functioning code vs. a non-functioning code. 

If you can relate to the mistakes that I have described, worry no more!  I have provided some examples and charts below to assist in understanding how variables, functions and objects work at a fundamental level with some syntax highlights.  Hope it helps! Keep calm and code on.

<img src="https://thepracticaldev.s3.amazonaws.com/i/br1wzlvv9pw722jq5kwi.png"/>

<img src="https://thepracticaldev.s3.amazonaws.com/i/tqdfahozcr0mlv1izfvb.png"/>

<img src="https://thepracticaldev.s3.amazonaws.com/i/lk2shvdaa9ljkdplsxlm.png"/>
How to manage your holidays?
Tags: holiday, worklifebalance
Published: 2018-09-11 21:04:24

---
title: How to manage your holidays?
published: true
tags: holiday,worklifebalance
canonical_url: https://howtosurviveasaprogrammer.blogspot.com/2018/08/how-to-manage-your-holidays.html
---

Let’s take an easy, but great topic today: the topic of holidays.

I think holidays are very important for programmers, that’s the time when you are really leaving your life, except is your work is your life.

The amount of your holiday is pending on the country where you are leaving and your company, but the big question is: how to use your holidays exactly when you need it?

At most of the companies there are critical periods from holiday point of view: the periods when all the colleagues would like to have holidays (summer holiday, christmas holiday etc.) and the periods which are critical from project point of view. The first ones are quite predictable, the second category is unpredictable.

At the beginning of my carrier I made the mistake: I thought that it is enough to request for my holidays two weeks earlier. So in the mid of the summer I just decided to visit a festival, I requested my holidays and the answer was: “sorry it is a critical period right now in the project, you can’t have holiday now”. Ok, shit happened. For the next year I set up a strategy regarding holidays which is working well. This is the following:

Plan your year in the beginning of January and request for holidays. Plan holidays for the fix yearly programs and try to predict when be enough from work (it is good to plan some day in every third month based on my experience). That means you are the first one who is requesting for a holidays for the critical periods, you are the winner. And in January nobody knows when are the critical project periods, so it can’t be a reason for rejecting. Later on if someone is telling that there’s a critical period during your holiday and you should cancel your holiday, you can simply tell, that you already reserved something for that period.

If your plans are changing in the meanwhile you can still reschedule your holidays, your chances are still not worse than without planning.

This is easy and nothing special.

And just a short suggestion: never cancel any planned holiday because of work pressure!

All the best!

  

RelaxedProgrammer
http://howtosurviveasaprogrammer.blogspot.com/
Should browsers still allow users to disable JavaScript?
Tags: healthydebate, webdev, javascript, browsers
Published: 2018-08-30 22:03:33

---
title: Should browsers still allow users to disable JavaScript? 
published: true
description: Nearly forty percent of our lovely community members voted that browsers should no longer allow users to disable JavaScript.
tags: healthydebate, webdev, javascript, browsers
---

We asked the question "Should browsers still allow users to disable JavaScript?" in the [State of the Web Survey we just finished up with](https://dev.to/devteam/state-of-the-web-data---call-for-analysis-2o75), and the results might be surprising.

Nearly forty percent of our lovely community members voted that browsers should no longer allow users to disable JavaScript.

![](https://cl.ly/5f5188dc1be0/Image%202018-08-30%20at%206.02.38%20PM.png)

The feelings involved here cannot fully be expressed merely as a binary. What are your thoughts on this subject?
My first NuGet package! Kritner.SolarEstimate
Tags: netcore, estimate, nuget, solar
Published: 2018-08-30 21:09:02

---
title: My first NuGet package! Kritner.SolarEstimate
published: true
tags: .net core,estimate,NuGet,solar
canonical_url: https://kritner.blogspot.com/2018/08/my-first-nuget-package.html
---

I published my first NuGet package ([https://www.nuget.org/packages/Kritner.SolarProjection/](https://www.nuget.org/packages/Kritner.SolarProjection/))!  Kristen and I recently were considering (and have since financed) a 17,000 kw/year solar array, on the back of our house - [https://photos.app.goo.gl/gZzp7DnkeEcg1zQMA](https://photos.app.goo.gl/gZzp7DnkeEcg1zQMA).  In the process of deciding whether or not to go for it, I started on some spreadsheets, to try and figure out when it would seemingly be "less expensive to have the solar panels, than our normal energy bill".  
  
With that spreadsheet I thought that it seemed like a good opportunity to try out a few new things I hadn't - additional docker work, a NuGet package, some basic angular, typescript, more unit testing.  So over the past few weeks after dinner, I've been tinkering around with my website and produced [solar-projection](http://www.kritner.com/solar-projection).  It started out all contained within my github repo of [https://github.com/Kritner/KritnerWebsite](https://github.com/Kritner/KritnerWebsite), but I needed to figure out how to start playing around with NuGet, so now I have the core "solar projection" logic in its own package - its repo is located at [https://github.com/Kritner/Kritner.SolarProjection](https://github.com/Kritner/Kritner.SolarProjection).  
  
The site is not currently pretty, but it does (hopefully accurately) tell me the information I wanted to know - solar panels seem to work out great for us, as long as we can get 90-100% power generation from the panels (and they're guaranteed for 90% of the 17k).  
  
I hope to be able to continue exploring angular, to make it a bit prettier with perhaps some charting, and datagridding, and perhaps turn it into a stupid little app I could maybe make a few cents off of?  Currently the site only estimates \*\*\*my\*\*\* solar panel array, but it should be a quick change to allow some user inputs so others could use it too.  
  
Oh! and if anyone's interested, the package could be used to run the numbers before I get the user inputs in (or you could do it for me? :D).  The solar array was installed via [Vivint Solar](https://www.vivintsolar.com/), if you're interested in getting a system, I get referral bonuses, get at me!