teleren/devto huggingface dataset:
My Shell Workflow: Executing a command in lots of directories. 
Tags: shell, bash, zsh, productivity
Published: 2018-01-03 14:52:07

---
title: "My Shell Workflow: Executing a command in lots of directories. "
published: true
description: A simple for-loop trick to run a command in lots of directories defined by a path. 
tags: shell, bash, zsh, productivity
---

## Problem 

You want to run a shell command in many directories. For example, in my case, I wanted to execute a shell command in lots of directories(approx. 200)  to clean up build files. 

## Solution 

Writing a for-loop and running it on the shell did the trick for me.

```
for d in ./*/ ; do (cd "$d" && mvn clean); done
```

## Explanation

The above for-loop would run `cd "$d" && mvn clean` in each item of the directory list defined by the path `./*/`. `$d` holds the directory name. You can be creative in defining the list of directories using a complex glob as well. 

I hope this helps you as well.
Grid cell issue with white-space: nowrap & text-overflow: ellipsis
Tags: help, css, grid
Published: 2018-01-03 13:51:50

---
title: "Grid cell issue with white-space: nowrap & text-overflow: ellipsis"
published: true
description: "Grid cell issue with white-space: nowrap & text-overflow: ellipsis"
tags: help, css, grid
---

**N.B.**: I **solved** with `min-width: 0` applied on each `.grid__item`, like in flexbox world.

Anyone can help me with this css grid stuff?

{% codepen https://codepen.io/timhecker/pen/YYNoMw %}

I have a complicated HTML structure:

```html
<div class="grid">
  <div class="grid__item">
    <div>
        <a href="#">
            <div class="grid__detail">
              <h2>Lorem ipsum, dolor sit amet consectetur adipisicing elit.....very long title</h2>
            </div>
        </a>
    </div>
  </div>
  [...]
</div>
```

And I'm using CSS grids:

```css
.grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	grid-gap: 2rem;
}
```

I need a `box-shadow` on a inner `div`:

```css
.grid__item div {
    box-shadow: 0 0 10px red;
}
```

with a long text title, I need the `text-overflow` prop to truncate it:

```css
.grid__item h2 {
	text-overflow: ellipsis;
	overflow: hidden;
	white-space: nowrap;
	max-width: 100%;
}
```

For some weird reasons the cells grow up, until to contain the whole text, and so, my grid breaks down. `overflow: hidden` on my grid cell solves the issue, but I can't use box-shadows on the inner `div`.

```css
.grid__item {
	// overflow: hidden; // this fixes the problem, but say goodbye to the inner box-shadow
        min-width: 0; // this fixes the problem with truncate text
}
```

Any ideas? :(
RAM model, Big O what's that?
Tags: beginners, computerscience, help
Published: 2018-01-03 13:18:32

---
title: RAM model, Big O what's that?
published: true
description: what is big O, RAM model??
tags: #beginner #computerscience #help
---
Here a question I don't understand. Can anybody help with that?

## Use RAM model to estimate the big-oh of the running time for the following code segment.

```

for(i = 1; i < n; i++){
   small_pos = i;
   smallest = Array[samll_pos];
   for(j = i + 1; J <= n; j++){
     if(Array[j] < smallest){
       small_pos = j;
       smallest = Array[small_pos]
     }
   }
}
Array[small_pos] = Array[i];
Array[i] = smallest;
```
Golang Test Coverage
Tags: go, test, coverage
Published: 2020-02-17 07:04:27

---
title: Golang Test Coverage
published: true
date: 2018-01-03 13:10:36 UTC
tags: go, test, coverage
canonical_url: https://lumochift.org/posts/golang-test-coverage/
---

Tulisan ini adalah lanjutan dari [Golang Unit Test](https://dev.to/h4ckm03d/golang-unit-test-3fmh-temp-slug-2651667). Kali ini membahas tentang _test coverage_, yaitu untuk mengetahui apakah unit test sudah memenuhi semua jalur logika dari sistem yang kita uji. Contoh sederhana sebagai berikut:

1. 

Suatu fungsi untuk menentukan nilai maksimal dari dua integer input.

2. 

Input didefinisikan dalam variabel `a` dan `b`.

3. 

Jika `a` lebih besar atau sama dengan `b` maka return `a`, sebaliknya jika `b` lebih besar maka return `b`.

Sample code sebagai berikut:

```
package main

func Max(a, b int) int {
	if a >= b {
		return a
	}

	return b
}

```

Kemudian _unit test_ sebagai berikut:

```
package main

import "testing"

func TestMax(t *testing.T) {
	if Max(1, 3) != 3 {
		t.Error("error, seharusnya 3")
	}

    // Jika pengecekan dibawah ini dihilangkan maka test coverage jadi 66.67%
	if Max(4, 3) != 4 {
		t.Error("error, seharusnya 4")
	}
}

```

Jika _test coverage_ dijalankan menggunakan perintah `go test --cover` di cli maka hasilnya sebagai berikut:

```
$ go test --cover
PASS
coverage: 100.0% of statements
ok github.com/h4ckm03d/blog-codes/test-coverage 0.002s

```

Coba kita review _unit testing_ diatas.

1. 

Fungsi Max mempunya 2 cabang logika dan terdiri dari 3 statement `if a >= b`, `return a`, dan `return b`.

2. 

`Max(1, 3)` ini menghasilkan nilai 3, jika dirunut dari fungsi Max akan melewati 2 statement `if a >= b` dan karena kondisi tidak terpenuh maka langsung ke `return b`. Jadi hanya tercover 2 statement sehingga test coverage jika pengecekan `Max(4,3)` dihilangkan maka hasilnya **66.67%**.

3. 

Karena pemanggilan fungsi `Max(4,3)` menghasilkan jalur yang berbeda dengan proses pada no.2 yaitu `if a >= b` dan `return a`. Maka semua cabang logika dilewati, karena itulah hasil _test coverage_ keseluruhan jadi **100%**.

Semoga yang sedikit ini bisa membantu pemahaman tentang _test coverage_ menggunakan golang. Sampai jumpa lagi di tulisan selanjutnya.
How to make an Expandable Recyclerview list and Firebase database-Part 1  
Tags: beginners, android, firebase, tutorial
Published: 2018-01-03 11:14:47

---
title: "How to make an Expandable Recyclerview list and Firebase database-Part 1  "
published: true
description: 
tags: #beginners #android #firebase #tutorial
cover_image: https://thepracticaldev.s3.amazonaws.com/i/9dijqmk79vts20h1thz8.jpg 

---
This is a step-by-step guide for how to create Recycleview expandable list on android studio and to create firebase project using realtime database.


Let’s start with [Firebase](https://firebase.google.com).



##Step 1  
###Create new project in Firebase 

Click on Get Started than add project. A small window will appear; put your project's name then click create project. In  the next page, choose your project's  app: ios , android or web. In this example, android app is selected.

In order to continue to the next step, a new project on android studio should be created. Fill in the box with the name of package android studio created.

Next, download the json file and follow the instructions.

finally, add the firebase SDK in android studio.



##Step 2
###Config Rules of Database

Go to the database, choose Realtime database then open rules page.  
 
Two rules will appear : read and write. If you want to read data, you need to change the value of read to true as illustrated below:

![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/s64wev1uoqevqnkd1mah.png)  

Note : if you want to add data with your application you need to change the value of write to true

##Step 3
###Creating Data

When you move to the page "Data" you will find a node which contains a reference to your database .
 

![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/4a99u3jzsqm0aqvlek8f.png)  

In order to add a new child, press on the box "+". a new row will appear with two empty text boxes; one for the name and the other for the value. To add a new child, you need to fill in only the name's box and leave the value's box empty then press "+". 
Note: in case of filling in the two boxes (name and value), the "+" box will disappear.

![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/wfh9rvc10u8zgwda82nw.png) 

Now,  fill in the both boxes .

 ![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/133rjwyxmwtv87k1f06c.png)

Repeat the previous steps until you make a similar database:

 ![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/celrw2u2btxgms6e88u9.png)

Once done ,move to the next [part](https://dev.to/hbodkr/how-to-make-a-expandable-recyclerview-list-and-firebase-database---part-2-3nco) .
Diesel 1.0 is out!
Tags: rust, news
Published: 2018-01-03 11:12:02

---
title: Diesel 1.0 is out!
published: true
description: Diesel 1.0 is out
tags: rust, news
---

Diesel is an ORM and Query Builder for Rust.

>1.0.0 marks stability for Diesel. While there are many more features
that will be added in the future, there will be no breaking changes from
this point forward without a major version bump (which we do not
anticipate happening for many years).
Do you have any technical books to recommend ?
Tags: books, programming
Published: 2018-01-03 11:05:01

---
title: Do you have any technical books to recommend ?
published: true
description: 
tags: books, programming
---

Hello Dev community !

In 2018 I would like to read more books but also more technical books ! 

(by more I mean at least one, I didn't read any tech book in 2017, shame on me...)


![shame gif](https://media3.giphy.com/media/hURsrHYlao1Ko/200.gif)


So I would like to collect your recommandations, I do some front and backend stuff (JS and PHP), but I think more basic and general book would be more suitable.

Anyway, I'm open to any suggestions, 

I wish you all my best wishes for this new year and much success for your projects !

![happy new year gif](https://media0.giphy.com/media/3ohc15YI9ZJH7q4OCA/giphy.gif)
New Enterprise Edition in Updated dbForge Studio for MySQL 7.3
Tags: development, databasetools, mysql, software
Published: 2018-01-03 10:34:10

---
title: New Enterprise Edition in Updated dbForge Studio for MySQL 7.3
published: yes
description: Devart has updated dbForge Studio for MySQL with the Enterprise edition that along with all features of the Professional edition, features brand new exclusive functionality, including Copy Databases, Data Generator, and Database Documenter, and much more.
tags: development, database tools, MySQL, software
---

Devart, a Czech software vendor of database tools and data connectivity solutions, has released dbForge Studio for MySQL v7.3, a new version of MySQL and MariaDB GUI tool. Alongside with the new Enterprise Edition, dbForge Studio for MySQL has been updated with improved features of Data Import/Export, Data Comparison, Database Backup and Data Export, SQL Document as well as introduced new connectivity possibilities, trial product activation, and much more.

 The new Enterprise edition of the tool provides users with the following exclusive features:

* Data Generator allows generating test data and instantly populating the database with it.
* Database Documenter is a tool for generation of database documentation in HTML, PDF, and Markdown file formats.
* With Copy Database, users can copy a set of databases by generating and running a script.


     New connectivity possibilities

* Support for MariaDB 10.1, MariaDB 10.2, MariaDB Galera Cluster 10.0 Series, Google Cloud Platform, Alibaba Cloud, Azure MySQL.
* Display of server version when testing a connection
  
     Support for New Table Engines

Support for TokuDB, NDBCLUSTER, RocksDB


dbForge Studio for MySQL is a universal MySQL and MariaDB client for database management, administration, and development. With the help of this intelligent MySQL client, working with data and code becomes easier and more convenient.

For more information about dbForge Studio for MySQL v.7.3, please visit https://www.devart.com/dbforge/mysql/studio/.

About Devart

Devart is one of the leading developers of database tools and administration software, ALM solutions, data providers for various database servers, data integration and backup solutions. The company also implements Web and Mobile development projects.

For additional information about Devart, visit https://www.devart.com/.
Where do you deploy your apps?
Tags: discuss, deployment
Published: 2018-01-03 05:01:39

---
title: Where do you deploy your apps?
published: true
description: 
tags: discuss, deployment
---
I am realizing that I'm probably outgrowing my current Heroku setup for a lot of my personal projects. I would like to find another place to host my projects. I am pretty happy hosting my static sites on Github pages, but could be convinced to move those over as well!

Wants:
* Ability to deploy multiple languages. Right now I have apps in Express (Node), Django (Python), Rails (Express), and Gorilla Mux (Go). I would like somewhere where it is relatively easy to deploy all of these! I use Postgres 99% of the time, but I have one app using Mongo right now (hosted on MLab).
* I would love to have the ability to run TMUX sessions and CRON jobs.
* More speed.
* I don't get a lot of traffic on these sites, they are just personal projects! They normally get a few hundred hits per day on the first few days then taper off pretty quickly.
* Right now, I have five personal projects that need hosting, though this will rapidly increase with my Learning New Things project!
* As inexpensive as possible!

At work-places, I've used Digital Ocean and company-owned Linux servers to deploy sites, so I could be convinced to use a closer to the metal solution!

So, where do you host your sites? Do you like the platform you are using? How was the learning curve to start to use that platform? Do you use any containerization to help? How about continuous integration?
Deploy Hugo from Gitlab CI to Github Pages
Tags: hugo, github, gitlab
Published: 2018-01-03 03:16:41

---
title: Deploy Hugo from Gitlab CI to Github Pages
published: true
description: My new blogging workflow, from Gitlab CI to Github Pages
tags: hugo, Github, Gitlab
---

I have Hugo blog, hosted on Github Pages and using Travis CI to deploy it.
But at new year, Travis CI take long time to queue my build.

![Travis CI](https://thepracticaldev.s3.amazonaws.com/i/lsvpjhapht0obw8a6bmo.png)

_Travis CI Status: [Container-based Linux over capacity](https://www.traviscistatus.com/incidents/631nlzm77xq2)_

As alternatif, I use Gitlab CI and mirroring [my blog repository](https://github.com/ardianta/blog) from Github to Gitlab.

Here my `.gitlab-ci.yml` script:

```yaml
image: andthensome/alpine-hugo-git-bash:0.31.2

before_script:
  - hugo version

github_pages:
  script:
  - rm -rf public
  - git clone --depth 1 https://<username>:$GITHUB_ACCESS_TOKEN@github.com/<username>/<username>.github.io.git public
  - hugo --config config.production.toml
  - cd public
  - git config user.email "<your git email>"
  - git config --global user.name "<your git name>"
  - git add -A
  - git commit -m "Build from $CI_SERVER_NAME $CI_PIPELINE_ID"
  - git push
  artifacts:
    paths:
    - public
  only:
  - master
```

We need to create environment variable `GITHUB_ACCESS_TOKEN` at Gitlab. Just go to __Settings->CI/DI->Secret Variables__.

![Creating Secret Variable](https://ardianta.github.io/img/gitlab-github/token-github.png)

You can get your Github Personal Token at https://github.com/settings/tokens.

And then...

Lets try to build it by commiting some changes to master branch on Gitlab.

![Build Hugo from Gitlab CI](https://ardianta.github.io/img/gitlab-github/build-ci-gitlab.png)

Awesome!

Now my blog is deployed from Gitlab CI to Github Pages, hare what look like on Github Pages repository.

![Github Pages Repository](https://ardianta.github.io/img/gitlab-github/github-pages.png)

_(you also can read [Indonesian version on my blog](https://ardianta.github.io/blog/gitlab-github-pages/))_
Create a VueJS Currency Filter
Tags: vue, components, webdev, tutorial
Published: 2020-03-16 01:09:28

---
title: Create a VueJS Currency Filter
published: true
tags: vuejs, components, webdev, tutorial
canonical_url: https://williamhuster.com/vuejs-currency-filter/
---

Displaying formatted currency amounts is a common requirement of web apps, but VueJS does not provide any filters out of the box. So here’s what you can do if you need to add a currency filter to your Vue project.

First, you'll need to know about VueJS filters and how they work. Read more here: https://vuejs.org/v2/guide/filters.html

## Using the currency-formatter NPM Package

If you are using webpack or a similar build tool and have access to node.js packages, then you can install the currency-formatter package from npm. By the way, I highly recommend using the [Vue CLI](https://cli.vuejs.org/) for your projects.

```bash
npm install currency-formatter --save
```

Then you can create a VueJS filter in your app code like so:

```javascript
import Vue from 'vue'
import currencyFormatter from 'currency-formatter'

Vue.filter('currency', formatNumberAsUSD)

function formatNumberAsUSD (value) {
  if (!value) return ''
  value = Number(value)
  return currencyFormatter.format(value, { code: 'USD' })
}
```

`Vue.filter` registers a new global Vue filter called 'currency' and `formatNumberAsUSD` function does the work. The formatting function does three things, it (a) makes sure it has a truthy value and returns a blank string if not, (b) attempts to convert the value to a `Number`, and (c) uses `currencyFormatter.format` to format the number as USD.

## Using Number.prototype.toLocaleString()

If you are not using a build tool with access to node.js packages, or you mistrust external dependencies, you might try using the Number.toLocalString() method below or [take a peek at currency-formatter source code on Github](https://github.com/smirzaei/currency-formatter/blob/master/index.js) and borrow from it. Note that while this is supported in modern browsers, it may not be available in older browsers you might need to target.

```javascript
import Vue from 'vue'
import currencyFormatter from 'currency-formatter'

Vue.filter('currency', formatNumberAsUSD)

function formatNumberAsUSD (value) {
  if (!value) return ''
  return Number(value).toLocaleString('en', {
    style: 'currency', currency: 'USD'
  })
}
```

Both `toLocaleString` and the currency-formatter package can handle currencies besides USD, too. [Check out the currency-formatter npm page](https://www.npmjs.com/package/currency-formatter) for more details.

## Summary

No matter the approach you chose, you have now created a 'currency' filter that you can use in your VueJS templates like this:

```vue
<template>
  <span>{{ 12 | currency }}</span>
</template>
```

And the output should look like this:

```text
$12.00
```

Excellent!
[Solved] How can I publish a post in my drafts?
Published: 2018-01-03 02:24:39

---
title: "[Solved] How can I publish a post in my drafts?"
published: true
tags: 
---

## Problem

Currently, when I look at my dashboard, I see several drafts that I've imported via RSS.

I have "DRAFT", "EDIT", and "DELETE" buttons. Under each post

However, none of those buttons appears to give me the ability to actually publish a post. And unlike authoring this post, when I click "SAVE POST", it appears to revert back to the unpublished post, rather than publishing it.

Anyone know how I can actually get some of these out into the wild?

## Solution

The post has a `published: false` piece in the frontmatter. Change it to `true`.
Explain This Like I'm Five
Tags: explainlikeimfive, javascript, freecodecamp
Published: 2018-01-03 01:00:03

---
title: Explain This Like I'm Five
published: true
tags: explainlikeimfive, javascript, freecodecamp
---

So, I've been doing freeCodeCamp for a while, and I need an explanation for the following:

```javascript
function largestOfFour(arr) {
  var results = [];
  for (var n = 0; n < arr.length; n++) {
    var largestNumber = arr[n][0];
    for (var sb = 1; sb < arr[n].length; sb++) {
      if (arr[n][sb] > largestNumber) {
        largestNumber = arr[n][sb];
      }
    }

    results[n] = largestNumber;
  }

  return results;
}
```

This is the beginner's solution provided by FCC, and I wrote the correct solution, but my code is wrong and I don't understand why there's a need for var results or for var largestNumber. Why can't I return arr[n][sb] as is?
Option menu checkbox android problem
Tags: help
Published: 2018-01-03 00:13:31

---
title: Option menu checkbox android problem
published: true
tags: help
---
Hi

I have a problem with the option menu checkable item

![Alt illustration of the problem](https://thepracticaldev.s3.amazonaws.com/i/39eqwencx5ss9ia90ea1.png)

I want the checkbox be placed right of title not under it.

He is my option.xml

    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">

        <group android:checkableBehavior="single">
            <item android:id="@+id/notif"
                android:title="Notification"
                android:checkable = "true"/>
        </group>
    </menu>
Thanks.
2018 Resolutions
Tags: newyear, books, personaldevelopment
Published: 2018-01-04 04:58:18

---
title: "2018 Resolutions"
published: true
tags: newyear, books, personaldevelopment
canonical_url: https://www.iamdeveloper.com/2018-resolutions/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/el9zpvhbtnwrdmeel3rz.PNG
---

So like many, I too will make resolutions for 2018. I made myself accountable by joining a recent [#DevDiscuss on Twitter](https://twitter.com/ThePracticalDev/status/948373905181478913).


{% twitter 948382168274829314 %}

So let’s break down the list:

1. I’ve been active in OSS for the past couple of years, with most of my focus being on [react-slingshot](https://github.com/coryhouse/react-slingshot). I started contributing to this project as a way to learn [React](https://reactjs.org) and at some point, to my surprise, I was asked to become a collaborator on the project. I really enjoy working on this project with my partners in crime. {% twitter 948259381912702976 %} In 2018, I will keep contributing to OSS including react-slingshot, but specifically I will contribute at least one PR to [Visual Studio Code](https://github.com/Microsoft/vscode), [TypeScript](https://github.com/Microsoft/TypeScript) and the [Brave Browser](https://github.com/brave/browser-laptop). These are all fantastic projects that I use everyday, so it just makes sense.
2. Keep on blogging <span style="green">✔</span> thanks to this post. 😉
3. Start making code pens on [codepen.io](https://codepen.io). I’ve never made any so yolo, here we go.
4. Read everything I put in [Pocket](https://getpocket.com). This is a toughy, but let’s see how it goes. {% twitter 947522380632678402 %}
5. [Functional-Light JavaScript](https://leanpub.com/fljs) is supposed to be a fantastic book. Kyle Simpson is a great teacher and has plenty of books out there, i.e. [YDKJS](https://github.com/getify/You-Dont-Know-JS). I’m looking forward to reading this one.

Now it’s time to add a reminder in Google Inbox for the end of the year to see if I’m all talk or not. 😉 💪
How to get core file of segmentation fault process in Docker
Tags: docker, debug
Published: 2018-01-02 23:32:22

---
title: How to get core file of segmentation fault process in Docker
published: true
description: 
tags: #docker #debug
---

## Configure to get core file

Run following commands in a start up script of docker container.

```sh
echo '/tmp/core.%h.%e.%t' > /proc/sys/kernel/core_pattern
ulimit -c unlimited
```

- In some case, default value of `/proc/sys/kernel/core_pattern` is pipe. Then, it should be configured explicitly
- Configure size of core file by `ulimit` command

## Setting for the program

- Enable debug option if the program is compiled by yourself. Install debug symbol
 if it's from package manager.
- Do not delete source code in docker image.

## Run container

- Use `--privileged` option when `docker run` to allow write permission for `/proc/sys/kernel/core_pattern`

## After segmentation fault

- Check your container ID by `docker ps -a` command
- Create docker image from the container by `docker commit`
    - example) `docker commit -m "coredump" 92b8935a7cd7` (92b8935a7cd7 is container ID）
- `docker run -it <created image ID> sh` and boot a container in a state immediately after segmentation falut

## After boot a container

- Install gdb if it hasn't been installed
- Run `gdb /path/to/binary /path/to/corefile`
- Enjoy debugging