teleren/devto huggingface dataset:
ประสบการณ์ย้าย Container ข้าม partition
Tags: docker, backup
Published: 2020-06-15 12:03:27

![HDD100%](https://dev-to-uploads.s3.amazonaws.com/i/ft2altapk8jhwwfph75c.png)

บังเอิญ (จริงๆ ก็คิดไว้แล้วว่าต้องมีวันนี้) วันที่ Docker Host ที่วางไว้ใช้สำหรับให้น้องๆ ได้ Dev เกิด Harddisk เต็มแต่ติดปัญหาที่ว่า แต่ละตัวก็ไม่ใช่ Docker ที่จะ Commit แล้วสร้างขึ้นใหม่ได้ (ทั้งข้อมูลก็ไม่ควรที่จะเป็น docker image แต่อย่างใด แต่ก็ลบไม่ได้) สิ่งที่คิดได้อย่างเดียวคือ "ย้าย" มันไปไว้ Harddisk ลูกอื่นซะ

แต่ยังไงหละที่จะไม่ทำให้ข้อมูลหาย หรือย้ายไปแล้วยังสามารถใช้งานได้อยู่ อ่านๆไปอ่านๆ ก็ตกลงปลงใจที่จะใช้ประยุกต์จาก https://github.com/moby/moby/issues/3127 ดังนี้

ขั้นแรก ปิด Docker ก่อนเลย 
```
sudo service docker stop
```

จากนั้นสร้าง Directory ปลายทาง ที่ต้องการซึ่งจะอยู่บน HDD อีกลูก (ในที่นี้สมมุติไปที่  /somewhere/extra) แล้วจัดการย้ายไฟล์ 
```
sudo mkdir -p /somewhere/extra
sudo rsync -av --progress /var/lib/docker/* /somewhere/extra/
```

จากนั้นเพิ่ม parameter ให้ dockerd เพื่อที่จะอ่านค่าที่อยู่ใหม่โดยทำได้ 2 วิธีคือ แก้ไขไฟล์ `/etc/default/docker` โดยเพิ่ม 
```
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -g /mnt/extra/docker"
```
หรือหากใครใช้ไฟล์ `/etc/docker/daemon.json` ก็สามารถแก้ไขไฟล์นี้โดยเพิ่ม
```
{
  ...
  "data-root": "/somewhere/extra",
  ...
}
```

สวดมนต์และภาวนา จากนั้นก็เปิด Docker ได้เลย
```
sudo service docker start
```

หากว่าทุกอย่างกลับมาอย่างปกติ ก็ลบ `/var/lib/docker` ออกได้เลยครับ

ไม่ยาก แต่ลุ้นโคตรๆ

May the force be with you. :)
【Pahud Dev】EP20 - Building and Publishing JSII Construct Library for AWS CDK (4K 2160p)
Tags: jsii, cdk, aws, pahud
Published: 2020-06-15 12:01:39

**【Pahud Dev】EP20 - Building and Publishing JSII Construct Library for AWS CDK (4K 2160p)**
https://youtu.be/wj09u7mpu48
{% youtube wj09u7mpu48 %}
--
JSII是一個支持跨語言binding的工具，它讓你只需用TypeScript開發class，就能讓其他語言例如Python, Java, .NET來調用，它同時也是支撐AWS CDK與CDK8S運作的核心技術。這部影片手把手教你怎麼透過我的github模板生成你的repository讓你只需要很小的修改就能開發，測試與發布你的第一個JSII construct library for AWS CDK，並且同步發布到npmjs與pypi上去，讓所有人都可以輕易npm install或pip install就能使用你的CDK construct library。

0:00 Opening
0:28 What is JSII
2:22 Construct Catalog(@awscdkio)這個Twitter機器人
2:48 來看看別人的作品 - aws-cdk-dynamodb-seeder
4:02 來看看別人的作品 - billing-alert
4:29 野人獻曝一下我的作品 eks-spot-blocks
5:27 working backwards - 先從high level角度開始構思我們的library
7:34 使用 awscdk-jsii-template github模板
8:27 開始用這個模板clone一個自己的項目
9:01 居然沒有package.json？ 沒問題，我們用projen來自動生成
10:44 開始進入lib目錄開發
12:22 撰寫integ來測試
14:32 unit testing如何進行
16:02 準備commit並且bump version
16:44 自動生成了Github Actions workflows
17:46 設定npm與pypi所需要的Secrets
18:28 re-run jobs 成功發布！
18:40 我們寫個README，並且重新bump version再發布一次吧
19:12 release v0.0.2 發布成功
19:17 查看npmjs的網頁確認內容
19:33 查看pypi的網頁確認內容
19:57 讓你的README看起來更專業，加上漂亮的Badges吧！
20:23 透過Cloud9模擬其他開發者怎麼使用你的Library
20:41 npm install我們的library
21:53 驗證AWS CDK in Python的寫法
22:20 pip install我們的library
23:26 回到我們最初設計思路的地方驗證我們的設計
23:45 CDK與傳統IaC最大的區別是什麼
24:19 Closing and wrap-ups
Daily Developer Jokes - Monday, Jun 15, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-06-15 12:00:07

---
title: "Daily Developer Jokes - Monday, Jun 15, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Monday%2C%20Jun%2015%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e12596bcfd66.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ What was Grace Hopper's favorite car?

___A:___ VW Bug
 -->
Android studio Layout Tip 1
Tags: androidstudio, android
Published: 2020-06-15 11:34:24

I was recently asked "When coding layouts for android apps, do you use pure XML or the editor (drag and drop)"

I do both.

A mixture of both results in the highest producivity for me.

I'll often, somewhat haphazardly, drag and drop to get the basics comoponents in the relatively correct spots in the editor. Then, visually wire up the basic constraints, and then in code fine tune the remaining constraints to actually get everything lined up at run time.

One tip for making drag-and-drop go quicker, is to use the filtering capability of Android Studio and the rest of JetBrains IDEs.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/67uqye3j3dkxrmjpgiqz.png)
If you type in the View palette, you'll see that it filters to what ever you type.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hvcl7u9t03m9tqw8f3h3.png)
My Custom Developer Roadmap as a Junior Software Engineer on 2020
Tags: learning, roadmap, codenewbie, webdev
Published: 2020-06-15 11:26:23

Heeya! So I've been wanting to do this sort of 100 days of code ever since the COVID-19 pandemic and raising of quarantine status within the Philippines. **The goal here is to have me coding while following this roadmap.**

This is a personal roadmap I've created that will tackle majority of the things I would want to learn, as well as stuffs that I really have a hard time doing so.

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

1. Flutter (Mobile Development) - I need this one atm since I am having a pending app project for both android and ios.
2. CSS - Oh God. Don't even get me started with this one. I've always hated CSS because I lacked the creativity to combine different styles to create a unique but presentable layout. **What I'm aiming here is to be familiarized with majority of the syntaxes and concepts, as well as to be able to create simple to intermediate layouts**
3. Full Stack Refresher - Just a refresher project that involves NestJS, Express, React, and TypeScript. This project will mostly revolve on a CRUD functionality that utilizes a microservice architecture, and will be hosted maybe through AWS/GCP.
4. Webpack, Babel, and TS config - Knowing what's happening under the hood and how to customize it out.
5. Java Spring + Kafka - Another refresher chapter. I've been a Java guy for majority of the time I spent on my college, and I still prefer it over JavaScript.
6. Angular 9 - With the big 3 JavaScript frontend frameworks, I've already had experience with React and Vue on professional work at my jobs. Been wanting to try out Angular once again and see which really fits my style of coding.

Will I be able to make this commitment and finish this before the year 2020 ends?

Challenge accepted! :)
From Crunching Numbers to Writing Code
Tags: career, beginners
Published: 2020-06-15 11:09:16

Once upon a time in Finance/Accounting. That thrill you have when your financial reports are looking top-notch. That feeling of exhilaration that comes from presenting periodic reports to aid strategic decision making in an organisation.

Some of us never thought deeply about what we wanted to study in University. In my own case, I just took advice from a cousin I admired deeply and decided to enroll in the same course they were in - Accounting. Twenty years later, I reminisce quietly about the rollercoaster ride it has been so far.

Starting my career as an entry-level accounts officer, I soaked up knowledge and advice from mentors, studied for professional exams and kept working my way up the corporate ladder, all the while keeping my dream of becoming a chartered accountant in focus. 

At mid-management level, I noticed how fascinated I had become working with data and databases, and was particularly appalled at the way most organisations I worked with didn't have well-structured data. Sure, they had ERP systems in place, but didn't (want to) use them appropriately. To get financial reports ready one had to resort to manipulating data in Microsoft Excel all day. I thought about really getting into Database Administration and registered for an Oracle Database certification course, but didn't get to follow it through, regrettably.

Last year, 2019 was the defining moment for me, when I finally decided to explore what I was really passionate about. I started with Python and data analytics, then moved on to learning Javascript, Node.js, and MongoDB. Working with backend technologies gives me the satisfactory "goose-bump" thrills.  The methodology of designing a database schema in Mongoose, creating routes to serve up that data to the client, starting up a server and testing those endpoints in Postman. I was excited at finally finding what excites me most about web development.

Everyone has to make a crucial decision at some point in life and in my opinion, switching careers must be one of the toughest of them all, especially for a career-oriented individual, whose life revolves around becoming a well-rounded professional in their chosen field. In my late 30s, that *is* quite a challenge. But finally, at long last, I get to do what I am really passionate about - backend web development.  

*“The most beautiful thing is that despite the shallow life we sometimes succumb to - the soul has no timeline and it knows what it wants and will yearn within until it seeks the journey”.*
Catch unsafe rails db migrations with  strong_migrations gem
Tags: rails
Published: 2020-06-15 10:50:30

###Introduction

In rails we are using migrations for performing database structure/schema modifications.

While doing so, we may end with many unsafe migrations. We shall go for `strong_migrations` gem to make sure we write safe migrations. 

It is also helpful to force the entire team to follow it as a best practice. 

##### Step: 1 Add strong_migrations to `Gemfile`

```ruby
  gem 'strong_migrations'
```
> Note: Do not add the gem under any group. 
```shell
 $ bundle install
 $ rails generate strong_migrations:install 
```

#####Step 2: checking the strong migrations

```shell
$ rails g scaffold User name:string{50} email
$ rake db:migrate
```

###### Adding column with default value
```shell
$ rails g migration add_status_to_users status:integer 
```
update `db/migrate/20200615103121_add_status_to_users.rb`

```ruby
class AddStatusToUsers < ActiveRecord::Migration[6.0]
  def change
    add_column :users, :status, :integer, default: 1
  end
end
```
```shell
$ rake db:migrate
```

When we attempt to migrate the above migration it throws error as follows
```shell
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

=== Dangerous operation detected #strong_migrations ===

Adding a column with a non-null default causes the entire table to be rewritten.
Instead, add the column without a default value, then change the default.

class AddStatusToUsers < ActiveRecord::Migration[6.0]
  def up
    add_column :users, :status, :integer
    change_column_default :users, :status, 1
  end

  def down
    remove_column :users, :status
  end
end

Then backfill the existing rows in the Rails console or a separate migration with disable_ddl_transaction!.

class BackfillAddStatusToUsers < ActiveRecord::Migration[6.0]
  disable_ddl_transaction!

  def up
    User.unscoped.in_batches do |relation|
      relation.update_all status: 1
      sleep(0.01)
    end
  end
end
```

`strong_migrations` not only report the issue, it gives the suggestions as well, which is one of the most important notable feature.
X is out. Is Y dead?
Tags: php, node, javascript, webdev
Published: 2020-06-15 10:50:23

---
title: X is out. Is Y dead?
published: true
description: 
tags: php, node, javascript, webdev
//cover_image: https://direct_url_to_image.jpg
---

No. 😛

____

_This is meant to be a joke, so please don't think I'm making fun of you personally if you've asked this question. I've been guilty of doing this in the past too._
DAY 3 & 4: Conditions, Classes & Instances
Tags: python, beginners
Published: 2020-06-15 10:44:04

Hello there 🙂,
Today  I will catch you up on two challenges that I did as they are short.
The first one was on Conditions which I briefly spoke about on my [previous](https://dev.to/idimaimuna/day-2-operators-21m1) post. The question was testing one's ability to work with conditional operators:
Given an integer,n , perform the following conditional actions:
•	If **n** is odd, print *Weird*
•	If  **n** is even and in the inclusive range of 2  to 5, print *Not Weird*
•	If  **n** is even and in the inclusive range of  6 to 20 , print *Weird*
•	If  **n** is even and greater than 20 , print *Not Weird*

```python
''' This is the function I created and if you call it with different arguments, you will get the various outputs'''

def checknum(N):
    if N%2 == 0  and N in range(2,5):
        print('Not Weird')
    elif N%2 == 0  and N in range(6,20):
        print('Weird')
    elif N%2 == 0  and N> 20:
        print('Not Weird')
    else:
        print('Weird')
```

The next challenge was about [Object Oriented Programming](https://realpython.com/python3-object-oriented-programming/). Classes are a part of Object Oriented programming and an instance can be looked at as an object of the class. I learnt that a class is like a blueprint that can be used to make objects based on its specifications i.e. the attributes/properties and methods.

This task required you to make a class(**Person**) with an instance variable and then also have a constructor that takes a parameter. One was also required to have two instance methods (*yearPasses()*  and *amIOld()*) .
My important take away from this task that is worth noting was that:
•	An instance variable is unique to an object and is declared in the class constructor.
•	A class variable is not unique and shared by all objects of the class.

```python
class Person:
    
    def __init__(self,initialAge):
        self.age = initialAge
        if self.age <0:
            self.age = 0
            print('Age is not valid, setting age to 0')
    
    def amIOld(self):
        if self.age < 13:
            print('You are young')
        elif self.age >= 13 and self.age < 18:
            print('You are a teenager')
        else:
            print('You are old')
            
    def yearPasses(self):
        self.age +=1
```
Making a REST API Using Python - Flask
Tags: python, api, flask, http
Published: 2020-06-15 10:39:15

Hi guys, In this post, we will be building a rest API in python using a microframework called [Flask](https://flask.palletsprojects.com/en/2.0.x/). There are basically two methods to create a Rest API using a flask. If you looking to find out more about Flask do check out my post on [Introduction To Flask](https://www.thegogamicblog.xyz/introduction-to-flask/).

## Method I - Using Only Flask
The first method is to use only flask without any other packages
{% gist https://gist.github.com/raghavmri/d5197334080b06251d2a61ea635ae2b7 
 %}

# Method II - Using Flask API
In this method, we use a package called flask API
{% gist https://gist.github.com/raghavmri/3af0bf9903bb4ef8508546688f3d6a06 
 %}

# Conclusion
- These are a simple way to create API in Python. You could also use [FastAPI](https://fastapi.tiangolo.com/)(A New post on it coming soon!).
- Do Consider [Digital Ocean](https://gogamic.com/ref/do) if you are trying to host your application.
RouteX | API Router for Node (Yes, another one!)
Tags: showdev, javascript, node, sideprojects
Published: 2020-06-15 09:02:00

---
title: RouteX | API Router for Node (Yes, another one!)
published: true
description: A minimal file tree based api router for building rest api's with node.
tags: #showdev #javascript #node #sideproject
---

Ahoy Humans! 

I've not been very active on here for the past months but as we all know, I keep making stuff. Stupid stuff, but stuff.

Covid got me productive and I finally have a well built app out there now.

[TillWhen](https://tillwhen.barelyhuman.dev). 

#### But!

This post isn't about it. The post is about a file tree based router that I built this weekend and is in active development right now.

### Why though?

In one word: Next.js.

I started using Next.js way to much the past year, my website, barelyhuman's website , TillWhen, and a few other simple apps that I built are all on Next.js. I know, I'm the same guy who was ranting about efficient software but trust me the amount of code I would've have written for route management would have been equal to the the static's that are generated by the framework so I went with it.

The framework's file tree based routing is the reason I started using and I stuck with it because of how convenient it was. In fact, TillWhen was built with Next.js both the backend and the frontend so yeah, I like Next.js and I'm using it way too much. 


### Way too much?

Yeah, TillWhen is a monolith that takes up 300-500MB of space which is way too much for something so simple and while the actual app is just about 35-40MB the node_modules take the remaining of the space.

Why? because a lot of pages rendered on TillWhen are server sided and require the node_modules to exist for them to work and we all know how well node_modules grows. The actual backend code and frontend code if compiled will hardly be around 40MB for the backend and under 4MB for the frontend but since I have a monolith with server renders and a huge dependency on node_modules, I have an app that ranges from 300-500MB depending on how many modules I've gotten rid of by now, by implementing my own versions of it. 

Know that this size is mostly the UI Component libraries that are being used in TillWhen. And since I'm not using most of the components it makes no sense to have the whole library installed. 
So I started moving them out after I implemented the few components that I was using from them. 

And, I realised that I could reduce the size if built a compiler for the app that would just take in the required elements and not have the other's exist at all but since that's going to be a time taking process my other approach was to go back to my normal way of building web apps. Frontend and Backend built separately. 

Now, while that is a feasible idea for now, I'd still miss the routing that was provided by it so.....

I built it. 


### RouteX 

I'm not writing anything here about it, just going to link you to it.

[Routex](https://barelyhuman.github.io/routex)
[Source](https://github.com/barelyhuman/routex)
Mapping PORT Values in .env of Frontend & Backend & error: Cannot read property 'error' of undefined (anonymous function) 
Tags: node, react, javascript, webdev
Published: 2020-06-15 10:29:21

A Full stack stands on the port values of Front - Back ends. Linking the port values are crucial I guess in running a smooth software.

You ever got this ⏬⏬ error ⏬⏬ then there is a **SOLUTION FOR THIS BELOW**

🎃 **Unhandled Rejection (TypeError): Cannot read property 'error' of undefined (anonymous function)** 🎃

Here I am going to tell the important part of linking ends in a stack. While making front to back server requests you should make sure the port values and paths of api are specific. Here I prefer MERN stack for now so ya you can assume :

🟡 **FRONT-END : REACT.Js**

🟡 **BACK-END : NODE.Js**

1️⃣: BACK-END Node.Js

🔵 You run nodemon app.js
🔵 You run Backend on port 3000
🔵 Backend is active to fetch all requests on port 3000

Good now you are running Backend on port **3000** 🎃

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4pru3s8kzd1n694wvn96.jpg)

2️⃣: FRONT-END React.JS

🔵 You run npm start on your Frontend React.Js
🔵 Your React says something is already running on port 3000
🔵 So you like to change port to say 3001
🔵 Frontend is active on port **3001**
    
Good now you are running Frontend on port **3001** 🎃

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/y882nm79ugt92ee16ga6.jpg)

3️⃣: Create a .env file in FRONTEND 

🔵 Open .env file
🔵 Specify a url name say REACT_URL
🔵 Declare REACT_URL=http://localhost:3000
🔵 **3000** port is the same value of your backend active port.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/kmc1c8f01l53szir7gc7.jpg)

4️⃣ DONE FINAL STEP
So while making all the GET POST PUT PATCH DELETE. . . requests from backend to frontend make sure the db is connected and ports that your .env uses is correct to make requests on such routes. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7auhkmef7h5mkwh2sehw.jpg)

Happy CODING💻
Danke for reading 🌈
The importance of building a responsive website and targeting the mobile audience
Tags: webdesign, webdev, marketing
Published: 2020-06-15 15:52:08

---
title: The importance of building a responsive website and targeting the mobile audience
published: true
date: 2020-06-15 10:29:01 UTC
tags: webdesign, webdev, marketing
canonical_url: https://www.ma-no.org/en/web-design/the-importance-of-building-a-responsive-website-and-targeting-the-mobile-audience
---

What are the changes reshaping the IT industry? The most significant one is the trend of using tablets, smartphones, and other mobile devices to access internet. This trend is the proof of technological revolution and is affecting greatly the web designers to follow some responsive approach for website creation.Google’s recommendation for creating responsive websites gives more weight to the concept of responsive web designing to be followed by the designers.Here we mentioned few reasons behind need of building a responsive websites and targeting the mobile audience.Why You Need to Prioritize Responsive Design Right Now?With the growing trend of accessing internet… !

Read on [📖!](https://www.ma-no.org/en/web-design/the-importance-of-building-a-responsive-website-and-targeting-the-mobile-audience)
WHAT IS A SUPERCOMPUTER AND HOW DOES IT WORK?
Tags: showdev, information, devops
Published: 2020-06-15 10:26:42

#Walking 
among the rows of
supercomputer cabinets in Argonne National Laboratory’s Leadership Computing Facility, located about 25 miles from Chicago, is kind of like wandering through a high-tech version of “The Shining’s” Overlook Maze — minus the axe-wielding madman. 

The two primary supercomputers in that steel labyrinth, named Mira and Theta, comprise 101 cabinets the size of standard refrigerators that contain stacks of racks and weigh between 3,450 and 4,390 lbs. each. Their combined total: 160 tons — much of that heft due to water-cooling systems that prevent overheating. Along with several other smaller systems, the machines are housed in a 25,000-square-foot data center with low ceilings and a white tile floor. With all of that equipment whirring away, it is not a quiet place. Nearest the computers, visitors must speak-shout in order to be heard above a constant loud hum.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mqafug2nl88q20qao6lo.jpg)

#TOP 10 FASTEST SUPERCOMPUTERS IN THE WORLD-

Summit | U.S.
Sierra | U.S.
Sunway TaihuLight | China
Tianhe-2A | China
Piz Daint | Switzerland
Trinity | U.S.
ABCI | Japan
SuperMUC-NG | Germany
Titan | U.S.
Sequoia | U.S.

WHAT ARE SUPERCOMPUTERS USED FOR?
JUST SIMULATING REALITY, THAT'S ALL?? 

Supercomputers are basically used by corporations and government organizations to simulate outcomes. These blazing fast computers can be used for everything from finding new oil repositories to developing new life-saving medicines. In fact, supercomputers all over the world are being used to assist in research and development of a vaccine for COVID-19.