teleren/devto huggingface dataset:
Giving Go another chance: more ambitious parsing
Tags: go, timetracking, cli
Published: 2019-01-23 22:48:12

---
title: Giving Go another chance: more ambitious parsing
published: true
description: I'm writing a simple time tracking tool and rediscovering Go at the same time.
tags: go, time tracking, cli
series: Making a time tracking tool in Go
---

Last time I was able to add some simple command line switches and it was easy. Now let's try something harder. First of all I'd like to be able to override the current time with a user specified one. I'd like to able to log a task at a specific time. Sometimes I'm so itching to get something done, that I forget about all those good habits I'm trying to acquire and start hacking right away. Later I realize that I forgot to log a task I'm working on. With [timetrap](https://github.com/samg/timetrap) it's quite easy to start a task 15 minutes ago instead of now:

```
$ timetrap in --at '15 min ago' 'Implementing --at parsing'
```

I'd like to be able to do exactly the same. I looked around and found a library with ungogleable name [when](https://github.com/olebedev/when). Actually, Go also is tough to google. I wonder if Google had to hack their algorithms to promote their language when people look for Go.

With some copying from the README and minor googling I was able to get it done in under 10 minutes. Not bad at all.

```go
import (
    "github.com/olebedev/when"
    "github.com/olebedev/when/rules/common"
    "github.com/olebedev/when/rules/en"
)

func parseAt(at string) time.Time {
    now := time.Now()
    if len(at) == 0 {
        return now
    }

    w := when.New(nil)
    w.Add(en.All...)
    w.Add(common.All...)

    parsed, err := w.Parse(at, now)
    if err != nil || parsed == nil {
        fmt.Printf("Don't know how to parse '%s'\n", at)
        os.Exit(1)
    }

    return parsed.Time
}
```

Next I wanted to add some tags with `--tag/-t`. The tricky thing is, I want to be able to repeat this flag many times, if I wanted to.

```
$ klk in -t coding -t tests "Writing some tests"
```

It turned out to be quite easy with Cobra. I didn't have to write much code for that. I compensated with a lot of googling, though.

```go
// Declare a variable
var tags []string

// Add a flag
inCmd.Flags().StringSliceVarP(&tags, "tag", "t", []string{}, "tags to use with this entry")
```

I could even do `-t 'tag1,tag2'` instead of `-t tag1 -t tag2` now. It's important to save keystrokes. No one wants to type when they don't have to, and I don't want people to abandon my software when they see how much they need to type.

This thing is really taking shape now. It's got custom timestamp and tags. It's already much better than Microsoft Project.

---

Google searches that went into getting this to work:

- go natural language date
- go check string empty
- go cobra repeated flag *(led to a lot of reading on Github)*
- golang strings

---

Time spent: 20 minutes
Total time spent: 5:35 hours
Redesigning Dev.to part On1 (1min Introduction) :)
Tags: css, html, design, uiux
Published: 2019-01-23 22:22:46

---
title: Redesigning Dev.to part On1 (1min Introduction) :)
published: true
description: Let's rebuild dev.to to something more friendly and beautiful :)
cover_image: https://thepracticaldev.s3.amazonaws.com/i/ox288r2ew3wxzf8t112l.PNG
tags: CSS, HTML, Design, UI/UX.
---

Yeah! you probably might be thinking: "Okay it's ugly so what?" Yes, it is! but it won't be any longer after we are going to rebuild it to something more pleasant to the HUMAN DESIGN :).

Now I'm not saying dev.to is one of the ugliest design out there, NO! this is for learning purpose, it is aimed for teaching about good UI/. and you guessed it right: UX, it's very popular these days you Know :) User's interface and experience.

__So what are we building in this short tutorial?__
 -we are redesigning dev.to user interface.

__Cool! what are the processes?__
as follows:
1) we will wireframe dev.to (Using Balsamiq) - not necessary
2) we will dive right into AdobeXD(or invision) and put colors and stuff.
3) we will then code it up. STATIC! no, react :).

__Okay! nice, what are the tools required for this short tutorial?__
 -Balsamiq mockup. You can get it following this link: https://balsamiq.com/wireframes/desktop/
 -AdobeXD(sketch for Mac user's). It's free :) Adobe made it free for Windows users. get it here: https://www.adobe.com/products/xd.html
 -Finally, I'll be using vsCode. Feel free to use whatever you like :)

alright, people, that's it, you know we can skip the whole Balsamiq process and just dive right into adobeXD. Hmmm, let me know what you think in the comment section. _And this is my first post, just joined_ :) Okay get these things ready and wait for part tw2. see yah :).
Screenshot for Mac!
Tags: osx, screenshots, apple
Published: 2019-01-23 22:54:25

---
title: Screenshot for Mac!
published: true
tags: os-x,screenshots,apple
canonical_url: 
---

#### Available in Mojave (OS X 10.14)

![](https://cdn-images-1.medium.com/max/1000/0*PU9L62nQX7YNu_sm)<figcaption>Macbook with code — Photo by <a href="https://unsplash.com/photos/B3l0g6HLxr8?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Blake Connally</a> on <a href="https://unsplash.com/search/photos/macbook?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption>

I was dragging my feet after seeing my coworkers and internet friends get “Mojaved”, a catch-all term for issues experienced after upgrading to the latest, greatest MacOS. Ain’t nobody got time for that.

So far, so good, but right away I noticed something different in my menu bar.

![](https://cdn-images-1.medium.com/max/1024/1*pQSLTuPkr42j2eleLVubqw.png)<figcaption>“Grab” is now “Screenshot”</figcaption>

I take screen grabs all the time. Full screen, windows, partials, all of the above. I’ve used MacOS’s “Grab” since I started using a MacBook Pro in college. But now it looks like I have a new app — “[Screenshot](https://support.apple.com/en-us/HT201361#mojave)”.

Screenshot has all the same features as Grab, plus more! Not only can you take pictures, you can record your entire screen or a portion of your screen, something I typically did in QuickTime Player or a Webex/Zoom meeting by myself.

If you are looking for Screenshot, it’s probably in your Applications > Utilities > Screenshot.

Bye Grab, I’ll miss you. ❤️

![](https://cdn-images-1.medium.com/max/190/1*h64t20SWV9yfg7Oh99EY4A.png)<figcaption>Grab, MacOS’s previous screen shot utility</figcaption>
Redux Devtools extension and Laco
Tags: react, javascript, state, redux
Published: 2019-01-23 22:03:48

---
title: Redux Devtools extension and Laco
published: true
description: Laco can be used with Redux Devtools to debug actions and look into the global state object of Laco.
tags: #react, #javascript, #state, #redux
---

*For a short introduction to Laco please check out my [previous post](https://dev.to/deamlabs/simple-react-state-management-with-laco-2e93).*

Getting an overview of actions, when they are fired and what happens to the global state object can really help debug a complex and big project.

[Redux Devtools](https://github.com/zalmoxisus/redux-devtools-extension) is an extension that provides an user interface where you can get an overview of actions. You can even skip and jump to actions which is usually called "time travelling". You can also see the global state of the whole app and look into each store. The global state even changes when you jump between actions.

Redux Devtools works out of the box with Laco in development mode. There are just some features missing that you normally would have when using Redux. Although Laco works with the most important features such as time travel and being able to look into the global state object.

[Laco](https://github.com/deamme/laco) is similar to Redux and operates on a global state behind the scenes. Each store has been given a unique id to the global state object which you can check out in Redux Devtools. You can also get the global state by doing:
```javascript
import { Store, getGlobalState } from 'laco'

const CounterStore = new Store({ count: 0 })
const ToggleStore= new Store({ toggle: false })

getGlobalState()
// Outputs an object:
// {
//   "0": { count: 0 },
//   "1": { toggle: false },
// }

```



To see which actions belong to what stores we need to initialize a store with a given name like so:

```javascript
import { Store } from 'laco'

const CounterStore = new Store({ count: 0 }, "CounterStore")

```

Otherwise you would only see the action name in the Devtools but not which stores the action changed.

To actually make a given action show up in the Devtools you also need to give it a name when calling `set()` on a store:
```javascript
import { Store } from 'laco'

const CounterStore = new Store({ count: 0 }, "CounterStore")

// Implementing some actions to update the store
const increment = () => CounterStore.set(state => ({ count: state.count + 1 }), "Increment");
const decrement = () => CounterStore.set(state => ({ count: state.count - 1 }), "Decrement");
```
Since it is a string passed to the second argument of the `set()` method you can even provide more info if needed - it doesn't have to be a "name".

That's basically it! Below is a GIF showing the powers of Redux Devtools:

![Laco with Redux Devtools](https://im5.ezgif.com/tmp/ezgif-5-3d0da270acd1.gif)

Check out the [code sandbox](https://codesandbox.io/s/6l7on1m473) to try it yourself. :)
Prettier with Lighting Web Components
Tags: lwc, prettier, salesforce, video
Published: 2019-01-29 05:19:28

---
title: Prettier with Lighting Web Components
published: true
tags: LWC,Prettier,Salesforce,video
canonical_url: https://wipdeveloper.com/prettier-with-lighting-web-components/
cover_image: https://wipdeveloper.com/wp-content/uploads/2019/01/Screen-Shot-2019-01-25-at-3.50.46-PM.png
---

{% youtube OdLXYjHuzqc %}

Hello I’m Brett with WIPDeveloper.com. If you’ve been working with Lightning Web Components in Visual Studio Code with the Prettier extension installed, you might have encountered issues where he tried to assign a property to an attribute on your HTML.

## A Prettier Problem

If I try to change the title from the string of web developer calm to the property label it’s going to reformat it and cause issues. I’m gonna hit save now I have an issue where it’s Prettier has automatically inserted quotes around my property.

The Lightning Web Component linter is saying that you should not have quotes around your property names to prevent Prettier from automatically inserting double quotes around your Properties on your HTML templates in your lightning lab components.

We are going to have to tell Prettier to ignore the HTML files. We can do that in our project so we don’t have to uninstalled the extension.

## A Prettier Solution

We create a new file called `.prettierignore`

now we’re going to do more than just ignore the HTML files actually got this from René Winkelmeyer and I hope he’s okay with me saying his name he works at Salesforce as a dev evangelist. This is a pretty or ignore file from one of the Trailhead example apps.

And I’m going to it’s what it’s going to do is it tells Prettier to ignore CSS, HTML, SVG files, XML files, and anything in the `.sfdx` folder so Prettier will not check the formatting on those.

All we do is add that to our `.prettierignore` file. Now when we remove the double quotes,

We press save. it did not work. What did I spell wrong?

Where did I create the `.prettierignore` file

You have to create it at the base of your project I was not paying enough attention.

Now we can delete the double quotes.

Press Save it prettier did not re insert the double quotes. The lender does not have problems with our syntax and we can carry on with using

properties from our web component in attributes, I will provide a link for the example `.prettierignore`, I’ll also have the entire contents below.

#### `.prettierignore`

```
**/lwc/** /*.css
**/lwc/** /*.html
**/lwc/** /*.svg
**/lwc/** /*.xml
.sfdx
```

## Links

- [.prettierignore Example](https://github.com/trailheadapps/purealoe-lwc/blob/master/.prettierignore)
- [René Winkelmeyer](https://twitter.com/muenzpraeger) 

## That’s it for now.

Remember to sign up for **[The Weekly Stand-Up!](https://wipdeveloper.com/newsletter/)**  and you can get updated with any new information we have on WIPDeveloper.com.

The post [Prettier with Lighting Web Components](https://wipdeveloper.com/prettier-with-lighting-web-components/) appeared first on [WIPDeveloper.com](https://wipdeveloper.com).
Announcing csv2ics
Tags: javascript, csv, ical
Published: 2019-01-23 20:29:04

I'm somehow always [fiddling with automating calendar events](https://dennis.dieploegers.de/flying-high-on-ical-files/) and now I even have to deal with ICS *and* CSV files!

Some background: I'm acting in an amateur theatre community and also manage their internal communications tool. In this tool, all rehearsals, shows and meetings are presented.

However, my fellow actors and the directors are not that tech-savvy to fill in the calendar by, i.e. exporting ical files from their google calendars and import them.

Instead, they wrap up an excel sheet with all events for the coming season.

And so, here we are with a CSV file.

I've searched through various csv to ics converters, but I haven't found one, that served all my needs. I especially needed to create custom vendor fields, that none of the tools I found supported.

So I created my own.

It's called csv2ics (creative, eh?) and you can find it on [GitHub](https://github.com/dploeger/csv2ics) and [NPM](https://www.npmjs.com/package/csv2ics). Check out its [README.md](https://github.com/dploeger/csv2ics/blob/master/README.md) for details.

{% github dploeger/csv2ics %}
Basics of Object Design - Introduction
Tags: objectorienteddesign, beginners, softwaredesign
Published: 2019-01-23 20:58:41

---
title: Basics of Object Design - Introduction
published: true
description: 
tags: ObjectOrientedDesign, Beginners, softwareDesign
cover_image: https://www.colourbox.com/preview/7724015-simple-seamless-pattern-with-damask-motifs-in-black-and-white-drawn-with-short-strokes-texture-for-web-print-holiday-decor-textile-design-fabric-wrapping-paper-invitation-background-wallpaper.jpg
series: Basics of Object Design
---

On 3rd January, I revisited some projects I had worked on in the past. Almost every code from each project follows the object-oriented paradigm. Even though, it has not really come to mind how I actually write code for software projects. Mostly, I follow to choose some patterns and then follow that approach for both design and implementation. However, there is one thing that runs through almost every project and that is, every application is designed around objects.  

In order to get better at designing and creating objects within a software project, I got this book, [Style Guide for Object Design](https://leanpub.com/object-design) from [Matthias Noback](https://twitter.com/matthiasnoback). I have started reading it this week. For now, I can frankly say, it is an amazing book. I will be sharing my learnings from the book with you through a series of blog posts. Once we go through the series of posts, we will be much equipped with the right fundamentals on how to design and create objects for simple and complex applications.
Code quality is overrated
Tags: startup, culture, productivity, programming
Published: 2019-01-23 20:10:18

---
title: Code quality is overrated
published: true
description: Spending time on code quality is a privilege - one that must be earned by building a product that people love.
tags: startup, culture, productivity, programming
---
If you're like me, you worry a lot about whether the code you write is "good enough".

For the past year I've been building [Gush](https://gush.com), a personalized guide for things to do in NYC, which is currently in private beta. I'm constantly asking questions like "is this properly abstracted?", "does this have enough documentation?", "is this easy to reuse?", "is this maintainable in the long term?", or "is there a smarter way to write this?". Answering these questions is a valuable exercise, no doubt.

But Gush's future is uncertain. Code quality doesn't matter if we fail to gain user traction. I've had to learn to stop improving my code a bit earlier than I might like, because user's don't care how good the code is. For situations like mine, I think "code quality" needs a slightly different definition.

The first measure of code quality should be "does it work?". The next most important measure of quality is "does it provide an excellent experience for our users?". Until you prove that your product has traction, all other measures of quality are nice-to-have's. 

Spending time on code quality is a privilege - one that must be earned by building a product that people love.

I'm not advocating sloppy code. I care about code quality and I do everything in my power to avoid accumulating tech debt. But for early stage projects, you have to find a balance, and that balance isn't always pretty.
Why is Rails ActiveRelation.update_all updating a different set of records?
Tags: ruby, rails, help
Published: 2019-01-23 20:02:45

---
title: Why is Rails ActiveRelation.update_all updating a different set of records?
published: true
description: ActiveRecord magic got me like whaaaaaaat?
tags: ruby, rails, help
---

I've got a weird case of `ActiveRecord_Relation` magic doing something unintended. Given the following:

```ruby
comment = Comment.find(params[:id])
# select only the original commenter's comments that match two scenarios
related_comments = comment.where(something: params[:something)
  .union(comment.where(something_else: params[:something_else]))
  .where(user_id: comment.user_id)

related_comments.count
#=> 4
# This is to demonstrate how many records I'm intending to update.
# Using .length would work too, for example's sake.

related_comments.update_all(receive_notifications: true)
#=> SQL (3.9ms)  UPDATE "comments" SET "receive_notifications" = 't'
#=> WHERE "comments"."user_id" = $1  [["user_id", 11]] [sql_query]
#=> 12
```

From the looks of it, `.update_all` is running a single SQL query that is updating all comments with a `user_id` of 11. The `.where(user_id: 11)` was technically the last query, but shouldn't it be running a SQL query for only the relations of `related_comments`?

I have a workaround where I could do this, but it would require two SQL queries and seems overly cumbersome than necessary:
```ruby
comment = Comment.find(params[:id])
# same as above
related_comment_ids = comment.where(something: params[:something)
  .union(comment.where(something_else: params[:something_else]))
  .where(user_id: comment.user_id).pluck(:id)
#=> [12, 14, 17, 18]

Comment.where(id: related_comment_ids).update_all(receive_notifications: true)
#=> SQL (5.7ms)  UPDATE "comments" SET "receive_notifications" = 't'
#=> WHERE "comments"."id" IN (18, 14, 17, 12) [sql_query]
#=> 4
```
The unexpected after_commit behaviour
Tags: rails, ruby, callbacks
Published: 2019-09-30 12:08:19

---
title: The unexpected after_commit behaviour
published: true
description: The Rails callbacks after_create_commit, after_update_commit and after_destroy_commit behave in a way you may not expect.
tags: rails, ruby, callbacks
canonical_url: https://www.kostolansky.sk/posts/unexpected-after-commit-behaviour/
---

Today I've learned something interesting. The new Rails callbacks `after_create_commit`, `after_update_commit` and `after_destroy_commit` can behave in a way I didn't expect.

The `after_commit` callback is a well-known part of the Ruby on Rails framework. It's called after a record has been created, updated, or destroyed and after the corresponding database transaction has been commited. It's the primary method to use if we want to trigger a background job associated with a record.

```ruby
class User < ActiveRecord::Base
  after_commit :schedule_welcome_email, on: :create  

  def schedule_welcome_email
    WelcomeEmailJob.perform_later(id)
  end
end
```

The Ruby on Rails 5 came with some new `after_*_commit` callbacks. Before it looked like this:

```ruby
after_commit :action1, on: :create
after_commit :action2, on: :update
after_commit :action3, on: :destroy
```

And now we can use:

```ruby
after_create_commit  :action1
after_update_commit  :action2
after_destroy_commit :action3
```

## The problem

Let's say we want to trigger the `broadcast` method after a record has been created or destroyed. We can try using the new callbacks:

```ruby
class Comment < ActiveRecord::Base
  after_create_commit  :broadcast
  after_destroy_commit :broadcast

  def broadcast
    BroadcastJob.perform_later(id)
  end
end
```

That looks good! The `after_destroy_commit` works as expected. However, for some reason, the first `after_create_commit` is never triggered. But why?

## The reason

Let's take a look at the source code of the `after_create_commit` method:

```ruby
def after_create_commit(*args, &block)
  set_options_for_callbacks!(args, on: :create)
  set_callback(:commit, :after, *args, &block)
end
```

As you can see, these methods are effectively aliases for the old `after_commit` callback with the `:on` option specified. And subsequent `after_commit` declarations override former declarations for the same method. That can be pretty surprising!

## The solution

To solve this issue, we can use the old callback. The `:on` option supports an array of multiple life cycle events, so the solution is simple and looks like this:

```ruby
after_commit :broadcast, on: [:create, :destroy]
```


---

Original article: [The unexpected after_commit behaviour](https://www.kostolansky.sk/posts/unexpected-after-commit-behaviour/)
Launching WebAuthn.me - Overview & Login Demo
Tags: webauthn, authentication, passwordless, identitymanagement
Published: 2019-01-23 19:22:16

---
title: Launching WebAuthn.me - Overview & Login Demo
published: true
description: Learn about WebAuthn with the interactive playground WebAuthn.me
tags: #webauthn #authentication #passwordless #identitymanagement
canonical_url: https://auth0.com/blog/web-authentication-webauthn-overview-demo-tool/
---

In this article, we will go over the WebAuthn specification and the newest resource, [WebAuthn.me, a fully interactive demo of the WebAuthn spec](https://webauthn.me/). We will go over how the identity scene is evolving and trending towards the mainstream adoption and enablement of strong authentication. Although the username and password combination will not be going anywhere for now, soon we may see more biometrics for authentication purposes...

[Read on 🔑](https://auth0.com/blog/web-authentication-webauthn-overview-demo-tool/?utm_source=dev&utm_medium=sc&utm_campaign=webauthn_launch)

![Launching WebAuthn.me - Overview & Login Demo](https://thepracticaldev.s3.amazonaws.com/i/evkunb1nyb5m68t8tmt7.png)