teleren/devto huggingface dataset:
SOS: Testing multiple subdirectories with Travis
Tags: travisci, help, docker, discuss
Published: 2018-11-19 13:56:28

---
title: SOS: Testing multiple subdirectories with Travis
published: true
description: Multiple subdirectories with independent travis.yml
tags: travisci, help, docker, discuss
---

This goes to all TravisCI ninjas

I have a repo with all my Dockerfiles and I would like Travis to run tests on them individually, but they are all in various directories. Below is how my directories are structured.

```
GitHub repo
    |-> fast.ai
        |- .travis.yml
        |- Dockerfile
    |-> Jekyll
        |- .travis.yml
        |- Dockerfile
    |-> LaTex
        |- .travis.yml
        |- Dockerfile

    |-> .travis.yml
```

I was able to run a Travis build, but then this just pretty much aggregates all the results into one Travis svg.

```yml
language: c
sudo: required

services:
    - docker
notifications:
  email: false

install:
  - make -C fast.ai build && make -C fast.ai run
  - make -C Jekyll build && make -C Jekyll run

before_install:
  - cd fast.ai && git clone --depth 1 https://github.com/fastai/fastai.git && cd -
  - cd Jekyll && git clone --depth 1 https://github.com/mmphego/mmphego.github.io && cd -

script:
- docker ps -a

```

Q: Is it possible to run Travis to multiple directories and have multiple results?
![](https://thepracticaldev.s3.amazonaws.com/i/ldun60megxzhj71i6zdc.jpg)
開発時はSQLのログを見よう
Tags: sql
Published: 2018-11-19 13:44:55

---
title: 開発時はSQLのログを見よう
published: true
description: 
tags: sql
canonical_url: https://crieit.net/posts/SQL
---

最近はSQLを利用したアプリケーションを開発する際、ほとんどORMを使うのが当たり前になってきていると思います。しかし実際に実行されるクエリを確認しないと大変なことになることもあるため、開発時のログをある程度は見ながら進めた方が良いと思います。

## 実行したSQLを見る方法

例えばPHPのフレームワークの場合、LaravelであればDebugbar、CakePHPであればDebugKitを導入することで、ページを開いた際に実行されたSQLの一覧を見たりすることができます。

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

その他の言語やフレームワーク、例えばRuby on RailsやPhoenix等は、開発サーバーを実行している際にSQLの履歴が流れてくるためそれによって確認することができます。

## 実際に何を見たら良いのか

基本的に見たほうが良いところというのは、重いSQLではないかと、SQLの実行回数あたりになると思います。

普通のシンプルなSQLであればだいだい問題ないとは思いますが、JOINしていたりサブクエリを含んでいたり関数を使っていたりする場合、そのSQLのEXPLAINで確認してちゃんとインデックスが効いているかなどを見たほうが良いです。ただ、このあたりはスキーマを検討する際にだいたい考えられていたりすることもあるので、大丈夫なことも多いかもしれません。

もう一つ問題となるのが、実行回数です。以前僕が既存のプロジェクトに途中から参加したことがあったのですが、一ページ内で3000以上のクエリを実行しているページがいくつもありました。たしかカレンダーとか、データ一覧のそれぞれのデータに対してループを行い、更に取得したデータに対してもループしてSELECTを実行する、みたいな感じでそれくらいになってしまっていたと思います。

なんでこんな事になっていたのかと言うと、それはLaravelのプロジェクトだったのですが、結局Debugbarを入れていなかったためクエリの実行回数が可視化されておらず、作成した本人も全く気づいていなかったような状態でした。後で僕がDebugbarを入れたため、そのページを触った時に気づきました。

この場合の解決法としては、ループの中でSELECTを実行せず、最初に1回必要なデータを全部取得しておき、ループの中ではそれを参照するだけにする、という形にすればほとんどSELECTを実行する必要がなくなります。

## まとめ

今もしSQLを利用しているプロジェクトで実行しているSQLを全く見ていない、という場合、ちょろっと見てみると良いと思います。

特に炎上中のプロジェクトの場合、誰もそのあたり考える余裕もなく適当に作られている場合があるため、怖いもの見たさで可視化してみるとよいかもしれませんよ…。
What are the advantages of using Pub/Sub instead of directly triggering through HTTP (Google Cloud Scheduler)?
Tags: help, devops, webdev, gcp
Published: 2018-11-19 13:02:36

---
title: What are the advantages of using Pub/Sub instead of directly triggering through HTTP (Google Cloud Scheduler)?
published: true
description:  What are the advantages of using Pub/Sub instead of directly triggering through HTTP (Google Cloud Scheduler)?
tags: help, devops, webdev, gcp
---

My guess: security.

Cloud Scheduler doesn't seem to provide any way to verify the request source. If the endpoint is discovered, users could trigger the endpoint outside schedule.

Are there any other benefits of using pub/sub?

Google Cloud Scheduler: https://cloud.google.com/scheduler/

Google Cloud Pub/Sub: https://cloud.google.com/pubsub/
Rethinking goal setting
Tags: goals, productivity, habit, routine
Published: 2018-11-19 11:17:07

---
title: Rethinking goal setting
published: true
cover_image: https://thepracticaldev.s3.amazonaws.com/i/qok1usirp6gy0z23zfms.jpeg
description: Setting goals
tags: goals, productivity, habit, routine
---

Listing goals is very important, mainly because you are able to visualize what you want in the future and get a clearer direction. But in reality, it does not matter if you have a long list of goals without a plan of action.

To achieve the goals, I usually have a few steps:

* List the goals I want to achieve in this topic, no matter how difficult they are;

* I reread the entire list and wonder: Is this item really necessary? If it is not, I just delete it;

* With my list reduced, it's time to list all the small actions to reach the goal. 

* For example, if your goal is to read 24 books in a whole year, but still you have not read any of them, how about starting to read 2 pages a day;

* With the new list of actions, we can create good habits and have immediate rewards and faster results.

I try to organize my life this way, for the time being it has helped me a lot.
What's your sense of "duty" to your team?
Tags: discuss, career, work
Published: 2018-11-19 10:07:16

---
title: What's your sense of "duty" to your team?
published: true
description: Balancing your needs versus your team's
tags: discuss, career, work
---

In my career so far, I've only been part of a few different software teams, but I find it hard to leave each one because I usually grow attached and have a sense of duty to the team that makes me feel bad for leaving.

As an example, I'm currently faced with an opportunity to switch teams again in a couple months (after six months in this one), and although I feel it's best for me to take it, I can already see myself feeling bad for leaving my current team - like I'm letting them down by moving to something that's more interesting to me, and leaving my teammates to adapt to the new team makeup in my absence.

**Do you feel a sense of duty to your team at work? What does that duty mean to you? How do you balance what's best for your career versus what's best for the team?**

I'd love to know your thoughts, and whether or not you've dealt with similar feelings in your career!
On That 'New' New!
Tags: beginners, javascript, webdev
Published: 2018-11-19 09:46:54

---
title: On That 'New' New!
published: true
description: Brief intro to the 'new' Javascript operator.
tags: Beginners, Javascript, WebDev
cover_image: 
---

## Simplifying the 'new' Keyword!

So, this week I'm gonna be breaking down another essential Javascript operator to become familiar with: the `new` operator. I think that the best way to start off an explanation of `new` is by first describing what happens when it is used. 

#### Four things happen when `new` is used:

1. A new, empty object is created.
2. `this` is bound to the new object.
3. The newly created object's internal `[[prototype]]`, or `__proto__`, is set to be the same as the `[[prototype]]` of the constructor function's.
4. The new object is returned with a `return` `this` at the end of the function.

## I know that might not make much sense!

Let's create a really simple constructor function so we can get a more practical idea of how `new` works. This one I'm going to call `Homie` and it's going to take in a couple of parameters and set them to the value of `this`.

```js
const Homie = function (name, thingInCommon, isChill, likesMyJokes) {
    this.name = name;
    this.thingInCommon = thingInCommon;
    this.isChill = isChill;
    this.likesMyJokes = likesMyJokes;
}
```

Now we can use `new` to invoke the constructor:

```js
const homie1 = new Homie ('Sweaty Steve', 'Weightlifting', false, true);
```

So in this example, we have:
1. Created an object, called 'homie1', that seems like a decent gym buddy. You probably wouldn't want to hang out with Sweaty Steve in your spare time, but he seems like he'd give you tips about your form and spot you if you needed him to. 
2. Bound `this` to homie1.
3. Added a `__proto__` to homie1 that will point to our `Homie.prototype`.
4. Returned our homie1 object. 

We can see this in action with a quick console log:

```js
console.log(homie1)

/* Homie {name: "Sweaty Steve", thingInCommon: "Weightlifting", isChill: false, likesMyJokes: true}
isChill: false
likesMyJokes: true
name: "Sweaty Steve"
thingInCommon: "Weightlifting"
__proto__: Object */
```

The commented code is what I get back when running all of the prior code in a Google Chrome console window. So we can clearly see that an object has been created with all of the values that we input when we called the `new` keyword. We can also see the `__proto__` object, which I will dive further into in a future post. 

We could continue using the `new` keyword and passing in new parameters to quickly create a whole gang of homies to kick it with!

I hope this gives a small example of how `new` can be used to quickly create new objects from a constructor function and some of the properties that carry over to these objects.

### I really love it when people react and follow!
What do I write about in my blog as a junior developer?
Tags: discuss, beginners
Published: 2018-11-19 08:50:04

---
title: What do I write about in my blog as a junior developer?
published: true
description: 
tags: discuss, beginners
---

Many professional developers with rich experience recommend starting a blog to share whatever comes to one's mind. 

Four years ago I started a blog. I was putting out to the world everything I was trying out and learning at that moment. And let’s be honest, it was rubbish that no one was interested in.

Later I started a new blog from scratch. I published my translations (English to Russian) of some blog posts I found interesting. One out of five existing posts got attention, and even at this moment, it’s relatively popular (it gets around 30 unique views per week). But I still understand that this content isn’t unique itself and it’s not highly demanded.

So, guys, do you have any good advice on what to write about when you don’t have many things to share? Maybe I shouldn’t share anything at all?
Compute Smart, Not Hard
Tags: mathematics, puzzles, logic, optimization
Published: 2018-11-19 08:25:21

Probably the most famous coding interview question has to do with the Fibonacci sequence:

> `Given a number F(0) = 0, and a number F(1) = 1`
> `Write a program to find F(N) for any N > 2, given:`
> `F(N) = F(N-1) + F(N-2)`

There are all sorts of different solutions which use iteration, recursion, [and even matrix multiplication](https://www.geeksforgeeks.org/program-for-nth-fibonacci-number/). "Better" solutions talk about tail call optimization and other advanced programming concepts. But most of these solutions are still unbearably slow. [The JavaScript solution posted here](https://medium.com/quick-code/fibonacci-sequence-javascript-interview-question-iterative-and-recursive-solutions-6a0346d24053) takes almost a second and a half to find the 15th Fibonacci number. Imagine how much time it would take to calculate `F(1000000)`!

One shortcut that lots of people aren't aware of is that the `N`-th Fibonacci number is related to the golden ratio by the rule:

> `F(N) = floor(pow(g,N) / sqrt(5) + 1/2)`
> `for any N > 0`
> `where g = the golden ratio = (1 + sqrt(5))/2`

The best, most efficient (in terms of space _and_ time) solution, is to use this relationship to calculate the `N`th Fibonacci number. But the knee-jerk reaction of most programmers is to just brute force it, without fully understanding the problem beforehand. Doing a little research can save you a lot of CPU cycles and wasted RAM.

On that note, here's a problem for you that could be brute-forced, but can also be solved with just a pen and paper. Make some assumptions and use some logic to narrow the parameter space of your problem to just a few possible solutions, and then find the correct one(s)!

---

Francesco was born in a year where the product of the digits of the year equal the square of some natural number, `n`. The year is now 2005, and he's waiting for the year when his age will be equal to that natural number, `n`. What year was Francesco born and what year is he waiting for?

---

Good luck! I look forward to your solutions below. Feel free to ask any questions related to the prompt.
I am Full Stack Developer with NodeJS,AWS,Serverless and NoSQL in Fintech domain having experience of 4 years, Ask Me Anything!
Tags: fintech, node, serverless, aws
Published: 2018-11-19 07:24:51

---
title: I am Full Stack Developer with NodeJS,AWS,Serverless and NoSQL in Fintech domain having experience of 4 years, Ask Me Anything!
published: true
tags: fintech,nodejs,serverless,aws
---
Filezilla's annoying transfer sound
Tags: filezilla
Published: 2018-11-19 06:52:16

---
title: Filezilla's annoying transfer sound
published: true
description: 
tags: filezilla
---

I know no one these days use FTP transfer but I still do. And this is something I am really annoyed at during transfers. 

So if you are one of those people who want to get rid of this follow this.

<b>On Windows 8 and above</b>

1. Open <b>Notifications and Settings</b> by pressing the windows key.
2. Scroll down to Filezilla. 
3. Click on it. Don't turn it off from there directly.
4. Inside it you will find an option to turn off the sounds.

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

<img src="https://thepracticaldev.s3.amazonaws.com/i/w48wgvkwt84mso41mio5.png" />
How do you design your noSQL database for RBAC system?
Tags: explainmelikeimfive, discuss, mongodb, nosql
Published: 2018-11-19 06:46:35

---
title: How do you design your noSQL database for RBAC system?
published: true
description: RBAC (Role Based Access Control)
tags: #explainmelikeimfive #discuss #mongodb #nosql
---


RBAC is like an user role system, in word-press or any CMS and dev.to have it too. But how do you design your database in mongodb/nosql? since the bad and good of nosql it is fluidness and dont care much about our database design (IMO) how would you make it on mongodb/noSQL? using collection as a pivot? same as SQL database?


Here is the things. 

1. User had a role
2. User had a menu
3. Some user just can see the menu, but cant edit/update the menu
4. Some user fully get all access to the menu

EDIT:

Here comes my schema approach so far :

**menus.model.js**

```javascript
module.exports = function (app) {
  const mongooseClient = app.get('mongooseClient');
  const { Schema } = mongooseClient;
  const menus = new Schema({
    name: { type: String, required: true },
    slug: { type: String, required: true },
    menu_roles: [{
      roles_id: { type: Schema.Types.ObjectId, ref : 'Roles' },
      roles_name: { type:  String },
      create: { type: Boolean },
      delete: { type: Boolean },
      update: { type: Boolean },
      read: { type: Boolean },
    }]
  }, {
    timestamps: true
  });

  return mongooseClient.model('menus', menus);
};

```

roles.models.js

```javascript
module.exports = function (app) {
  const mongooseClient = app.get('mongooseClient');
  const { Schema } = mongooseClient;
  const roles = new Schema({
    name: { type: String, required: true },
    slug: { type: String, required: true },
  }, {
    timestamps: true
  });

  return mongooseClient.model('roles', roles);
};

```

users.models.js
```javascript
module.exports = function (app) {
  const mongooseClient = app.get('mongooseClient');
  const { Schema } = mongooseClient
  const users = new mongooseClient.Schema({

    email: {type: String, unique: true, lowercase: true},
    password: { type: String },
    first_name: { type: String },
    last_name: { type: String },
    roles: { type: Schema.Types.ObjectId, ref : 'Roles' },

  }, {
    timestamps: true
  });

  return mongooseClient.model('users', users);
};

```

Still on work, feedback are pretty welcome thanks!
UberG33K: A beginners guide.
Tags: career, geeks
Published: 2018-11-19 06:29:59

---
title: UberG33K: A beginners guide.
published: true
description: A parody of what it means to be an UberG33K.
tags: #career #geeks 
---

This video wraps all the best career advice into a tidy package and unceremoniously dumps it in the bin.

Talking about best practice is so dry and boring, so I thought I would put together a video about all the worst practices I've ever seen. Unafraid of taking on the values systems held dear by developers we dive in to parody the very worst prima donna developers.

The whole point of this video is to identify anti-examples, examples which under no circumstances should be followed. Also, if you feel I am mocking hard working software developers you would be right; we might not be this bad, but the examples I'm using real life. Sometimes the examples were not intentional. Sometimes they were.

It was also to have a little fun with the often delicate egos of those who like to think they are all that. Lets keep it real out there!
4 Occasions When A Redesign Is Necessary For Your Website
Tags: websiteredesign, websitedesign, webdesign, webdesigner
Published: 2018-11-19 06:03:49

---
title: 4 Occasions When A Redesign Is Necessary For Your Website
published: true
description: Here are 4 ways to find out if your website needs a redesign 
tags: website redesign, website design, web design, web designer,
---
2018 has been a year of tremendous trends. From AI to VR, there is a plethora of new technologies making its way into our day-to-day lives. To keep up with growing needs, any business today needs a website - the simplest, yet the strongest piece of technology. A portal that connects you with a customer, the website you own has to be nothing short of stellar. Web design is considered the most important part of each website. Without good design, catching a customer's attention is impossible! If your website doesn't have good design, it is high time you get one. However, overdoing it can be a problem all the same. So how do you know if your website needs it or not? 

![Website Redesign Company Singapore](https://thepracticaldev.s3.amazonaws.com/i/rymr3aqtv0qpwp6ulg6r.jpg)

**1) Clustered Appearance:**

Unlike how things were a decade ago, today websites have to be neat, simple and to the point. Minimalism is the fashion people look for. Several websites have a cluster of unnecessary information housed, which only creates more confusion! If that's the case with your site, consider a redesign. Make it minimal, and only show what a user wants.

**2) Poor Navigation:**

When a website has multiple features to display, navigating around them becomes a difficult task for users. If a site has no proper buttons or links to follow, a visitor is bound to leave! Should your website need a better navigation, and then consider redesigning it!

**3) There Are More Content And Less Space:** 

Often times, businesses branch out and have a bigger reach. A tee-shirt online store might start selling mugs as well; this creates the need for more space. Things can't be added on top of each other, and such conditions call for a new design.

**4) The Website Isn't Mobile Friendly:**

For a site to be mobile friendly is today's greatest requirement. With 60-65% of people using mobiles today, the chances of reaching customers through phones are higher! If your website doesn't load on mobiles or has a poor interface when seen on phone, it needs a redesign. 

Websites are of paramount importance today, and your venture needs one with the best design! Call Openwave today and [hire a web designer in Singapore](https://www.openwavecomp.com.sg/web_design.html)! With our assistance, your site will look sparkling new in no time!
Text to Emoji converter using G-Script
Tags: javascript, beginners, education, webdev
Published: 2018-11-19 04:42:37

---
title: Text to Emoji converter using G-Script
published: true
description: A small code snippet that converts plain text to emoji by converting some of the words.
tags: #javascript, #beginners, #education, #webdev
---

Did something I found fun. So sharing it here. If there are teachers on here they can think of ways to use this as a model to teach different coding concepts to students.

I designed a small Google script code that accepts plain text and converts it into Emoji text. Basic steps below.

STEP 1: Setting up the Google sheet.

I have 2 sheets. One for the inputs/generated output and another for the lookup which has the word > equivalent emoji. This second sheet is sorted by word so that Binary Search can be implemented for the search. 

SHEET 1
![Sheet 1](https://thepracticaldev.s3.amazonaws.com/i/2h9qsy47efzode2vz8mw.jpg)

SHEET 2
![Sheet 2] (https://thepracticaldev.s3.amazonaws.com/i/gbhpg0johdbbbqwfksl8.jpg)



STEP 2: The code

The code comprises of two functions. 

convertTexttoEmoji () : This is the main function that analyses the input text and outputs the converted emoji text.
getEmoji() : This function is called by convertTexttoEmoji() and does the heavy work of looking up matching emoji icons for every word. This is the function which uses a Binary Search for this operation.


convertTexttoEmoji ()
![convertTexttoEmoji](https://thepracticaldev.s3.amazonaws.com/i/lxcrsbalxg0k93hv1k3l.jpg)


getEmoji()
![getEmoji()](https://thepracticaldev.s3.amazonaws.com/i/swaibhtugavjm4swphjw.jpg)



STEP 3: The result

![Output 1](https://thepracticaldev.s3.amazonaws.com/i/sdzkjffh75v8p2fv25cc.jpg)


![Output 2](https://thepracticaldev.s3.amazonaws.com/i/kam3gvrkrhl4wuxbvkgw.jpg)




CONCLUSIONS:

- The words being looked at are absolute matches (including case-sensitivity). So if I were to type "bike" instead of "biking" it will not work. Solution? Add more words to the data set with a comma and do a second level look up for similar words + force lower case on them for consistency check.

- Splitting this text into an array was easy but handling punctuation in the output was a little tricky due to the spaces.

- The emoji database itself is limited so a much larger data set might take longer to run/execute.

- Emojis look different on different devices. So a mountain may look perfect on your device and may look like a big ugly triangle on some other device. Testing it with various devices is a good idea!
Allow Multiple Email Addresses in a Lightning Input Component
Tags: salesforce, aura, emailinput, lightningcomponent
Published: 2018-12-17 18:43:24

---
title: Allow Multiple Email Addresses in a Lightning Input Component
published: true
tags: Salesforce,Aura,Email Input,Lightning Component
canonical_url: http://blog.ijasoneverett.com/2018/11/allow-multiple-email-addresses-in-a-lightning-input-component/
---

The [lightning input component](https://developer.salesforce.com/docs/component-library/bundle/lightning:input/example#lightningcomponentdemo:exampleInputEmail) has built in support for emails which works great when you need to accept an email address as input.

```
<lightning:input aura:id="emailForm" label="To: " type="email"
                 name="toEmail"
                 value="{!v.toEmail}"
                 required="true"/>
```

This auto validates the input to ensure its in the correct format. The moment you add a semi-colon to add multiple emails, the validation fails. It only allows for one email input. To get around this you can’t use the email type. You have to use the text type and do the validation yourself using a regular expression like:

```
<lightning:input aura:id="emailForm" label="To: " type="text"
                 name="toEmail"
                 value="{!v.toEmail}"
                 required="true"
                 messageWhenPatternMismatch="Please enter a valid email or valid emails separated by a semi-colon"
                 pattern="^(([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)(\s*;\s*|\s*$))*$" />
```

With the snippet above, you can now accept multiple emails in a single input control. It’ll correctly validate whether you use a single email or multiple emails. If you can improve the regular expression, leave a comment below.

**Controller validation**  
You can further validate the input in your controller with this snippet:

```
var allValid = component.find('emailForm').reduce(function (validSoFar, inputCmp) {
     inputCmp.showHelpMessageIfInvalid();
     return validSoFar && inputCmp.get('v.validity').valid;
}, true);
if (allValid) {
    //proceed
} else {
    //display error
    component.set("v.error", 'Please update the invalid form entries and try again.');
}
```