teleren/devto huggingface dataset:
Reducing Texture Overhead for our PBR Asset Pipeline by 50% using Channel Packing & Emissive Intensity Maps
Tags: gamedev, computergraphics, computerscience
Published: 2020-04-02 18:55:11

Wooden H Studio is currently developing a PBR renderer for our Xbox One Engine Actus Dei. We ran into some issues with needing too many textures for our PBR assets. This is a quick breakdown of how we reduced the number of textures we needed for our PBR renderer.

# Channel Packing
Our initial PBR renderer used 6 textures for PBR, those textures being base color, normal map, metallic, roughness, ambient occlusion & emissive. This was a bit absurd, but it was my first time working with PBR rendering so I wasn't aware of the tools that the artists had for channel packing. After discussing the texture limitations with my Art Lead she told me that it was possible to pack the metal, roughness & AO into a single texture so that took us down to 4 textures, but that was still too much, so I decided to drop emissive support in the engine to keep us down to 3 textures.

# Emissive Intensity Mapping
It didn't stop there though, later in the project, we decided to do a night level for our demo and I (Joseph Whittington - Dev Lead) found it too limiting to ask the artists to avoid using emissive maps for a night level so I looked into ways of reducing the overhead of the emissive maps. After looking at the emissive maps for some of the emissive PBR assets I had for testing purposes, I noticed that the emissive maps were just the diffuse maps with some slight variation in color intensity.

After a quick brainstorming session with my Art Lead, Ashton Ritzel, we created a technique to reduce the data needed for emissive maps into a single channel by storing an intensity value that we map to the base color texture to use as the emissive color in the shader. We coined the technique "Albedo to Emissive Intensity Mapping" because that's pretty much all we're doing here. 

On the art side, the artists need to simply use emissive maps that only use the base color, they can color in the emission the same as they normally would just with black and white, keeping in mind that only the intensity value will be stored. Then when exporting they need to take the greyscale color of the emissive map and pack it into the metal/ roughness/ ao map making it the new metal/ roughness/ ao / emissive intensity map.

On the dev side, we just need to use the alpha channel of the new mixed map to get the intensity of the emissive color and then multiply it by the albedo to get the emissive color then use it as we normally would.

The result is a limited, but basically free emissive map. This was more than enough for what we needed and I'm glad I had a chance to implement it. Although this technique is a bit limiting and needs some specific requirements to be met in order to be implemented, if you meet the requirements you can save a ton of memory by not having an emissive texture and you basically get emissive color for free.

By Joseph Whittington
Quick solution: getting the mouse position on an element regardless of positioning
Tags: mouseposition, dom, javascript
Published: 2020-04-02 18:48:29

---
title: Quick solution: getting the mouse position on an element regardless of positioning
published: true
tags: mouseposition,dom,javascript
---

![Cat with mousepointer on its nose](https://dev-to-uploads.s3.amazonaws.com/i/85kb4qj51jm694h8rnpu.gif)

As I was upgrading an older codebase of mine that used `layerX` and `layerY` (boo, non-standard) I looked into a very succinct way of finding the current mouse position on any element regardless of its position, scrolling, padding, margin and such and I found this to work for me, so maybe it is good for you, too.

```Javascript
const getposition = ev => {
  // get the current mouse position in the browser
  let x = ev.clientX;
  let y = ev.clientY;
  // get the position of the element you applied the handler to
  let pos = ev.target.getBoundingClientRect();
  // subtract the position of the element (rounded up to the next
  // integer) from the mouse position and return it.
  return {
    x: x - pos.x|1,
    y: y - pos.y|1
  };
}
```
For example: 

```xml
<div id="paintarea"></div>
```

```Javascript
document.querySelector('#paintarea').addEventListener(
'mousemove', ev => 
{
  let pos = getposition(ev);
  // pos.x is now the x position in the paintarea
  // pos.y is now the y position in the paintarea
});
```
Here's a [codepen of it in action](https://codepen.io/codepo8/pen/poJBQqL), and you can play with it and give it more annoying things to deal with. 

{% codepen https://codepen.io/codepo8/pen/poJBQqL %}
How to store the online lessons learned by users? 
Tags: database, laravel, php
Published: 2020-04-02 18:41:43

Hi guys, I am currently working at a project, an online website where people can learn programming by advancing through lessons, so I need to know what lessons they have completed. Should I create a table named "completed lessons" with the columns: `lesson_id` and `completed_by_user_id` ? I don't know if this is a good idea, but don't have others.
Google Drive API access via Service Account - Python
Tags: googledrive, python
Published: 2020-04-02 18:31:25

# Intro

I was looking for Google Drive API access with Service Account authentication (ie. server to server communication without frequent user interaction). I always, ended up here https://developers.google.com/drive/api/v3/quickstart/python via search engines. So, I couldn't find suitable doc for Service Account access for Google Drive API.

# How to access

I found a way to mix it with other tutorials.

### Sharing with email
Service account json (credential.json) has an client_email. We should share the resources with this account, then only the Service Account access is possible.

### The mix

I searched for "Google Service Account Getting started python".

```python
# https://developers.google.com/drive/api/v3/quickstart/python
from __future__ import print_function
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request

# https://developers.google.com/analytics/devguides/config/mgmt/v3/quickstart/service-py
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
credentials = ServiceAccountCredentials.from_json_keyfile_name(
            key_file_location, scopes=scopes)

# https://developers.google.com/drive/api/v3/quickstart/python
service = build('drive', 'v3', credentials=credentials)

# Call the Drive v3 API
results = service.files().list(
    pageSize=10, fields="nextPageToken, files(id, name)").execute()
items = results.get('files', [])

if not items:
    print('No files found.')
else:
    print('Files:')
    for item in items:
        print(u'{0} ({1})'.format(item['name'], item['id']))
```

# Conclusion

I was able to figure out Google Drive API. I would like to thank Google for consistent terminology.

# Remarks
This article is not bullet proof. Basically, get credential by following this tutorial https://developers.google.com/analytics/devguides/config/mgmt/v3/quickstart/service-py. Now use that credential to https://developers.google.com/drive/api/v3/quickstart/python.
The new open-source library to access to Arxiv.org API
Tags: kotlin, java, showdev
Published: 2020-04-02 18:25:09

Yo!
Recently, I faced with the task of sending various search requests to [arxiv.org](https://arxiv.org/) API on Java/Kotlin and as result of that, I and my mates had decided to realize it as an open-source library ArxivApiAccess.
## A simple track to use it
For example, if you would like to find the last 20 articles about Java or Kotlin, this can be done as follows code:
``` kotlin
val request: SearchRequest = SearchRequest.SearchRequestBuilder
            .create("Java", SearchField.ALL)
            .or("Kotlin", SearchField.ALL)
            .sortBy(SortBy.LAST_UPTATED_DATE)
            .sortOrder(SortOrder.DESCENDING)
            .maxResults(20)
            .build()

val response: Feed = SearchRequestExecutor().executeAndMap(request)
    
println(response)
```
Also, you can load all articles by your request and save it to file or implement callback function as you want:
``` kotlin
val subjectCategory = "astro-ph"
val fileToSave = "../arxiv_data_sets/${subjectCategory}.csv"

val request = SearchRequest.SearchRequestBuilder
        .create(subjectCategory, SearchField.SUBJECT_CATEGORY)
        .build()

loadAllByRequest(request, { feed ->
    // Donwload to file 
    val writer = FileWriter(fileToSave, true)
    writer.use {
        feed.entry?.forEach {
            val authorString = it.author.joinToString(", ") { author -> author.name }
            val resultString = "${it.updated}|${subjectCategory}|${it.title}|${authorString}".replace("\n", "")
            writer.write("${resultString}\n")
        }
        writer.close()
    }

    println("parsed ${feed.startIndex+feed.itemsPerPage}/${feed.totalResults}")
})
// return false to stop a process of the parsing
true
``` 
Or you can find all articles about Java or Kotlin for last 30 days:
``` kotlin
val request: SearchRequest = SearchRequest.SearchRequestBuilder
        .create("Java", SearchField.ALL)
        .or("Kotlin", SearchField.ALL)
        .build()

var list = searchAllAfterDate(request, Date(System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(30, TimeUnit.DAYS)))

println(list)
```
## Getting started with Maven
``` xml
<repository>
    <id>myMavenRepoRead</id>
    <url>https://mymavenrepo.com/repo/m3NxrnIEacYdXdF77zDL/</url>
</repository>

...

<dependency>
  <groupId>olegthelilfix</groupId>
  <artifactId>ArxivApiAccess</artifactId>
  <version>${ArxivApiAccess.version}</version>
</dependency>
```
The current version is 0.2-RELEASE. More information about the project you can find in the project repository. 
{% github https://github.com/olegthelilfix/ArxivApiAccess no-readme %}
## The future of the project 
The current version of the project is not final and I’m planning to continue the project. The first is to stabilize the current functionality. The second is to enhance the library's ability to interact with [arxiv.org](https://arxiv.org/) API and so on.
Fell free to write me about everything.
Send templated AWS SES emails with Powershell  
Tags: aws, powershell, email, ses
Published: 2020-04-02 18:11:07


There is a lot of documentation and examples for the Amazon Web Services cli tools but there are less examples for the AWS Powershell module. I had the problem that I did not find a working example to send emails via AWS SES and had to find a solution by myself. I hope the following post will save your time.

I assume that you already have the Powershell tools installed and your AWS credentials have been set up.

As I already had the AWS cli installed my credentials were already stored and I just had to install and load the powershell module.

```powershell
Install-Module -Name AWSPowerShell.NetCore
Import-Module AWSPowerShell.NetCore
```

If you need to install it differently or further informatins on how to set up the credentials you should have a look at the offical [AWS Powershell tools documentation](https://docs.aws.amazon.com/powershell/latest/userguide/pstools-welcome.html)

## Creating and storing the template

First I created a json file for the template and saved the contents below as mytemplate.json.

```json
{
  "Template": {
    "TemplateName": "MyTemplate",
    "SubjectPart": "Greetings, TESTSTRING!",
    "HtmlPart": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitiona
l.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /
> <title>Demystifying Email Design</title> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/> </head> <body>
Español üäü {{name}}</body> </html>",
    "TextPart": "Dear TESTSTRING,\r\nYour favorite animal is TESTSTRING."
  }
}
```

To load the template into the SES template store the content of the json needs to be loaded ( Unicode is important! ), converted from json to a object and then piped to the New-SesTemplate CmdLet.

```powershell
Get-Content -Path ./mytemplate.json -Encoding UTF-8 | convertFrom-Json | New-SesTemplate
```

# Sending the mail

After the template has been created you are able to send mails with the content of the template and fill the placeholders in the template with data.

For this you should save the contents below in a file named myemail.json.

```json
{
  "Source":"Mary Major <mary.major@example.com>",
  "Template": "MyTemplate",
  "Destination_ToAddress": [ "test@example.com" ],
  "TemplateData": "{ \"name\":\"Español\", \"favoriteanimal\": \"alligator in IL template\" }"
}
```

The json needs to be adjusted to fulfill your needs. Which means especially the mail adresses should be replaced to align with your SES and domain configuration.

To send the mail you just need to execute the code below.

```powershell
 Get-Content -Path ../myemail.json -Encoding UTF-8 | convertFrom-JSON | Send-SESTemplatedEmail
```

**Congratulations for delivering your email via SES with Powershell! :-)**
Bring in the WhiteNoise, Bring in Da Funk - Building SaaS #34
Tags: python, django, saas, whitenoise
Published: 2020-04-02 18:03:49

{% youtube P1rssIETizc %}

In this episode, we added WhiteNoise to the app as a tool for handling static assets.  This lets us move away from depending on Nginx for the task and gives shiny new features like Brotli support.

We installed WhiteNoise into the `requirements.in` file and used `pip-tools` to generate a new `requirements.txt`.

```text
whitenoise[brotli]==4.1.4
```

Once WhiteNoise was installed, it needed two primary settings changes.

1. Add a new middleware.
2. Change the `STATICFILES_STORAGE`.

```python
MIDDLEWARE = [
    ...
    "whitenoise.middleware.WhiteNoiseMiddleware",
    ...
]

STATICFILES_STORAGE = \
    "whitenoise.storage.CompressedManifestStaticFilesStorage"
```

This was enough to get WhiteNoise working.  We checked the local development server, and the site continued to operate normally.

Unfortunately, the configuration was not enough to make static assets work with the Shiv app.  Since `STATIC_ROOT` used a relative value of `static`, Shiv couldn't find the static files.  This relative pathing was the same problem I faced when getting the templates directory working with the Shiv app.  We used the same solution and switched to:

```python
import conductor

conductor_dir = os.path.dirname(conductor.__file__)
STATIC_ROOT = os.path.join(conductor_dir, "static")
```

Finally, we needed to make the conductor package hold the collected static files.  We could do this by tweaking `MANIFEST.in` with the following addition:

```text
recursive-include conductor/static *
```

On the next stream, we'll make some CI changes and update deployment to discontinue use of Nginx for serving static files.

This article first appeared on [mattlayman.com](https://www.mattlayman.com/building-saas/bring-in-the-whitenoise/).
What are the features of an online food ordering app?
Published: 2020-04-02 17:52:33

---
title: What are the features of an online food ordering app?
published: true
description: In this article, you will learn about the various features of an online food ordering app.
tags: 
---
In this article, you will learn about the various features of an [online food ordering app](https://www.cedextech.com/blog/food-delivery-app-development)

### The key stakeholders of the platform are
• Platform Administrator (You)
• Restaurant Partners
• Delivery Partners
• Customers

### Customers
• Sign up
• Sign in
• Search Restaurants
• Browse Menus
• Add/Remove Cart Items
• Checkout & Online Payments
• Track the Order
• Rate the Order
• Previous Orders
• Address Book
• Push Notifications

### Restaurant Partners
• Manage Menus
• Manage Categories
• Manage Items
• Manage Modifier
• Manage Orders
• Store Settings
• Update Store Hours
• Orders History
• Payments
• Ratings & Review

### Platform Administrator
• Manage Restaurant Partners
• Manage Delivery Partners
• Manage Orders
• Manage Customers
• Manage Reviews & Ratings
• Analytics and Reporting
• Financials
• Dashboard

To learn more about [building food ordering apps](https://www.cedextech.com/blog/build-a-food-ordering-app) visit our website.

### Delivery Partners
Sign In
The delivery partners can sign in using their mobile number and password. The delivery partners have to receive their account information from the Platform Administrator.

Profile
The delivery person can change their mobile number, password, etc.

Orders
The delivery partners receive the orders from the platform, they can either accept or reject the orders. If they accept the order, they are provided with the information on the order, restaurant, and address of the customer. They can see the route to the customer's location on the Google map and has the option to contact the customer/restaurant.

Earnings
The delivery person can see their everyday earnings. 

Settings
The delivery person can change their availability online or offline. Only partners with status online receive orders for delivery.
Data Science Course in San Jose - 360DigiTMG
Tags: datascience, datascienceuses, onlinedatasciencecourse
Published: 2020-04-02 17:47:43

The data is all around us. It’s everywhere. No matter what humans do, at every moment we generate lots and lots of data that can be collected and monitored. The whole existence of humans technologically can be singled into a single piece of data article. So when we say that our population is increasing day by day with more and more people joining the technological bandwagon, we need this data to be managed and arranged in a better way so that we can use it when we want. This power to use the data and process it to get what we actually want comes from this Data Science. Data Science helps us understand the correct behavior and trends of the data around us by using simple tools on them. All of the big companies use Data Science to actually deduce about what actually customers want with the help of Data Science. All the things we do are collected as data and then worked upon to get the results. This is what makes it so interesting and in this tech savvy age, it makes data science kind of necessary for learning and research activities.
What exactly does a Data Scientist do?
A data scientist has many kinds of work. But most importantly, they have the job to create the processed form of data in the way described by their clientele. The data scientist has to actually start by mining the data from different places. Here mining effectively means to collect all the instances of data that have to be used in this particular result. After getting this raw instances of data they now have to plan accordingly on the ways they can convert the data so as to make it easy for their clients to understand. All of this is done with the help of tools and languages that help these expert individuals to do their job. The end product is a data instance that is easy to see and understand and this is what helps people or companies to take a better and educated decision and plan accordingly.
What is in this course?
The industry experts would help you understand the basic concepts of data science with online lectures and study materials.
In this course, there are many statistical tools and advancements to be learned. Most of them are actually used by experts in the industry. Most of the major topics include making decision trees, learning clustering, hypothesis testing, creating perfect data models, understanding linear and logistic regression, making regression models and data visualization as well. R studio, Hadoop, Spark, PROC SQL, SQL Macros et cetera tools and languages help us work with data in a better way. To cap them all, a capstone project is also added at the end to help you judge your learning and implement what you have learnt here. 

Conclusion
Data science is now on a gradual rise. People are slowly getting interested in this subject. 

Resource box
Join the data science course and boost your resume. Find the <a href="https://360digitmg.com/usa/data-science-using-python-and-r-programming-in-sanjose">Data Science Course Certification Program</a> in your place.
Looking to contribute to Open Source Projects
Tags: java, spring, microservices
Published: 2020-04-02 17:46:51

Hi all,

Hope you are doing well.
I am a back-end developer with knowledge of Java & Spring Framework. I also have basic knowledge of containerized applications using micro-service architecture. I am willing to spend some time and contribute to an open source project in Java. If you are looking for a active contributor then please let me know.

Thank you for your time.
Stay home, stay healthy & stay hardworking.
Ruby Roda Web Application Framework Post Request Params
Tags: ruby, roda
Published: 2020-05-30 14:17:29

---
title: Ruby Roda Web Application Framework Post Request Params
published: true
date: 2020-04-02 17:43:00 UTC
tags: ruby,roda
canonical_url: https://www.railsmine.net/2020/04/ruby-roda-post-request-params.html
---

There is difference when accessing the parameters data in Roda aplication between sending request with`Content-Type: application/x-www-form-urlencoded` and `Content-Type: application/json`.

## When Sending POST Request with Content-Type: x-www-form-urlencoded

Use `r.params['your_params']` to read `your_params` parameter value.

### Example Request

```sh
curl -v -X POST --data "foobar=example_value" example.com/foo/bar
```

### Example Roda Route

```ruby
class Example
  route 'foo' do |r|
    r.post 'bar' do
      r.params['foobar'] # => example_value
    end
  end
end
```

## When Sending POST Request with Content-Type: application/json

Use `r.body.read` to read the JSON body parameter and parse it with JSON parser.

### Example Request

```sh
curl -v -X POST -H "Content-Type: application/json" -d '{"foobar":"example_value}' "example.com/foo/bar"
```

### Example Roda Route

```ruby
class Example
  route 'foo' do |r|
    r.post 'bar' do
      params = JSON.parse(r.body.read) # => {"foobar"=>"example_value"}
    end
  end
end
```
PoC-1 Testnet Is Ready | Phala Updates v0.0.7
Published: 2020-04-02 17:39:53

## Mainnet:
- Completed development of PoC-1 testnet (POA & Single Node TEE) which will be launched on March.30th! Candy program will start soon after the testnet launches;
- Configuration parameters of official mining hardware "Sentinel" are settled. 
- Online sale and assembling service will be available next week;
- 3 more motherboards passed our test. Now we have 17 types of motherboards tested in "The Privacy Awakens" program.
- Officially published Phala Token Economics Whitepaper on our website.

## Product: Web3 Analytics
- Completed UI development of user client;
- Completed debugging of API;
- Completed 90% of frontend development.

## Community
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/fcxqcgyhvqzr86z8ry7y.png)

- Rounded off our Twitter airdrop with Math Wallet as 200 KSM sent to all winners! We now have 3,224 followers on Twitter.
- Over 150 participants attended our "Token Economics Whitepaper Quiz Game" in the Chinese community and 73 winners won rewards for their speed and talent at last.
- Uploaded 5 episodes of "Learn Phala's Token Economics in 5 Minutes" videos and claimed over 900 clicks. English version will be uploaded to Youtube as well :)