teleren/devto huggingface dataset:
Use Lucid ORM to Query Related Data from a MySQL Database [AdonisJS]
Tags: node, tutorial, javascript, mysql
Published: 2018-02-15 20:53:07

---
title: Use Lucid ORM to Query Related Data from a MySQL Database [AdonisJS]
published: true
description: Lucid is an implementation of Active Record pattern in Javascript.
tags: node, tutorial, javascript, mysql
cover_image: https://thepracticaldev.s3.amazonaws.com/i/adj8nvcvuicch4fyap2q.png
---

> Subscribe to my YouTube channel for [more tutorials on working with VueJS and AdonisJS -- an MVC framework for NodeJS](https://www.youtube.com/channel/UCF5w1QdWroWOoxxXMgp88AQ?sub_confirmation=1)!

In this video I show you how to define relationships between database tables using the Lucid ORM.

Once those relationships are defined, we'll easily be able to load related data with our main query.


{% youtube _zUF_mhubL0 %}

## Links:

[Githup Repo for code used in the video](https://github.com/patrickodacre/simple-api-adonis-js)

**Related YouTube Videos**
* [Building a Simple API with AdonisJS](https://www.youtube.com/watch?v=5wzcRtrRVd4&list=PLoCq0WM_wHG-rFQEsShMQkgGcTO1Hmnvx)
* [Understanding the IoC Container in AdonisJS](https://www.youtube.com/watch?v=yTiZrOluehU)
Асинхронный PHP: Зачем?
Tags: php, webdev, reactphp, async
Published: 2018-02-28 14:45:41

---
title: "Асинхронный PHP: Зачем?"
published: true
tags: php, webdev, reactphp, async
canonical_url: http://phpprofi.ru/blogs/post/100
---

Асинхронное программирование сегодня достаточно востребованно. Особенно в веб-разработке, где скорость реагирования приложения играет огромную роль. Никто не хочет тратить свое время и ожидать подвисшее приложение, пока вы выполняете несколько запросов к базе, отправляете электронное письмо или запускаете другие потенциально длительные задачи. Пользователи хотят получать ответы на свои действия, и они хотят, чтобы эти ответы происходили мгновенно. Когда ваше приложение становится медленным, вы начнете терять своих клиентов. После того, как пользователь сталкивается с подвисанием приложения, в большинстве случаев он или она просто закрывает его и никогда не возвращается. Когда интерфейс зависает, с точки зрения пользователя не ясно - толи ваше приложение поломанано, толи оно выполняет какие-то длительные задачи и на них требуется некоторое время.

----
Читать далее: http://phpprofi.ru/blogs/post/100

----
En: http://sergeyzhuk.me/2018/02/02/why-asynchronous-php/
Do you monitor the activity of your third parties?
Tags: discuss, dx
Published: 2018-02-15 17:25:06

---
title: Do you monitor the activity of your third parties?
published: true
tags: discuss,dx
---

We all developers depend on third parties, service and software providers. They sometimes announce events such as deprecations and service shutdowns. Such events need your attention and a timely response.

Do you monitor the activity of your third parties? If so how?
Developing Web Apps with ASP.NET Core 2.0 and React - Part 1
Tags: aspnet, react, aspnetcore2, javascript
Published: 2018-02-15 16:54:03

---
title: Developing Web Apps with ASP.NET Core 2.0 and React - Part 1
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: #aspnet #reactjs #aspnetcore2 #javascript
canonical_url: https://auth0.com/blog/developing-web-apps-with-asp-dot-net-core-2-dot-0-and-react-part-1/
---

In this series of posts, you will build a Web application based on ASP.NET Core 2.0 and React. Today, you are going to use ASP.NET Core 2.0 to develop the APIs of your application 🙌

[Read on 💻](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)

![Developing Web Apps with ASP.NET Core 2.0 and React - Part 1](https://thepracticaldev.s3.amazonaws.com/i/fg0n1tqp8kitx2ghzein.png)
Using Cobalt with GitHub pages
Tags: cobalt, blogging
Published: 2018-08-19 15:14:30

---
title: Using Cobalt with GitHub pages
published: true
tags: cobalt,blogging
canonical_url: https://booyaa.wtf/2017/cobalt-github
---

It turns out using [Cobalt](https://github.com/cobalt-org/cobalt.rs) and your personal GitHub page is a bit trickier to setup. Your personal GitHub page as oppose to your repo GitHub page, must have the content in the `master` branch. Repository/Project GitHub pages can live in a subdir of default branch i.e. `docs`

This is not a criticism of Cobalt, but rather myself demonstrating my lack of git prowess.

The general gist of this how to, is that you place your Cobalt project in the `source` branch and then use `cobalt import --branch master` to transfer the rendered content to master.

## Instructions

- Create your user/personal page repo (USERNAME.github.io)
- Follow instructions for initialising a repo

```shell
git checkout -b source
cobalt init
# do cobalty stuff..
cobalt build
# commit, maybe even push to source
cobalt import --branch master
git checkout master
# commit, definitely push
```

If you want to check out my setup you can find it [here](https://github.com/booyaa/booyaa.github.io).

## Things I've not worked out yet

- The `build` folder gets copied to the `master` branch during `cobalt import`. The folder doesn't contain any files. My work around at the moment is to add it to `.gitignore` in the `master` branch.

## Thanks to...

- [Johann Hofmann](http://johannh.me) for allowing me to copy his blog's style (and his travis-ci auto deploy setup).
- [Cobalt](https://github.com/cobalt-org/cobalt.rs) for creating this easy to use static site generator.
Handle Slack's Incoming Webhook easily and type-safely in TypeScript
Tags: javascript, typescript, slack, npm
Published: 2018-02-15 15:31:07

---
title: Handle Slack's Incoming Webhook easily and type-safely in TypeScript
published: true
description: Handle Slack's Incoming Webhook easily and type-safely in typescript.
tags: javascript, typescript, slack, npm
---

[slackapi/node\-slack\-sdk](https://github.com/slackapi/node-slack-sdk) is great slack client. However, it does not contain d.ts files. So I made a library with type definition.

[typed\-slack](https://github.com/starhoshi/typed-slack) has type definitions, so you can handle slack-api easily and type-safely.

Code completion is enabled when using VSCode.

![vscode\.gif \(898×298\)](https://raw.githubusercontent.com/starhoshi/typed-slack/master/docs/vscode.gif)

## Install

```
npm install typed-slack
```

## Usage

### Webhook

```ts
import * as Slack from 'typed-slack'

let slack = new Slack.IncomingWebhook('https://hooks.slack.com/services/.......')
slack.send({ text: 'text' }).then(e => {
  console.log('success')
}).catch(e => {
  console.error(e)
})
```

#### Use options

More optional parameters are [here#typed\-slack\.d\.ts](https://github.com/starhoshi/typed-slack/blob/master/out/typed-slack.d.ts)

```ts
const options = <Slack.IncomingWebhookOptions>{
  text: '@star__hoshi Hi!',
  channel: 'debug',
  icon_emoji: ':smile:',
  link_names: 1,
  attachments: [
    {
      color: Slack.Color.Danger,
      fields: [
        {
          title: 'Priority',
          value: 'High',
          short: false
        }
      ],
      image_url: 'http://my-website.com/path/to/image.jpg',
      ts: 123456789
    }
  ]
}
await slack.send(options)
```

## [starhoshi/typed\-slack](https://github.com/starhoshi/typed-slack)

Please use [typed\-slack](https://github.com/starhoshi/typed-slack) !

<img src="https://raw.githubusercontent.com/starhoshi/typed-slack/master/docs/logo.png" width='200px' />
Ruby Helper for GitHub Markdown
Tags: github, ruby, opensource
Published: 2018-02-15 15:10:41

---
title: Ruby Helper for GitHub Markdown
published: true
description: File includes in GitHub markdown
tags: github, ruby, opensource
---
I have made public my GitHub repository <a href="https://github.com/BurdetteLamar/MarkdownHelper#markdownhelper">MarkdownHelper</a>.

The first feature is file inclusion for GitHub markdown, supporting included text as:

* Highlighted code block.
* Plain code block.
* Verbatim text.
NetworkStatsManager querySummary returning incorrect data for specific time interval
Tags: android
Published: 2018-02-15 12:20:07

---
title: NetworkStatsManager querySummary returning incorrect data for specific time interval
published: true
tags: android
---

I am using following code to get data used per application for a given time interval

long t1 = System.currentTimeMillis()-(60*1000);
long t2 = System.currentTimeMillis();
NetworkStats networkStats = networkStatsManager.querySummary(ConnectivityManager.TYPE_WIFI, null, t1, t2);

long data_tx = 0;
long data_rx = 0;

NetworkStats.Bucket bucket = new NetworkStats.Bucket();    
while (networkStats.hasNextBucket()) {
            networkStats.getNextBucket(bucket);
            String callingApp = context.getPackageManager().getNameForUid(bucket.getUid());
            data_tx = bucket.getTxBytes();
            data_rx = bucket.getRxBytes();
    }

but the values of bucket.getTxBytes() and bucket.getRxBytes() for any given application for given time interval is too big which can not be true as i have checked it with glasswire data monitoring app. So is this the right way to get data usage per application for any given time interval and also how can we have real time watch on application to monitor their internet activities?
WooCommerce 3d Product View Plugin 
Tags: woocommerce3dproduct
Published: 2018-02-15 12:10:22

---
title: WooCommerce 3d Product View Plugin 
published: True
description: If you want to display your product image in a 3d view then WooCommerce 3d product view plugin is perfect for you.
tags: WooCommerce 3d Product
---
<img src="https://thepracticaldev.s3.amazonaws.com/i/htg4ru2ppmwyp3nko7z7.png">
If you want to display your product image in a 3d view then WooCommerce 3d product view plugin is perfect for you. You can add 360 photography images to your product pages which help customers to visualize your product clearly. <a href="https://codecanyon.net/item/woocommerce-360-image-plugin/21204344">WooCommerce 3d product</a> view plugin help to remove the hesitation of users and provides full satisfaction when they see the products from all possible angles. This is a good plugin to boost the sales and increase the profit. The price of this plugin is only 25$ and you can get free updates and upgrades as well. 
<b>Screenshots</b>:  

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


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


<img src="https://thepracticaldev.s3.amazonaws.com/i/21dd7hhm04kcyu6yojsa.png">
What email client do you use and why? (Inbox is driving me nuts!)
Tags: discuss, productivity
Published: 2018-02-15 11:01:48

---
title: What email client do you use and why? (Inbox is driving me nuts!)
published: true
description: Inbox by Gmail is marking important emails as spam. I'm looking for the next best.
tags: discuss, productivity
---
I've used Inbox by Gmail for a very long time, but it's been a constant battle between an incredible user experience and wading through the spam folder multiple times a day because the spam filter seems _way_ too aggressive.

I'm not ready to use Gmail either because its user-interface leaves much to be desired. So I'm curious as to what we all use!
Let’s play with the Android accelerometer + Kotlin
Tags: kotlin, android, sensors
Published: 2018-02-15 05:26:31

---
title: "Let’s play with the Android accelerometer + Kotlin "
published: true
description: 
tags: kotlin, android, sensors
---

This post was originally published on [Medium](https://medium.com/@enzoftware/lets-play-with-the-android-accelerometer-kotlin-%EF%B8%8F-ed92981b0a6c)

---

# General aspects about sensors

Android devices tend to be accompanied with a series of sensors that make the device to interact with the environment that surrounds it.

And that’s already great to have a range of possibilities about what we can do in our applications,these sensors allow the terminal to have a knowledge of the environment that surrounds you,but the sensors are nothing more than electronic parts that capture information from outside and it is the application which should transform this information into data to work them.

![sensors](https://cdn-images-1.medium.com/max/800/1*HgTref-c5Lh_kX33yQC8-g.jpeg)

The activities who works with sensors must implement the interface SensorEventListener that will force us to implement the methods **onAccuracyChanged()** y **onSensorChanged()** .

The method **onAccuracyChanged()** will be executed when the precision of a sensor change , while **onSensorChanged()** will do it every time there is a change in one of the sensors.

# Building an accelerometer app
The topic of sensors in android is tremendously big and it can’t be covered at all in one article, so for this occasion we will be build an accelerometer app, metallball 💥.

![final app](https://cdn-images-1.medium.com/max/800/1*XvbMaUpE-EWxZ-2ZTjppgw.gif)

But first a little bit about this sensor in specific.

## Accelerometer
With this kind of sensor it’s possible to determinate the orientation of the terminal in the real world 🌎 , considering as coordinate axis the middle point of the device.

![device](https://cdn-images-1.medium.com/max/800/1*oyiKkfu-3zGIIqwk9mLIzw.png)

The accelerometer calculates the linear acceleration in each of the 3 axes (x, y, z); each axis has its own accelerometer, so that the data can be received individually.

# The app code
In the **MainActivity** file you access to the vibration service, for that reason don't forget to copy this into the **AndroidManifest** file.

```xml
<uses-permission android:name="android.permission.VIBRATE" />
```
Here is the full code of the app, If you have questions, post it to be able to answer.

{% gist https://gist.github.com/enzoftware/87a25a790ac43433dc019b1eb43ba283 %}

# Conclusion
If you found this helpful, click the <3 below. Follow me for more articles on technology.

Here is the [link](https://github.com/enzoftware/metallball) to the full source code 💥 :

![github](https://afrisoft.co.ke/wp-content/uploads/2017/11/github.png)
Create a WaitGroup by yourself
Tags: go, concurrency
Published: 2018-05-26 16:19:08

---
title: Create a WaitGroup by yourself
published: true
tags: golang,concurrency
canonical_url: 
---

If you had written any concurrency code in Go. I think you could seem `sync.WaitGroup` before. And today point is to focus on creating a waitgroup by channel trick.

How?

First, you need a channel without the buffer.

```go
func main() {
    wait := make(chan struct{})
}
```

Then get something from it so if there was no value in `wait`, the process keeps going. But if just trying to get something from an empty channel. You will get blocking and cause deadlock. Then go will panic it. So we have to change the code a little bit but also be more extendable for next iteration.

```go
// ...
n := 0
wait := make(chan struct{})

for i := 0; i < n; i++ {
    <-wait
}
// ...
```

Now let’s create works loop.

```go
import (
    "time"
)
// ...
n := 10000
wait := make(chan struct{})

for i := 0; i < n; i++ {
    time.Sleep(time.Microsecond)
    wait <- struct{}{}
}

for i := 0; i < n; i++ {
    <-wait
}
// ...
```

ps. This code has a little bug(you can try to find it, or read the answer at the end)

Now we can see it work. The reason for this code can work is because size n is our expected amount of workers. After each worker done their jobs. They will send something(here is `struct{}{}`, but exactly it doesn’t matter thing) into our `wait` channel. We only read `n` things from `wait`.

So after `n` things are read. We won’t be blocked anymore even `wait` got the new thing. Else we have to wait `wait`.

Whole code dependent on this fact. Having this knowledge, we can create ours `WaitGroup` now.

```go
type waitGroup struct {
	n    int
	wait chan struct{}
}

func WaitGroup() *waitGroup {
	return &waitGroup{
		n:    0,
		wait: make(chan struct{}),
	}
}

func (wg *waitGroup) Add(n int) {
	wg.n = wg.n + n
}

func (wg *waitGroup) Done() {
	wg.wait <- struct{}{}
}

func (wg *waitGroup) Wait() {
	defer close(wg.wait)
	for i := 0; i < wg.n; i++ {
		<-wg.wait
	}
}
```

As you can see, we use a type wrapping all the thing we need. (It’s a basic idiom, so I don’t want to say why)

Then method `Add` is preparing for `n` we talk before. Adding these things in a dynamic way.

Next `Done` do the thing as we manually do in previous code.

And `Wait` is read the number of things equal final `n`.

The end lets say what happened in the previous code. You should close the `channel` always. So the code will be:

```go
// ...
wait := make(chan interface{})
defer close(wait)
// ...
```

Maybe you will feel confusing about this part. The reason is `channel` won’t be collected by GC automatic(if it can, it will be another hell). So always closing it is important.

ps. In productive code, please still using the `sync.WaitGroup`, I do a test, `sync.WaitGroup` is 25% faster than the version you see here.

### References:

#### [The Go programming language](http://www.gopl.io/)

- Author: Alan A. A. Donovan & Brian W. Kernighan
- ISBN: 978-986-476-133-3

#### [Concurrency in Go](http://shop.oreilly.com/product/0636920046189.do)

- Author: Katherine Cox-Buday
- ISBN: 978-1-491-94119-5
My Git Hot Commands
Tags: git, gitcommands
Published: 2018-02-14 21:36:08

---
title: My Git Hot Commands
published: true
description: this is my most used list of git command listed here with description of every one
tags: git, git-commands
---
<img src="https://thepracticaldev.s3.amazonaws.com/i/oea99akwtqg6bgzfj4pv.png"/>

1--`git log --pretty=format: --name-only --author="aa-ahmed-aa" --since="2 days ago" | sort | uniq`
display the files modified by specific Author users within the Since time period

2--`git fetch origin`
3--`git reset --hard origin/master`
fetch the remote origin and hard reset your current with the remote (reset everything like the remote)

4--`git log -p --author=aa-ahmed-aa`
get a very detailed information about the files edited by the Author with all the insertion and deletion files

5-- `git commit -m "adding the images" *.jpg`
this is adding commit message to images only (add files by name if you want)
and if you push them it will only push the commited files 

6-- `git stash` to save you current working directory changes to a specific point if you want to reset to master without losing changes
    `git stash list` to list all of your stashed points

7-- 'git clean -d -x -f ' to remove the untracked files 
be careful when using this command because it will erase all the untracked files even if this files is still used in your project
*this list is daily updated.

8-- 'git merge --abort' to revert back from the merging status
Welcome Thread - v9
Tags: welcome
Published: 2018-02-14 20:31:57

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

Hey there! Welcome to dev.to!

![Hello from a cloud](https://media.giphy.com/media/HgycnYQCMeJXO/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. 👋

That's it!
DEV QUERIES: Finding out what makes software developers tick ❤️
Published: 2018-02-14 16:33:39

---
title: DEV QUERIES: Finding out what makes software developers tick ❤️
published: true
description: 
tags: 
---

Alternate title: Software Devs and Engineers: What Do They Know? Do They Know Things? Let's Find Out!

Happy coding ❤️
A Love Poem for my IDE
Tags: valentinesday
Published: 2018-02-14 16:31:50

---
title: A Love Poem for my IDE
published: true
description: 
tags: #valentinesday
cover_image: https://thepracticaldev.s3.amazonaws.com/i/fener9rphtfnief4yjkl.jpg
---
Shall I compare thee to a summer’s day? 
Thou art more lovely and more formulaic:
Horrific bugs do shake the base of all my code,
And sometimes I want to throw my computer away:

Sometimes I doubt your import system,
And often do I curse your name;
And every exception sometime breaks;
By fault of mine, or yours, or nature’s changing course

But thy debugging suite shall not fade,
Nor fail to reveal some abomination
Nor shall vim replace thy charms,
When in eternal lines my gripes are written:
So long as devs can fuck up, or eyes can see,
So long lives my frustrations and these give life to thee

Original Sonnet 18: https://en.wikipedia.org/wiki/Sonnet_18
What happen with echojs.com
Tags: webdev, javascript, discuss
Published: 2018-02-14 14:53:51

---
title: What happen with echojs.com
published: true
description: 
tags: #webdev,#javascript,#discuss
---

Yesterday in the morning as always I went to check [echojs.com](http://echojs.com) ,website which read a lot of what was happening in the javascript environment and I found this

![](https://thepracticaldev.s3.amazonaws.com/i/n448unqev14895gdpjim.png)

Someone knows because the site is not publishing the news as they have always done...??
巨大なGitリポジトリのOculus-VR/UnrealEngineからサンプルだけをダウンロードする
Tags: git, oculus, unrealengine
Published: 2018-02-14 03:55:00

---
title: 巨大なGitリポジトリのOculus-VR/UnrealEngineからサンプルだけをダウンロードする
published: true
tags: Git, Oculus, UnrealEngine
date: 20180214T03:55Z
canonical_url: https://qiita.com/shiena/items/1dda91986bda050e82ef
---
# はじめに

Oculusの開発者センターに[Unreal Samples](https://developer.oculus.com/documentation/unreal/latest/concepts/unreal-samples/)のリンクがあるのですが、Gitリポジトリが巨大でダウンロードに時間がかかるのでサンプルのみダウンロードしてみました。

# sparse checkout と shallow clone

詳細は [巨大なリポジトリ を Git で上手く扱う方法](http://japan.blogs.atlassian.com/2014/05/handle-big-repositories-git/) の解説にあり

* 一部のフォルダのみcheckoutするsparse checkout
* 指定した履歴だけをcloneするshallow clone

この2つを組み合わせます。

# UE4のOculusサンプルのみcloneする

次のコマンドで `/Samples/Oculus/` フォルダのみcloneされます。

```
## 不要なfetchしないために、initとremote add originを組合せる
$ git init UnrealEngine
$ cd UnrealEngine
$ git remote add origin https://github.com/Oculus-VR/UnrealEngine.git


## sparse checkoutで/Samples/Oculus/のみcheckoutする
$ git config core.sparsecheckout true
$ echo /Samples/Oculus/ > .git/info/sparse-checkout


## checkoutしたいbranchが4.18なので同じ名前のbranchを作る
$ git checkout -b 4.18


## shallow cloneで履歴を1つだけにする
$ git pull origin 4.18 --depth 1
```

# 参考にしたリンク

* [Unreal Samples](https://developer.oculus.com/documentation/unreal/latest/concepts/unreal-samples/)
* [Oculus-VR/UnrealEngine](https://github.com/Oculus-VR/UnrealEngine)
* [巨大なリポジトリ を Git で上手く扱う方法](http://japan.blogs.atlassian.com/2014/05/handle-big-repositories-git/)
Setting Up Service Providers in AdonisJS for NodeJS
Tags: node, tutorial, javascript
Published: 2018-02-13 23:02:21

---
title: Setting Up Service Providers in AdonisJS for NodeJS
published: true
description: Continuing from Understanding the IoC Container and Service Providers, we follow the documentation in creating our own service provider for the Bee Queue library.
tags:  node, tutorial, javascript
cover_image: https://thepracticaldev.s3.amazonaws.com/i/y1uks5cc170j9egz9wvl.png
---

> Subscribe to my YouTube channel for [more tutorials on working with VueJS and AdonisJS -- an MVC framework for NodeJS](https://www.youtube.com/channel/UCF5w1QdWroWOoxxXMgp88AQ?sub_confirmation=1)!

Follow along as I setup a Service Provider in AdonisJS as per the example in the [Adonis documentation](http://adonisjs.com/docs/4.0/service-providers#_distributing_as_a_package).

{% youtube w4apTeBa4O0 %}

---

In part 1 and 2 of this series, we took an in-depth look at the IoC Container and Service Providers. If you didn't watch those videos, be sure to watch them first:

* [Understanding the IoC Container](https://dev.to/patrickodacre/a-look-under-the-hood-of-adonisjs-part-1---the-ioc-container--3b0n)
* [Understanding Service Providers](https://dev.to/patrickodacre/a-look-under-the-hood-of-adonisjs-part-2---service-providers--5efj)

**By the end of these videos, you'll have a firm grasp on how the IoC Container and Service Providers do their jobs, and just how helpful they are.**