teleren/devto huggingface dataset:
Dead Simple Keyboard shortcut management library for Angular
Tags: angular, javascript, keyboard, shortcuts
Published: 2019-04-18 23:02:07

---
title: Dead Simple Keyboard shortcut management library for Angular
published: true
description: A component based library used to easily create and manage keyboard shortcut in your angular application using a similar interface to Visual Studio Code, while keeping a component based API.
tags: Angular, javascript, Keyboard, shortcuts
---

I have always liked the way Visual Studio Code enabled you to modify/add key binding in a JSON object, which is a pretty nice interface in my opinion. 
Taken as an insperation, I wanted to create a similar and scalable solution for Angular application. 
To achieve a pretty scale-able solution keeping mind memory leakage and garbage collection of registered shortcut in a large app. Thus a component based architecture was chosen.

The library supports both Windows and Mac, has a nice built in help screen to show all registered shortcuts and service to create a customize help screen in need.


You can find the library [here](https://github.com/omridevk/ng-keyboard-shortcuts):
And play with a working example [here](https://codesandbox.io/s/yvyovny43v)

### How it works

1. To optimize for performance, only one event listener is registered to the document body.
2. Each shortcut is then checked when keydown is pressed (this part can still be optimized and will be in the future, but the filtering is pretty quick at the moment so even with 100 registered shortcuts no slowdown are noticeable)
3. You can use a directive to target a shortcut to work only when a specific element is in focus
4. Or use a component that will add a global shortcut to your application, and will be cleaned out automatically when the component is destroyed.

### Feedback

This is the first library I publish to NPM, any feedback, code related, documentation or anything at all will be greatly appreciated.
Doing What Makes You Happy
Tags: career, personal, advice
Published: 2019-04-18 23:00:55

I wrote my first line of code when I was 9. In most industries starting that early would be unusual. Yet in the tech industry this is actually quite common.

So why is this? It is simply because we have a passion for it.

When you are 9 years old, you're not doing it for money, popularity or anything self indulgent other than the amazement of seeing something you have created out of nothing. Even if it is just a blue box on a webpage. That hit if dopamine still tells you it's the coolest thing ever.

But as we get older and step out into the real world we find all sorts of external pressures. Rent to pay, food to put on the table - the list goes on.

For most people the dream is to have passive income. Be able to build something and earn money from it, rather than selling your time. It gives you the freedom to work on those projects you think are cool and that you enjoy, rather than working out of necessity.

This is where so many developers get into the SaaS mindset. Software as a service can lucrative. So why not? The issue is coming up with an idea. 

You search around for SaaS ideas. What industries have a gap for a niche app? You find one and start building. Full of passion and positive mentality.

Some people will succeed at this, but quite a few wont. That's because it all goes back to the 9 year old self making a box blue on the screen. After spending a significant amount of time on just setting up the project you begin to lose interest and motivation. You don't find the project enjoyable because you don't have that passion to see it through.

It is not because you lack passion in coding, it is because you lack passion in the product you are building.

This won't apply to everybody, but I know for me it does. 

This is how we end up with a bunch of unfinished side projects.

Because of this, I am now putting that time and energy from trying to build SaaS apps to doing those things that give me the dopamine hit. For me, it is helping people and creating resources.

So I aim to be a lot more active on a variety of channels. My website, DEV and Twitter to name a few.

I'm going back to my 9 year old self and doing what is making me happy - and there's nothing wrong with that.
How to turn a bash script into a Mac app
Tags: opensource, tutorial, bash
Published: 2019-04-19 09:49:06

---
title: How to turn a bash script into a Mac app
published: true
tags: open source, tutorial, bash
canonical_url: https://www.kennethlarsen.org/turning-a-bash-script-into-a-mac-app/
---

![](https://www.kennethlarsen.org/content/images/2019/04/dadjoke.png)<figcaption>My dad joke app in the Mac dock</figcaption>

I had this stupid idea: At work, we love to share dad jokes. And I know that there is a site called [https://icanhazdadjoke.com/](https://icanhazdadjoke.com/) which when I `curl` it returns a dad joke. So why not make a mac app that fetches a dad joke and reads it out loud?

But I didn't even know where to start building a Mac app. I've built a lot of things, but never a Mac app. So I decided to start making a bash script instead. It looks like this:

```
JOKE=$(curl https://icanhazdadjoke.com)

say -v Daniel "$JOKE"

exit 0
```

This script will assign the dad joke from the website to a variable called `JOKE`. Then I call the `say` command which is a native Mac OS command that reads a string out loud. I pick the voice named `Daniel` to have a consistent British feel to the delivery of the joke.

I could easily run this and have a lot of fun. But, I wanted to share this with my colleagues. I wanted to turn the bash script into a Mac app.

It turns out that if you create the folder structure of a Mac app and use the bash script as the `main.command` it actually works. You can see the result here: [https://github.com/kennethlarsen/dadjoke.app](https://github.com/kennethlarsen/dadjoke.app)

## Create Your Own App

If you have your own bash script you would like to turn into a Mac app then start by forking my dad joke app. Then:

1. Edit [Info.plist](https://github.com/kennethlarsen/dadjoke.app/blob/master/dadjoke.app/Contents/Info.plist) to contain your name and info.
2. Add your bash script to [main.command](https://github.com/kennethlarsen/dadjoke.app/blob/master/dadjoke.app/Contents/MacOS/main.command)
3. Replace [cmd.icns](https://github.com/kennethlarsen/dadjoke.app/blob/master/dadjoke.app/Contents/Resources/cmd.icns) with your own icon

That's it! Now you can `zip` it and send it to your friends.
Amplifying Others
Tags: tips, career, discuss
Published: 2019-04-18 21:22:54

---
title: Amplifying Others
published: true
description: A few simple tips how to elevate the work of others.
tags: 
- tips
- career
- discuss
---

I want to share a way that I elevate others and give visibility to those who may not be visible. It's proven to be a way for me to build trust with others that I work with and to make sure others are seen and heard.

1. I try to use "we" when talking about team accomplishments. Even if I did the bulk of the work or the most visible work, I try to put the group in the spotlight.
2. I try to use the person's name when talking about a teammate's work. Rather than use "we," I directly give that person credit for their work and ideas.
3. I try to use "I" when taking responsibility. If something fell through the cracks that was my fault, or if something didn't go as we planned, I put it on my back.

It usually works well, and it sometimes feels contagious. Others will often amplify each other’s work or ideas the same way. I feel it lets people share without the fear of someone else taking the credit. This is healthy for a team. 

I must add a disclaimer. I mention these tips from a place of privilege. I can give away visibility or credit and be fine. This may not be true for underrepresented groups or people with low visibility. They may have to use "I" where I try to use "we." It's on me to recognize that and amplify their work and voice even more.
What's Haskell?
Tags: haskell, computerscience, beginners, programming
Published: 2019-06-09 15:49:29

---
title: What's Haskell?
published: true
tags: Haskell, Computer Science, beginners, programming
canonical_url: https://lautarolobo.xyz/blog/what-s-haskell/
cover_image: https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Haskell-Logo.svg/1024px-Haskell-Logo.svg.png
series: Haskell 
description: A brief introduction to Haskell
---

So, you are new in [Haskell](http://wikipedia.org/wiki/Haskell_programming_language), and you want to know the basis, great!

Haskell is a _purely functional_ [programming language.](https://en.wikipedia.org/wiki/Programming_language) What this is? Well, the variables do not change over time, the variable will always stay setted to the sepcific value given. So, if you called a function twice, with the same parameters given, the output will be always the same. This property is known as _referential transparency_. It lets you evaluate a function, and get to know if it’s correct.

Haskell is known as a _lazy_ programming language. This means that it will do just the bare minimum computation required to show the result of a piece of code (if you tell him to show it).

And not less important, Haskell is _statically typed_ and has _type inference_, so, if you do not specify the [type](https://en.wikipedia.org/wiki/Data_type) of a function, Haskell will intelegently figure it out. And, if you mess up with the types, the [compiler](https://en.wikipedia.org/wiki/Compiler) will tell you the error and, most of the times, specificly show you in wich line is it that everything blowed up. This helps to fix errors in early stages of development, so the probabilities of the program failing once it is released will be decreased.
How to easily configure properties in Swift
Tags: swift, property, configure
Published: 2019-04-18 19:40:43

---
title: How to easily configure properties in Swift
published: true
description: 
tags: swift,property,configure
---

This post lists the many ways that I know to easily configure properties in Swift

## Using a helper method

```swift
var label: UILabel!

override func viewDidLoad() {
  super.viewDidLoad()

  configureLabel()
}

func configureLabel() {
  label = UILabel()
  label.backgroundColor = UIColor.greenColor()
  view.addSubview(label)
}
```

## Using anonymous function

```swift
lazy var label: UILabel = { [weak self] in
  let label = UILabel()
  label.backgroundColor = UIColor.greenColor()
  return label
}()
```

Ah, by the way, did you know that

- You shouldn't call access `label` in ViewController `deinit`, because it is `lazy` and we have `weak self`
- `lazy` increases your compile time

## @noescape configure Block on init

I first saw it on https://github.com/AliSoftware/Dip/blob/develop/Sources/Dip.swift#L61

```swift
public init(@noescape configBlock: (DependencyContainer->()) = { _ in }) {
    configBlock(self)
}
```

## configure Block as extension

This https://github.com/devxoul/Then makes it easier to configure your property as an extension to NSObject

```swift
extension Then where Self: AnyObject {

    public func then(@noescape block: Self -> Void) -> Self {
        block(self)
        return self
    }
}
```

so we have

```swift
lazy var label: UILabel = UILabel().then { [weak self] in
    $0.backgroundColor = UIColor.greenColor()
}
```

We have to declare `label: UILabel` to use `[weak self]`

## init without extension

I try to avoid extension, after reading this http://nshipster.com/new-years-2016/

```swift
public func Init<Type>(value : Type, @noescape block: (object: Type) -> Void) -> Type
{
    block(object: value)
    return value
}
```

we can use it like

```swift
lazy var label: UILabel = Init(UILabel()) { [weak self] in
  $0.backgroundColor = UIColor.greenColor()
}
```

We have to declare `label: UILabel` to use `[weak self]`

## anonymous function again

This https://gist.github.com/erica/4fa60524d9b71bfa9819 makes configuration easier

```swift
lazy var label: UILabel = { [weak self] in
  $0.backgroundColor = UIColor.greenColor()
  return $0
}(UILabel())
```
How do you stay motivated for the entirety of your project?
Tags: productivity, help, advice
Published: 2019-04-18 19:38:36

---
title: How do you stay motivated for the entirety of your project?
published: true
description: What do you do to stay motivated & dedicated to a project?
tags: productivity, help, advice
cover_image: https://images.unsplash.com/photo-1523292720785-762f75b66b65?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1650&q=80
---

When starting a new project I find myself full of energy and motivation. I can spend days working on it non-stop. 

However, once I get to a certain point where the project is taking shape, I find it harder to dedicate time and stay focused/motivated.

Basically when I get to the polishing, modifying, or adding features portion of the journey; I simply start losing interest. How do you prevent this or push through this plateau? 

Any & all advice are welcome!
How to run action once in Swift
Tags: swift, ios, once
Published: 2019-04-18 19:34:50

---
title: How to run action once in Swift
published: true
description: 
tags: swift,ios,once
---

There are times we want to run an action just once. It would be nice if we can encapsulate this

## dispatch_once

In the Objective-C age, there was dispatch_once that ensures a block of code is run only one time for the lifetime for the application

`dispatch_once` is meant to be used for action that runs once and only once

## Once

Many times, we just want to make an action run once. Encapsulating this prevents scattered boolean flags, and also make the intention clearer

We can have

```swift
class Once {

  var already: Bool = false

  func run(@noescape block: () -> Void) {
    guard !already else { return }

    block()
    already = true
  }
}
```

Then we can use it like

```swift
class ViewController: UIViewController {
  let once = Once()

  override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(animated)

    once.run {
      cameraMan.setup()
    }
  }
}

```

❤️ Support my apps ❤️ 

- [Push Hero - pure Swift native macOS application to test push notifications](https://onmyway133.com/pushhero)
- [PastePal - Pasteboard, note and shortcut manager](https://onmyway133.com/pastepal)
- [Quick Check - smart todo manager](https://onmyway133.com/quickcheck)
- [Alias - App and file shortcut manager](https://onmyway133.com/alias)
- [My other apps](https://onmyway133.com/apps/)

❤️❤️😇😍🤘❤️❤️
What's the best thing anyone has ever said to you at work?
Tags: discuss, career
Published: 2019-04-18 19:28:45

---
title: What's the best thing anyone has ever said to you at work?
published: true
description: "when you enter a bar, do you order 0 beers to see if something explodes?"
tags: #discuss, #career
cover_image: https://images.unsplash.com/photo-1464979681340-bdd28a61699e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80
---

This morning on a bug ticket, the dev that fixed it said

> @desirottman when you enter a bar do you order 0 beers to see if something explodes?

It struck me as maybe the best and funniest thing anyone has ever said to me at work and came during a week that I sorely needed a laugh!

### What's the best thing anyone has ever said to you at work?
Changelog: DEV Connect Open Inbox!
Tags: changelog, meta
Published: 2019-04-18 19:26:25

As many of you know, [DEV Connect](https://dev.to/connect/) is an on-platform messenger that allows you to chat with other DEV members. Since its [launch](https://dev.to/ben/changelog-announcing-dev-connect-beta-1i5f) last year, DEV Connect has only allowed users that mutually follow each other to have direct chats. 

Earlier this year, @bgadrian opened a wonderful feature request that proposed adding a way to optionally open your inbox to incoming messages from all users. We thought it was a great idea and began working on adding that functionality. 

{% github https://github.com/thepracticaldev/dev.to/issues/1460 %}

**Open inbox is now available**. To open your inbox, go to your [Misc Settings](https://dev.to/settings/misc), select the "Open" option, and if you'd like, type up a short guideline for those looking to get in touch with you. You can always change your settings back to private at any time.

![change-settings](https://thepracticaldev.s3.amazonaws.com/i/iv2o51m9m9evyp2u1pe8.gif)

When viewing a user profile with an open inbox, clicking the chat button will open up a modal with their guidelines and a textarea for you to draft your opening message. 

![new-message](https://thepracticaldev.s3.amazonaws.com/i/t6zv8ai0v1p2fsoy0654.gif)

@nickytonline also had a wonderful suggestion to make it easier to navigate to a particular chat on DEV Connect. Now when you view the profile of a mutually followed user, clicking the chat button will take you straight to that Connect chat.

{% github https://github.com/thepracticaldev/dev.to/issues/1567 %}

![hi-ben](https://thepracticaldev.s3.amazonaws.com/i/4yunz7h1ui2yujh59jhl.gif)

With an open inbox, you're putting yourself out there. To prevent spam and abuse, we've added Block and Report Abuse buttons directly into DEV Connect. Blocking closes the chat and prevents that user from opening a new chat--even when you keep your inbox open. Note that blocking is only on DEV Connect (not site-wide).

![hi-peter](https://thepracticaldev.s3.amazonaws.com/i/p1fz21x1tbbb0fcgpmgg.gif)

This feature is brand new, so if you run into any bugs, please tell us in the [GitHub repo](https://github.com/thepracticaldev/dev.to).
Anyone Have Best Headphones For Meetings In Public Places?
Tags: discuss, productivity
Published: 2019-04-18 18:30:22

---
title: Anyone Have Best Headphones For Meetings In Public Places?
published: true
tags: discuss, productivity
cover_image: https://thepracticaldev.s3.amazonaws.com/i/9y0hjwz1upscvkyxyvy2.jpg
---


So I volunteer remotely for a non-profit and often have to do meetings in public places (because I choose to schedule them during break hours at times).

However, the background noise of these places interferes with the video/voice software and I am constantly having to mute my mic and unmute it.

It can be a little frustrating! And it's hard for my team members to hear me. 


I'd love to hear people's suggestions of headphones that can help with these problems!
Promise To Myself
Tags: beginners, webdev, career
Published: 2019-04-18 18:02:55

---
title: Promise To Myself
published: true
description: This is my promise to myself.
tags: #beginner #webdev #career
---

I'm going to become a programmer. Because I'm programming everyday. I squeeze it in every chance I get. It's a lot of work ontop of life, on top of my responsibilities. But, I've never wanted something more in life. 

I will become a programmer, because I won't rest. I won't be able to live with myself until I get to my goal!
Cognitive Empathy: Walking in Their Shoes
Tags: career, advice
Published: 2019-04-18 16:36:21

Have you ever wondered what a situation looks like from another participant's perspective? Perhaps you have found yourself asking yourself what another person is going through and trying to understand how they're feeling in that moment. This is Cognitive Empathy, or our ability to identify and understand other people’s emotions.

Cognitive Empathy is the base block of your empathetic building blocks. In the end, instead of thinking about how we would like to be treated in a given situation, we need to think about how the other person would like to be treated in a given situation. This form of empathy is one of the ways we can achieve doing this.

Cognitive Empathy can also be viewed as "perspective taking," or taking a walk in another person's shoes. Let's take a look at a work example to understand what this means:

"A colleague is sad because the project they were leading had been de-prioritized for other work. You knew that the project did not have very well defined specifications and had a high chance for failure, so you don't understand at first why your colleague is sad!

But then you stop and ask yourself what your colleague is thinking right now. You realize that despite the high risk for failure, this project was a great way for them to display their professional growth regardless of the outcome. In fact, it's possible that any successes would have provided even stronger justifications for how much they have grown and how capable they are. You now understand that, regardless of the stress relief that comes from the project being de-prioritized, your colleague feels sad because they won't get this opportunity to prove themselves in a challenging situation."

Cognitive Empathy is a not easy to utilize, and takes a lot of practice. You need to practice removing your biases and opinions from the situation, which gets harder the closer we are to the other person. It can also feel like the perspective taking is more akin to mind reading, which leads to misses on your part or a desire to pin down a person's mind set perfectly.

Instead, I invite you to consider that, rather than trying to read someone's mind, you instead try to feel the way that person is feeling after you understand what they are feeling. This is Emotional Empathy, which we will discuss in my next post.
From a little idea for a little project to a brand new project
Tags: laravel, php, javascript, osm
Published: 2019-04-18 16:16:09

---
title: From a little idea for a little project to a brand new project
published: true
description: How www.thedatapond.net was born
tags: laravel, php, javascript, osm
---

How [The Data Pond](https://www.thedatapond.net) was born.

![The Data Pond](https://thepracticaldev.s3.amazonaws.com/i/vj49pqj04wsa7tqavlid.png)

While working on a side project, I was looking for a way to get a list of restaurants in a given city. I needed a list of websites for a particular type of business (restaurants) in order to check which kind of technology they use and which kind of server they need. I did extensive research and found nothing satisfactory.


So I tried to get this information from Google Maps and Foursquare until I read their terms of service. Obviously, data from services such as Google Maps or Foursquare can not be used extracted. For example, the Google Maps Terms of Service (3.2.4) states "Customer will not extract, export, scrape, or cache Google Maps Content for use outside the Services".

Then I tried OpenStreetMaps and found what I was looking for: a list that could be used without constraints. However, it is quite difficult to extract these data. That's when I decided to create a tool to automate the process.

If you want to get data from the map, the procedure is pretty simple : you draw a geographic zone on the map, define your parameters (categories, keywords...) and you get a list of names, addresses, websites, telephone numbers...


The data you get are not as rich as data from services like Google Maps or Foursquare but, at least, it is legal to use them (ODC Open Database License).

The website is not completely finished, there are still 1000 things to do: design, typo, features, improve lists... but the idea is to continue development based on comments or requests from users.

You can try it out with the [demo](https://www.thedatapond.net/mew-demo).