teleren/devto huggingface dataset:
How to force package installs to use yarn not npm
Tags: npm, yarn, javascript
Published: 2019-01-18 14:06:30

---
title: How to force package installs to use yarn not npm
published: true
description: 
tags: npm, yarn, javascript
---

Leaving aside arguments over which node package manager is better, one thing that should be clear is that it's a bad idea to switch between them in the same project, as conflicting lockfiles can leave the project in an unpredictable state. If you run yarn in a project that has a `package-lock.json` from npm then it does warn you about this, but npm doesn't do the reverse. If you run `npm install` in a project with a `yarn.lock` it will happily install the packages and create a package-lock.json for yarn to complain about next time. This is my solution.

If you add a `"preinstall"` script to your `package.json` it is run before any install by npm or yarn. If it exits with an error code then the install is aborted. This means it's the perfect place to check. During script execution, the environment variable `$npm_execpath` is set to the path of the npm or yarn executable, so we can use this to check what the install is using. You could use node to check this, but that seems like overkill, so I'm going to use shell commands directly inside the script. I echo the contents of the variable, pipe it to `grep`, and if it doesn't match yarn then it exits with an error. (I ❤️ emojis in shell scripts):

```sh
echo "$npm_execpath" | grep -q "yarn\.js$" || (echo '⚠️ Use yarn not npm! ⚠️' && exit 1)
```

This works great, but it can look confusing as it displays the full command when it's run, so looks like there's an error even when all is well. The way around this is to make it a separate script, which is run with the `--quiet` flag. We can use `$npm_execpath` again to be sure we're running it with the same script:

```json
"scripts": {
        "preinstall": "$npm_execpath --silent run checkyarn",
        "checkyarn": "echo \"$npm_execpath\" | grep -q \"yarn\\.js$\" || (echo '⚠️  Use yarn not npm! ⚠️ ' && echo && exit 1)"
}

```

If you run `npm install` you get the error:

```sh
example git:(master) ✗ npm i

> example@0.0.1 preinstall /Users/matt/Documents/repos/example
> $npm_execpath --silent run checkyarn

⚠️  Use yarn not npm! ⚠️

npm ERR! code ELIFECYCLE
errno 1
```

...but if you run `yarn`:

```sh
➜  example git:(master) ✗ yarn
yarn install v1.12.3
$ $npm_execpath --silent run checkyarn
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 1.35s.
```

Happy installing!
Don't You Dare Update That Copyright Manually
Tags: rant, csharp, advice
Published: 2019-01-18 13:44:34

---
title: Don't You Dare Update That Copyright Manually
published: true
tags: rant, csharp, advice
---

A quick reminder for developers: now that we're in a new year, if you update your copyright to manually be "2019" there's almost certainly a spot for you in hell. Don't kick this down the road--solve the problem forever with something like `DateTime.UtcNow.Year` (or whatever your language of choice does for current year).

I just approved a ticket that changes `2016-2018` to `2016-{DateTime.UtcNow.Year}` because there were three separate pull requests in the past that didn't address this. Now, barring any systemic changes to how .NET calculates the current UTC DateTime, we will **never have to update this again**.

### July 12, 2016


![2016 Change](https://thepracticaldev.s3.amazonaws.com/i/xaypxjiawux8lrboo7hn.png)

### February 16, 2017

![2017 Change](https://thepracticaldev.s3.amazonaws.com/i/8ma1hirwwtbmhwqh6p4y.png)

### July 13, 2018

![2018 Change](https://thepracticaldev.s3.amazonaws.com/i/n3osm8cwvmyjj3ul3g4p.png)

### January 17, 2019

![2019 Change](https://thepracticaldev.s3.amazonaws.com/i/qnmwz6qwclrx0hj74ki3.png)
Firefox Multi-Account Containers are awesome!
Tags: firefox, browser, tools, productivity
Published: 2019-01-18 13:14:34

---
title: Firefox Multi-Account Containers are awesome!
published: true
description: Firefox Multi-Account Containers are awesome and what you need
tags: #firefox #browser #tools #productivity
---

I use three types of accounts:

* Private
* Full-time work
* Web development work

If you want to know why I'm using three types of accounts. Leave a comment down below.

I'm switching all the time between these accounts on different websites.

Logging into Gmail with my work account and at the same time logging into Gmail with my private account. So I can read both emails.

Another example is YouTube. I'm subscribed to different types of channels on every account.

Firefox Multi-Account Containers to the rescue!

From the day on I discovered them I use them everywhere and Firefox is my main browser because of that.

How do they work?

Firefox has `profiles or containers`. If you really look behind the scene it's just a folder on your hard drive where firefox saves stuff like your configuration or history and so on.

You can change that profile by starting firefox with the -p flag and then you will be prompted with a list of profiles where you can manage them. So its nothing new but now you can use these profiles within the same window but in different tabs!

Okay, let's set this up

 * 1) Install Firefox ( Hello captain obvious) 
 * 2) install this [extension](https://addons.mozilla.org/en-US/firefox/addon/multi-account-containers/)
 * 3) Have fun with it! 

Now when you long press the new tab button you see this:

![firefox screenshot](https://addons.cdn.mozilla.net/user-media/previews/full/196/196940.png?modified=1543520769)

By default, Firefox creates 5 containers for you!

 * 1) The default container ( no color)
 * 2) The personal container ( Blue )
 * 3) The work container ( Orange )
 * 4) The banking container ( Green )
 * 5) The shopping container ( Pink )

If you want to use them like that just do it is a pretty nice setup.
You can edit them by clicking on the symbol with 4 squares on the right side

![firefox screenshot 2](https://addons.cdn.mozilla.net/user-media/previews/full/196/196941.png)

Cool so now we have our multi-account containers and we can log in to 3 google accounts at the same time just a tab away!

![tabs screenshot](https://thepracticaldev.s3.amazonaws.com/i/dc6okn6b0qgs26mm6ffe.png)


Thanks for reading!

Say Hallo! [Instagram](https://www.instagram.com/lampewebdev/) | [Twitter](https://twitter.com/lampewebdev) | [LinkedIn](https://www.linkedin.com/in/michael-lazarski-25725a87) | [Medium](https://medium.com/@lampewebdevelopment)
Using arrow functions in object methods
Tags: es6, arrowfunctions, method, react
Published: 2019-01-18 12:31:40

---
title: Using arrow functions in object methods
published: true
description: 
tags: ES6, arrow functions, method, react
---
Is it possible to use arrow functions to define a method inside a class?

If it's possible. How can I define the method bark() in the bellow example with arrow function?

```
class Dog {
    constructor(name, bread) {
        this.name = name;
        this.bread = bread;
    }

    bark() {
        return `Bark Bark! My name is ${this.name}`;
    }
}
const mini = new Dog('Mini', 'Spitz');
mini.bark();

```

I tried this, but it's saying: Uncaught SnytaxError.
```
bark = () => {
        return `Bark Bark! My name is ${this.name}`;
    }
```
Docker Wildfly with Oracle developing environment
Tags: docker, java, wildfly, oracle
Published: 2019-01-18 12:13:08

---
title: Docker Wildfly with Oracle developing environment
description: Dockerized Wildfly with Oracle driver developing environment, setting up a data source (using credential store) and basic auth. Autodeployment and Debugging. [Find it on Github](https://github.com/javieraviles/docker-wildfly-oracle)
published: true

tags: docker,java,wildfly,oracle
canonical_url: https://github.com/javieraviles/docker-wildfly-oracle/blob/master/README.md
---
UAE Road Accidents Statistics - Infographic
Published: 2019-01-18 11:53:46

---
title: UAE Road Accidents Statistics - Infographic
published: true
description: Road Accident causes in UAE. See the infographic full statistics.  
tags: 
---




Road accidents are increasing rapidly on UAE roads irrespective of better road infrastructure and traffic rules. According to TheNational, there are 76 deaths in the first half of 2018. There are heavy fines and penalties but still due to the visitor drivers who don't know much about traffic laws and road safety of UAE roads causes accidents. 

According to reports, Road accidents were mainly caused by fast driving and careless behavior of the driver. The 98% of passengers in road crashes were without seat belts - a Survey shows. 

New and passionate drivers drive without looking on the road safety measures. A new driver or careless driver don't even know speed limits in domestic areas. According to the UN World Health Organization report, in UAE the road accidents deaths are the second major cause of deaths in UAE. Based on a report, 63% of children dying every year due to road accidents.   
[PitStopArabia -an authorized dealer of online tires](https://www.pitstoparabia.com/) supplying in UAE, has gathered data from different sources in the form of an Infographic. Have a look at their prepared statistics. 



<img src="https://www.pitstoparabia.com/media/wysiwyg/Road-Accident-in-UAE-2018-Infographic.png"></IMG>
Happy Wheels
Tags: happywheels, onlinegames, flashgames
Published: 2019-01-18 11:27:44

---
title: Happy Wheels
published: true
description: Happy Wheels is extremely hard online game.
tags: happy wheels, online games, flash games
---

Happy Wheels was developed in late 2010 and since that it became most played game of all time. Here is [happy wheels demo](https://happywheels13.com) for testing and if you're lucky enough to win all levels then go to the official website: Totaljerkface.com
Fin out 10 other games like Happy Wheels: [link](https://www.techshout.com/alternatives/2012/16/games-like-happy-wheels/)

![happy wheels pic](https://snagfilms-a.akamaihd.net/6fef71e8-3185-432f-8431-106c2be042c8/images/47/09/00cdb2744189aa94da11150b943e/1527252611112_happywheelsjpwthumbnail_16x9Images.jpg)
Understanding the Eigenclass in less than 5 minutes
Tags: ruby, eigenclass
Published: 2019-01-18 10:21:56

---
title: Understanding the Eigenclass in less than 5 minutes
published: true
description: 
tags: ruby, Eigenclass
---

Today I read [Understanding the Eigenclass in less than 5 minutes](https://medium.com/rubycademy/understanding-the-eigenclass-in-less-than-5-minutes-dcb8ca223eb4). It explained clearly.

```ruby
class Greeting
  def self.hello
    'hello world!'
  end

  def self.eigenclass
    class << self
      self
    end
  end
end

Greeting.eigenclass      # => #<Class:Greeting>
Greeting.eigenclass.name # => nil

Greeting.singleton_methods                  # => [:hello, :eigenclass]
Greeting.eigenclass.instance_methods(false) # => [:hello, :eigenclass]
```

```ruby
class << self
```
This weird syntax means the eigenclass context.
Introduction to Authentication and Authorization
Tags: security, authentication, authorization
Published: 2019-01-18 10:19:41

---
title: Introduction to Authentication and Authorization
published: true
tags: Security, Authentication, Authorization
---

*First published on my [blog](https://lasseschultebraucks.com/security/2019/01/18/introduction-to-authentication-and-authorization.html)*

Lately I have dealt a lot of with authentication and authorization. Therefore I will probably blog a little bit more about these topics in the next weeks. But before that happens I want to talk about specific technologies and tools I want to talk a little bit about the basics.

First let's understand what authentication and authorization is.

# Authentication

Authentication is the process of verifying that a claimed property is true. In the context of IT a machine or a person claims to be someone, e.g. some entity and proves someone, e.g. a server where he wants to fetch some resources from, that
he is actually the one he claims to be. In the process of authentication not only the claim but also the confirmation of the claim is involved. So if the confirmation has successfully happened, the authentication has been successful, else the authentication failed because the person who claims to own an identity failed to prove it.

Every time you log in to a website you use authentication to prove the website server that you are actually the person you claims to be. Without a secure authentication everybody could just claim to be someone else.

# Authorization

After the process of authentication has successfully happened, an authorization process decides which resources you can access. So authorization is basically about distributing roles, rights and privileges and making sure that nobody can see or modify resources which are out of their scope. 

Therefore authorization makes sure that just you - and the admins of a website - can make changes to your posted content. Just imagine that everybody could modify content on the web after a successful authentication process. There would be more than just chaos.
Also limiting the reading of resources is very important. Not everybody should see private shared content or sensitive data.

# Conclusion

Authentication and Authorization is very important for securing resources and limiting access in the whole IT.

That's for now. In the next post I want to talk more about different authentication methods and Identity Provider.
A Month (Actually 2.5 Weeks) of My Life on Github
Tags: coding, programming, github, react
Published: 2019-01-18 09:47:52

---
title: A Month (Actually 2.5 Weeks) of My Life on Github
published: true
description: Exercising my github foo
tags: coding, programming, github, react
---

My actual New Year's resolution was to exercise more.  I didn't know I would specifically be exercising my github foo! 

![](https://thepracticaldev.s3.amazonaws.com/i/jxo8hc0hw0nyyzi74bu2.PNG)

I worked on a couple of existing repos, including ["jackrabbitmvc" a micro-framework for PHP](https://github.com/dexygen/jackrabbitmvc), but also eliminated a couple, while now having added 6, though to be fair, I've not done anything significant with 2 of the 3 forks.  The one fork I did work on is a browser side static content generator I've renamed as [upstaged](https://github.com/dexygen/upstaged) which in turn I've used on for [my own github pages](https://github.com/dexygen/dexygen.github.io)

Neither last nor least is [withMethods](https://github.com/dexygen/withMethods) which allows calling methods from other components in React.  I've already been told on Reddit this goes against the philosophy of React.  Good, I hope it catches on.
blog-cli: A CLI for Blogging with Static Site Generators
Tags: cli, productivity, blogging
Published: 2019-03-02 15:38:54

---
title: blog-cli: A CLI for Blogging with Static Site Generators
published: true
tags: cli, productivity, blogging
canonical_url: https://www.kahlillechelt.com/2019/01/18/blog-cli-a-cli-for-blogging-with-static-site-generators/
---

My blog is built with Hugo. Every blog I ever had was built with a static site generator or a file based CMS. I love static site generators, they make content management simple, they are secure and it’s fun to build websites with them.

For me, they have one problem: creating a blog post is annoying. Typically the file for the post needs to have the date in it and the slug and then you need to put in the Front Matter for the post. It is all just very tedious and annoying.

That’s why I made blog-cli. It creates the Markdown file for me at the right location with the correct file name, inserts the basic Front Matter and opens the file in my favorite Markdown editor. This means I go from post idea to writing in 1 second.

This should work for most static site generators. At least for simple setups.

Here is how it works.

First you have to install blog-cli. You need Node.js and npm for that.

```
npm install --global @kahlil/blog-cli
```

Then you need to tell blog-cli where you want it to put your posts.

```
blog --path ~/my-blog/posts
```

Then you need to tell blog-cli about your favorite Markdown Editor.

```
blog --editor 'ia writer'
```

Now you are all set and you can create a new post and open it in your editor by simple specifying a slug.

```
blog my-new-cool-post
```

This will create a new file with the filename: 2019-01-17-my-new-cool-post.md in the directory you specified, ~/my-blog/posts in this case.

The Front Matter that is inserted looks something like this:

```
---
draft: true
date: 2019-01-18T10:03:48.620Z
title: ""
---
```

* * *

Now, if you are part of the cool kids club then you probably keep your files in a Git repository, commit new blog posts and push them to Github at which point it gets deployed to Netlify.

It turns out that blog-cli can help you with that as well!

```
blog --publish
```

Will automatically commit all changes with the message ‘new post’ and execute a git push.

Nifty, right?! If you are static-site-generator-blogging as well I hope blog-cli can help you.

If you have any ideas to improve it please send an issue or a PR [on GitHub](https://github.com/kahlil/blog-cli).
Ruby Symbols
Tags: ruby, programming
Published: 2019-01-18 08:58:14

---
title: Ruby Symbols
published: true
cover_image: https://thepracticaldev.s3.amazonaws.com/i/1g74wmiwo9xxk4e78ze5.jpg
description: Ever wondered what the difference between symbols and strings are?
tags: 
  - ruby
  - programming
---

[![Ruby Symbols](https://thepracticaldev.s3.amazonaws.com/i/1g74wmiwo9xxk4e78ze5.jpg)](https://www.codemy.net/posts/rfs-symbols-007/sets/ruby-from-scratch)

Symbols are immutable data structure in ruby, it can come in handy in many instances. We also explore the difference between ruby's Strings and Symbols [in this episode](https://www.codemy.net/posts/rfs-symbols-007/sets/ruby-from-scratch).

This video is a part of the [Ruby From Scratch](https://www.codemy.net/sets/ruby-from-scratch) Series on Codemy.net
A Fun Way to Find a Ruby Method with suggest Gem
Tags: ruby, doc, gem, fun
Published: 2019-01-18 08:28:59

---
title: A Fun Way to Find a Ruby Method with suggest Gem
published: true
description: 
tags: ruby, doc, gem, fun
---

{% github jbodah/suggest_rb %}

```ruby
require 'suggest'

# Object#what_returns? tells you which method returns the value
[1,2,3].what_returns? 1
=> [:first, :min]
```

Really fun.
Microservices
Tags: saas, microservices, api
Published: 2019-01-18 07:42:07

---
layout: post
title: "Microservices"
description: Is the end of monolithic structures?
tags: [SaaS, microservices, API]
published: true
cover_image: https://dzone.com/storage/temp/570495-slide1.png
---

## Introduction
Since the explosion of SaaS applications there have been a lot of innovation
in the area of APIs which provide an important interaction between application functionalities.  

The main idea around microservices is that, in general, applications tends to become easier to develop when they are treated as modules. Considering that, each piece is developed separately, being the application a composition of all parts working together. It opposes the traditional development where the application is considered a 'monolithic' entity.  

That way, developers can focus on their own core business while other specialists provide the components needed, which will be accessed through APIs.  

![Monolithic vs Microservice](https://dzone.com/storage/temp/570495-slide1.png)
<figcaption>Monolithic vs Microservice</figcaption>

## How it works
In general, a microservice provide an API endpoint commonly (but not exclusively) through a stateless REST API which can be accessed via HTTP as a traditional webpage. So, consuming those services is easy, as they only require tools and methods that developers are already familiar with.

## Benefits
When applications components are splitted, development time is optimized as they are produced concurrently.  Besides that, modules created with this thought in mind are easier to be reused in other contexts/applications.  

Resilience appears as an additional advantage as components can be spread into multiple servers or even various data centers. In case of a component failure, you can quickly replace it while the rest of application can continue to work as expected.  

Scaling become more efficient too, because you can focus on most demanding parts rather than simply duplicating the entire application.

## Examples
There are several players in various areas, as one can see in the image below:

![Microservices players](http://rafaelmonteiro.github.io/images/microservices_players.jpg)
<figcaption><a href="http://rafaelmonteiro.github.io/" data-toggle="tooltip"
    title="Microservices players">Microservices players (image by Menlo Ventures)</a>.
</figcaption>

## Conclusion
Microservices demands a conceptual change in IT departments towards a DevOps culture, in which development and operations teams work aligned to support an application through its lifecycle, and go through a fast or even continuous release cycle rather than a traditional long one.

Though they are not a silver bullet, microservices must be considered when architecting a new application or refactoring an old one.
The fastest way to learn the syntax of a new programming language
Tags: discuss
Published: 2019-01-18 07:04:19

---
title: The fastest way to learn the syntax of a new programming language
published: true
description: 
tags: discuss
---

![Photo by Dose Juice](https://images.unsplash.com/photo-1543363136-3fdb62e11be5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=600&q=80)

There are many sites like [Leetcode](https://leetcode.com), [Codewars](https://www.codewars.com) and so on, where people solve various coding problems. A lot of people use these sites to make preparations for job interviews, but recently I have found that these sites are supporting more and more programming languages, so they can also be a great helper if you want to learn a new programming language.

The point is that when you are going to solve the coding problems, you will have to figure out how to implement conditions, loops, and how to utilize different data types, e.g., string, list, array, tuple. Every language has its official documentation for these concepts, but documentation is usually too tedious to read through. On the contrary, solving problems is great fun. Also, you will have a clearer purpose when you have to turn to the documentation.

If you want to have a taste of a new programming paradigm, for example, functional programming, you can also practice yourself via these coding problems

What is your opinion？Where would you like to go when learning a new language?