teleren/devto huggingface dataset:
Odoo 101
Tags: odoo, odoo11
Published: 2020-01-17 02:31:22

สวัสดีครับ วันนี้ผมจะมาพูดถึง Odoo เว็บแอปสำเร็จรูปที่ใช้จัดการส่วนต่างๆ ในบริษัท

ตัวของ Odoo มีโมดูลพื้นฐานมาให้อยู่แล้วเช่น โมดูลการขาย การซื้อ การผลิต สต๊อกสินค้า บัญชี
แต่เราสามารถที่จะดัดแปลงเพิ่มเติมเองได้

เราสามารถสร้างโมดูลเองได้ จากไฟล์ **odoo-bin**
```shell
odoo@odoo ~ $ ./odoo-bin scaffold name destination
```
* name ให้ใส่เป็นชื่อของโมดูลเรา
* destination ให้ใส่เป็นที่ตั้งโฟลเดอร์เรา

<hr/>

หลังจากนั้นถ้าลองเข้าไปดูในโฟล์เดอร์ที่เราสร้างจะพบว่ามีไฟล์และโฟล์เดอร์ประมาณนี้

- __init__.py

กำหนดว่าเราจะเอาไฟล์ python ไหนไปใช้งานจริงบ้าง

- __manifest__.py

กำหนดข้อมูลของแอปเรา
กำหนดว่าเราจะเอาไฟล์ไหนไปใช้งานจริงบ้าง ที่ไม่ใช่ไฟล์ Python

- data/

ข้อมูลที่เราจะใส่เข้าไปในฐานข้อมูลทุกครั้งหลังจากการอัพเดทฐานข้อมูล ข้อมูลในนี้ถูกเก็บในรูปของ xml หรือ csv ก็ได้เพราะฉะนั้น เมื่อมีการเปลี่ยนฐานข้อมูล ข้อมูลเหล่านี้จะไม่หาย

- models/

เก็บไฟล์ Python ที่ไว้กำหนดรูปแบบลักษณะของข้อมูล (class)
ตัว Odoo ไม่อยากให้เราสร้างหรือแก้ไขตารางหรือข้อมูลโดยตรงกับฐานข้อมูลดังนั้น
ทุกครั้งที่เราสร้าง class ไว้ในไฟล์ Python ตัว odoo จะแปลง class นั้นเป็นตารางในฐานข้อมูลให้อัตโนมัติ

นอกจากนั้นไฟล์ Python ในนี้ยังใช้ใส่ Business Logic อีกด้วย

- controllers/

เก็บไฟล์ Python ที่เป็น class เหมือนกับโฟล์เดอร์ model แต่ใช้งานคนละแบบ
ส่วนใหญ่ใช้สำหรับการกำหนด URL

- views/

เก็บรูปแบบการแสดงผลในแบบต่างๆ

- static/

เก็บไฟล์ที่ไว้สำหรับเรียกใช้งานจากที่ไหนก็ได้ เช่น css, js, images


<hr/>

ในตอนแรก เราจะเจาะจงไปที่การสร้าง Model ก่อน
```python
# api -> เป็นเครื่องมือช่วยเชื่อมต่อฟังก์ชั่นที่เราเขียนกับ field
from odoo import api

# fields -> เครื่องมือช่วยสร้าง fields
from odoo import fields

# models -> สิ่งที่เราจะสืบทอดมันมา
from odoo import models
"""
ใน models นั้นจะมีแยกย่อยออกเป็นประเภทต่างๆ การใช้งานก็จะเป็นคนละแบบ
- AbstractModel
จะได้ทุกคุณสมบัติของความเป็น model

- Model
แบบที่เราจะใช้ในครั้งนี้
โมเดลแบบนี้จะเน้นสำหรับ class ที่ต้องการบันทึกข้อมูลลงฐานข้อมูลเก็บไว้

- TransientModel
โมเดลแบบ Pop up ข้อมูลจะถูกลบเองอัตโนมัติ
"""

class SaleOrder(models.Model)
 # ถ้าเป็น model ใหม่ให้ใส่ชื่อ ชื่อนี้จะถูกนำไปเป็น ชื่อตารางในฐานข้อมูล
 # _name = ''

 # หากเราต้องการสืบทอด Class ที่มีอยู่แล้ว ไม่ต้องใส่ _name
 _inherit = 'sale.order'

 # ต่อไปเราจะสร้าง field ให้กรอกข้อมูล
 new_name = fields.Char('New name from inherit')
 state = fields.Selection([
  ['draft', 'Draft'],
  ['confirm', 'Confirmed'],
 ], string='Status')

 # ฟังก์ชั่นในคลาส
 @api.multi
 def confirm(self):
  for rec in self:
   rec.write({'state': 'confirm'})
```
Exercise For Every Programmer
Tags: exercise, lifestyle, wellness
Published: 2020-01-17 02:20:11

A few years ago, I just realized back pain is a common health problem among programmer and office worker.

I am also have faced the same health problem and started to study "working out" and decided for the first time ever in my life to go to the gym.

And after trial and error, I accidentally find out this tremendous exercise among big gym bros, have helped me fight the back pain back.

It is a DEADLIFT.  

Try it out, within a few weeks, your back pain will go away. Use challenging weight and study the exercise on youtube. It will help!
HTML Grid Debugging
Tags: css
Published: 2020-01-17 02:13:51

Assume a grid that sets up three rows .2fr 1fr .2fr for the root page. The three sections are for Header, Main and Footer. 

Each subsequent page alters the main area by injecting its own container of components. Depending on the main area, the footer may get pushed down too far.  How can the footer always bump upward to the main area (regardless of main content)?

To debug this problem, you must start in the main section and find any offenders which make it too tall. Some examples could be images, hard coded heights, margins and or paddings each contributing to more height. As each sub container in main is selected, Chrome displays it height in top part of page. Spotting the offender is now simple to do.

The symptoms of this problem are that any fr unit adjustment (up, down, left or right) does nothing. That symptom is a *huge clue* of  something else is stopping the desired behavior.

With the new Grid support for fr units, maybe it's time to stop hard-coding in heights, widths, and margins. Let the browser layout engine do the work.
HTML 5 Grid for Margins
Published: 2020-01-17 01:58:20

Instead of using margins, you can use the HTML 5 grid. Assume each div with text uses the .text class.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/iiwbnrex3j2d0z4bc33m.PNG)

This markup makes a Grid with one column that takes up 90% of free space. No need for right margins.  It is viewport size agnostic, meaning that it works automatically on any screen size.
Conditionals
Published: 2020-01-17 01:40:44


Why do you think conditionals are important?
Give a set of instructions on how you think a thermostat program should work and “bold/underline” the conditionals.
	Conditionals are important because when making a function or performing a task, different things can happen when different conditions are met. A thermostat program should work by turning on and off when needed. In order for that to happen the thermostat needs to know when it needs to turn on and turn off. The air conditioner should turn on when the temperature gets too warm, and turn off when it gets cool enough to your liking. The heater should turn on when it gets too cold and turn off when it gets as warm as you want it to be.
About Minds.com -My Experience 
Tags: minds, help, opensource
Published: 2020-01-17 01:09:53




 
## What is [Minds.com](https://www.minds.com/register?referrer=MindsGaming) 

[Minds.com](https://www.minds.com/register?referrer=MindsGaming)  is an open sourced social media site that started with the goals of privacy and anonymity for its users. I started using Minds in 2015, the early beta days and have been a contributor to the network in many ways. 



##  Contribution 

I mostly help new users in the support room and log issues into Gitlab or answer questions about how to do things on the network. I also work with other users that do this and keep tabs on new features, the top issues with users on the network, open source standards and things of that nature. Once a month we have a meeting with Minds developers and address these issues with them. Just in case one of them somehow runs into this article the group is called [MCOSI](https://mcosi.org) 

I also built a small community inside the network called [#MindsGaming](https://mindsgaming.glitch.me) that focuses on using groups for community interactions and views based on topics like gaming, music, and art.  And created a user based [Minds Handbook](https://minds-handbook.glitch.me/) for my subscribers.



## Cryptocurrency

Minds offers users erc20 tokens for interactions on your content, you can use these tokens to [“boost”](https://minds.com/boost) content on the network for views, or you can become a [“pro user”](https://minds.com/pro) and get paid in ETH or USD for pageviews on your content. 



## Issues

Other than bugs, something I could go on about for a while the main issue with Minds is traffic and search. The community is very “clicky” so growing takes time and dedication. Over the years I have been on Minds I have grown my channel to  around 35,000 subs and 9 million views, however I still have content that flops (I'm sure is pretty standard in social media). The search protocol is far from user friendly and makes it hard to find relatable content, channels and groups. 


## It could benefit 

I think Minds could really benefit from more technical users that are willing to work with the developers to improve the UX in general. I for one know I would love to see more technical based users that can focus on the user experience from a technical standpoint.

## Links 

[Minds Docs](https://developers.minds.com/)

Join [Minds.com](https://www.minds.com/register?referrer=MindsGaming)

Minds [Gitlab](https://gitlab.com/minds)

Minds [Help & Support Group](https://www.minds.com/groups/profile/100000000000000681/feed)

 [MCOSI](https://mcosi.org)

[The Minds Handbook](https://minds-handbook.glitch.me/)

My Channel [@MindsGaming](https://minds.com/mindsgaming?referrer=MindsGaming)
Got rejected by two different companies today.
Tags: rejection, developer, laravel, php
Published: 2020-01-17 01:09:02

---
title: Got rejected by two different companies today.
published: true
description: Applied and got rejected after final interview.
tags: #rejection #developer #laravel #php
---

I got rejected by two different companies today, that I really wanted to work for. Both were Laravel positions, one company focused on TDD and Vue as a frontend, and the other company used a decoupled React with Laravel as the backend api. 

I made it to the final round of both of these companies, but instead got hit with two rejection emails on the same day! :/ 

I thought I did really well in the technical portions, and both even moved me into the "final round" part of the interview. 

I've been coding for a few years, and transition from Mean stack to a Lamp stack (Laravel) because of the past companies I've been working for, and right now I feel pretty lost on what I'm really good at.

ps. This is my first post lol.

#feelinglikecraptoday
CockroachDB ?? who and how do they come up with these names 
Tags: curious, help
Published: 2020-01-17 00:02:15

---
title: CockroachDB ?? who and how do they come up with these names 
published: true
description: Genuinely curious about the "thought-process" involved in naming libraries and frameworks
tags: curious, help
---

Genuinely curious about the "thought-process" involved in naming libraries and frameworks. What are the sources of inspiration... etc.
Writing Pitfalls
Tags: blog, writing, discuss, watercooler
Published: 2020-02-01 19:05:01

---
title: Writing Pitfalls
published: true
date: 2020-01-17 00:00:00 UTC
tags: BLOG, WRITING, DISCUSS, WATERCOOLER
canonical_url: https://coreydmccarty.dev/posts/2020_01_08_writing_faults/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/5llz6cy6fe1pdcwpibbc.jpg
---

<a href="https://www.freepik.com/free-photos-vectors/business">Cover image from  created by pikisuperstar - www.freepik.com</a>

I've been working since New Year's trying to write something daily without completing it. As I write ideas come to mind and I'll open a new file to hold the new thought however short it may be. The continuing echo of 'write more' has permeated dev.to recently, so I'm surely not the only one.

I just want to discuss bad habits, and maybe we can help one another to be more aware of what we may be doing, similar to saying 'umm' too much when you talk.

1. I have found that I use the word 'to' constantly; so much so, that I currently have VSCode set to highlight ' to ' and I'm refactoring as many of them away as I can.

2. My spacing after periods is terribly inconsistent. I learned in school that there should be two, but in recent years I have succumbed to the one that my phone prefers. As a result, I find myself replacing every time I used two space to be one, just for consistency.

3. I also find that I tend towards writing very long sentences. I make sure that they are grammatically correct and not just run-ons, but long clauses strung together can lend itself to be more difficult to follow.
Difference between Fault, Error, and Failure explained with JavaScript
Tags: javascript, testing, programming
Published: 2021-02-28 12:25:52

---
title: Difference between Fault, Error, and Failure explained with JavaScript
published: true
date: 2020-01-17 00:00:00 UTC
tags: javascript,testing, programming
canonical_url: https://mannes.tech/difference-fault-error-failure-javascript/
---

You've heard of the terms fault, error, and failure.

And as software developers, we use them every day. But what do they mean?

One popular definition is this (_see_ [_“Fundamental Concepts of Dependability”, Avižienis et al._](https://pld.ttu.ee/IAF0530/16/avi1.pdf)):

* **Fault** is the cause of an error
* **Error** is the incorrect state of the system that may cause a subsequent failure
* **Failure** is when the system does not deliver the expected result

To better understand this definition, let's look at a concrete example.

Imagine a JS function that calls an external API to get search results.

```javascript
const result = JSON.parse(response.payload)
```

Let's assume the response object is always present.

But when there is no payload property, a `SyntaxError` when running that code:

* The fault is that response.payload is not checked to be a JSON-parsable type
* The error that appears is a `SyntaxError`, because we try to call `JSON.parse(undefined)`
* A failure will now appear if the error is not caught and either the app stops working, or the user gets no results and no error message

This example is a bit trickier than we see at first glance:

* There will be no failure if the error is caught using `try` and `catch` and handled appropriately
* If the error is caught, you can't really speak of a fault, because the program works as expected
* But even without fault and failure, the error will still exist for a brief moment, before being caught

Now the big question, where does a **bug** fit into this?

The bug can be the fault or the failure, depending on context.

* Bug as fault: “this code has a bug, it will throw an error when the list has no items. Better add an `if` to handle this case.”
* Bug as failure: “the software has a bug when I click ‘delete’ with no items on the list.”

So a bug can actually be two things!
Who would've thought 🤓

***

🙏 [_Follow me on Twitter @simon_mannes_](https://twitter.com/@simon_mannes)
Login to your Storage Accounts using Azure Active Directory
Tags: azure
Published: 2020-02-25 14:51:06

---
title: Login to your Storage Accounts using Azure Active Directory
published: true
date: 2020-01-17 00:00:00 UTC
tags: azure
canonical_url: 
---

Previously, I wrote an article talking about how to use KeyVault to generate SAS Keys: [https://woivre.com/blog/2020/01/generate-storage-accounts-sas-keys-using-keyvault](https://dev.to/wilfriedwoivre/generate-storage-accounts-sas-keys-using-keyvault-134h)

In the same philosophy as the latter, it is possible to completely avoid using the Storage keys in your configs or your source code, even if I hope that it is already the case.

Some services on Azure support RBAC roles, such as storage accounts, which contain Reader or Contributor rights on Blob and queues.

Thanks to this it is possible for a specific AD account to connect to my Azure Storage to get a file for example.

The names of the build-in roles that exist for the storage accounts are:

- Storage Blob Data Contributor (Preview)
- Storage Blob Data Reader (Preview)
- Storage Queue Data Contributor (Preview)
- Storage Queue Data Reader (Preview)

It is possible to configure these different permissions using the DataAction property in the definition of your RBAC roles.

Until now, the C # SDK for Storage does not support this new functionality it must be done via the Azure REST APIs, as below:

```
AuthenticationContext authContext = new AuthenticationContext($"https://login.microsoftonline.com/{TenantId}");
AuthenticationResult authResult = await authContext.AcquireTokenAsync($"https://{StorageAccountName}.blob.core.windows.net/", new ClientCredential(ApplicationId, SecretKey));
	
HttpClient client = new HttpClient(); 
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + authResult.AccessToken);
client.DefaultRequestHeaders.Add("x-ms-version", "2017-11-09");

var response = await client.GetStringAsync($"https://{StorageAccountName}.blob.core.windows.net/{ContainerName}/{BlobName}");	

```

I generate a token thanks to ADAL and that I ask for it for my storage account.

With this article, you have even fewer excuses to keep your storage keys in your configs.
How to Get Data Attribute Value In Jquery
Published: 2020-01-17 11:32:52

---
title: How to Get Data Attribute Value In Jquery
published: true
date: 2020-01-17 00:00:00 UTC
tags: 
canonical_url: 
---

Hi GuysIn this examplei will learn you how to get attribute value in jqueryyou can easy and simply get the attribute value in jqueryGet the value of an attribute for the first element in the set of matched elements or set one or more attributes for every matched elementIn following exampl
Django: Query ImageField by height or width
Tags: django, python
Published: 2020-01-16 23:20:14

Django has a built in `ImageField` - it is great & makes dealing with images very easy. However, out of the box, you can't query the database for images of a certain dimension (width or height). For example, you can't find all the large images you are storing.

The solution is hiding in plain sight in the [Django docs](https://docs.djangoproject.com/en/3.0/ref/models/fields/#django.db.models.ImageField "Django docs").

An `ImageField` accepts two arguments: `height_field` and `width_field`. Using these are pretty easy:

```python
from django.db import models


class Person(models.Model):
    avatar = models.ImageField(
        blank=True,
        null=True,
        height_field="avatar_height",
        width_field="avatar_width",
    )
    avatar_height = models.IntegerField(blank=True, null=True)
    avatar_width = models.IntegerField(blank=True, null=True)
```

Every time we save an image to the `avatar` field, Django will automatically update the `avatar_heigh` and `avatar_width` fields with the new image dimensions.

This means we now have an entry in the database that we can query! If we wanted to find all the images with at least one large dimension, we can do something like:

```python
from django.db.models import Q


big_dim = 500;
big_images = Person.objects.filter(
    Q(avatar_height__gt=big_dim) | Q(avatar_width__gt=big_dim)
    )
```

Couple of final notes:

1. The fields are only updated on "save", so if you are adding this to an existing model, you may want to loop through each instance & call `save()` so that the fields are populated
2. Normal usage of `person.avatar.height` would load the whole image into memory in order to figure out how big it is. This can be slow if you are using a remote storage such as [S3](https://aws.amazon.com/s3/) or [Digital Ocean Spaces](https://m.do.co/c/4afdc8b5be2e). But using `person.avatar_height` skips all that. This can lead to a big performance increase if you need to know the size of your images but don't need to operate on the image itself.
🚇 London Tube live status from your terminal 🇬🇧
Tags: showdev, bash, london, opensource
Published: 2020-01-16 23:07:52

I've created a few months ago a really small bash script (with `jq`) to get the live status of the London tube using the TFL Api.

Since then I've also built a new habit to run a quick `tubestatus` in my terminal before leaving my desk, helping me to avoid a lot of bad surprises 😄!

Thought I'd share it with you as I'm sure there are some Londoners over here!

repo: https://github.com/smallwat3r/tubestatus
Day 71 : Guidelines
Tags: hiphop, code, coding, lifelongdev
Published: 2020-01-16 23:03:25

_liner notes_:
- Professional : Had a lot of stuff on my plate today. A couple of meetings and took a look at some code for a coworker's project using Firebase. Also, began the process to book the hotel room for my next conference in Miami. For the rest of the time, just continued to work on the report I've been putting together. Got all the formatting and guidelines done. Just have to fill in all the spots with the different sources I've been researching. Hoping to have it all done by tonight. 

- Personal : Went through some tracks for the radio show this week. There's a lot of music coming out early in the year. I don't think I've ever seen it like this in previous years.

![a field in Seiser Alm, Italy with mountains in the distance](https://thepracticaldev.s3.amazonaws.com/i/l3u8edtmcipz59rbmcyv.png)


Going to keep working on the report and this week's radio show. Pretty much it.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube QOFQDy2NNmc %}
Destructuring Functions in javascript Es6
Tags: javascript, function, es6, destructuring
Published: 2020-01-16 22:53:30

// Example 1
// const getStudentInfos = () => ({
//   name: "John Doe",
//   age: 22,
// })
```javascript
const getStudentInfos = () => {
  const studentInfos = {
    name: "John Doe",
    age: 22
  };

  return studentInfos;
};
const student = getStudentInfos();
console.log(student);

// Example 2
const getStudentInfos1 = () => ({
  name: "John Doe",
  age: 22
});
const { name, age } = getStudentInfos1();
console.log(name, age);

// Example 3
const getFullName2 = (firstName = "John", lastName = "Doe") => {
  return `${firstName} ${lastName}`;
};
const person = getFullName2();
const person2 = getFullName2("Maria", "Brewer");
console.log(person, person2);

// Example 4
const getFullName3 = ({ firstName = "John", lastName = "Doe" }) => {
  return `${firstName} ${lastName}`;
};
const person3 = getFullName3({
  firstName: "Maria",
  lastName: "Brewer"
});
console.log(person3);

// Example 5
const { firstName = "John", lastName = "Doe" } = {
  firstName: "Maria",
  lastName: "Brewer"
};
console.log(firstName, lastName);
```

*****Realiser par : Arbaoui Mahedi *****
Types of functions
Published: 2020-01-16 22:50:15

What processes and tasks, from real life, can fit into the various ways you can define a function?
You can make functions for any process or task in real life, you just need to know the different ways to define a function and how to apply that to the task. An example can be cleaning a house. You can break up all the different parts of cleaning the house into different functions. Some tasks can be done at any time or in any order, like putting things where they go, or dusting the furniture. Some tasks cannot be done until other tasks have been done, such as mopping the floor after you sweep and not before. You also have tasks that need be done only when it happens, such as unclogging a toilet. You can make a function for unclogging the toilet. In a normal house cleaning you wouldn’t need to unclog the toilet all the time. Why would you perform the task of unclogging a toilet if the toilet is not clogged, that makes no sense. You would only perform the task (call the function) if the toilet was clogged and therefore needs unclogging. Other tasks can only be done as a result of another task such as using a dish washer. To use a dish washer, you first need to load it, then run it, and as a result you put away clean dishes. You wouldn’t perform the task of putting away clean dishes if they have not been first loaded into the dishwasher and then washed. You cannot run the dish washer unless its first loaded, and you cannot load it unless you have emptied it first. All these are different ways to define a function.
Minesweeper clone in Haskell for console
Tags: haskell, career, help
Published: 2020-01-16 22:42:31

One of the well-known HR companies has recommendation to build Minesweeper clone to prepare to their technical interview. I decided it's good idea not just to be prepared (actually, it didn't help me) but because I miss Minesweeper on my MacBook. And its classic interface is not suitable for OSX.
So I implemented it in Haskell.
Enjoy!
https://github.com/DKurilo/minesweeper
If you have any suggestion or ideas, feel free to write me.
I  wanted to try Brick library:
https://hackage.haskell.org/package/brick
and this app was a great chance to do it.
So I found it's very easy to build console app with Brick. I used this great tutorial:
https://github.com/jtdaugherty/brick/blob/master/docs/samtay-tutorial.md
It took only two days to understand Brick and write Minesweeper clone.

I'm looking for a job now. In case you need good enough developer, here is my resume (you can also other my projects :) ):
https://github.com/DKurilo/dima-kurilo-resume/blob/master/Dima-Kurilo-resume.pdf