teleren/devto huggingface dataset:
Simple Memorization BEYOND
Tags: ruby, beginners
Published: 2018-05-13 16:30:46

---
title: Simple Memorization BEYOND
published: true
description: when smile would be falsy?
tags: ruby, beginner
---

[This REPO](https://github.com/shtakai/simple-smile)

[From last post](https://dev.to/alyson/simple-memorization-36ic),
there's a question. `memorization on falsy case.`

Thank you  @jakebman. :)

I changed code.

```ruby
clas Smile
  SmileError = Class.new(StandardError)

  attr_accessor :smile

  # @smile is false on initialization.
  def initialize
    @smile = false
  end

  def ensmile(cry: false)
    @smile ||= begin
      puts 'memorize start'
      raise SmileError if cry
      puts 'memorize success'
      "SMILE"
    rescue SmileError
      puts 'memorize fail'
      "CRY"
    end
  end
end

(spec file is same)
```

And ran `rspec`

```terminal
FF

Failures:

  1) Smile#ensmile returns "SMILE"
     Failure/Error: expect(smile.smile).to be_nil

       expected: nil
            got: false
     # ./spec/smile_spec.rb:8:in `block (3 levels) in <top (required)>'

  2) Smile#ensmile returns "CRY"
     Failure/Error: expect(smile.smile).to be_nil

       expected: nil
            got: false
     # ./spec/smile_spec.rb:14:in `block (3 levels) in <top (required)>'

Finished in 0.04088 seconds (files took 0.48848 seconds to load)
2 examples, 2 failures

Failed examples:

rspec ./spec/smile_spec.rb:7 # Smile#ensmile returns "SMILE"
rspec ./spec/smile_spec.rb:13 # Smile#ensmile returns "CRY"
```

It's okay because of `false` after initialization.
Just fix spec file.

```ruby
--- a/spec/smile_spec.rb
+++ b/spec/smile_spec.rb
@@ -5,13 +5,13 @@ RSpec.describe Smile do
   let(:smile) { described_class.new }
   describe '#ensmile' do
     it 'returns "SMILE"' do
-      expect(smile.smile).to be_nil
+      expect(smile.smile).to be_falsy
       expect(smile.ensmile).to eq 'SMILE'
       expect(smile.smile).to eq 'SMILE'
     end

     it 'returns "CRY"' do
-      expect(smile.smile).to be_nil
+      expect(smile.smile).to be_falsy
       expect(smile.ensmile(cry: true)).to eq 'CRY'
       expect(smile.smile).to eq 'CRY'
     end
```

Then re-ran `rspec`.

```terminal
Finished in 0.00841 seconds (files took 0.4119 seconds to load)
2 examples, 0 failures
```

Okay. And check on pry.

```ruby
1) nil
2.4.0 (main):0 > a=nil
=> nil
2.4.0 (main):0 > a ||= 'cat'
=> "cat"
2.4.0 (main):0 > a
=> "cat"

b) false
2.4.0 (main):0 > b=false
=> false
2.4.0 (main):0 > b ||= 'dog'
=> "dog"
2.4.0 (main):0 > b
=> "dog"

3) already set to Object something
2.4.0 (main):0 > r='roo tiger'
=> "roo tiger"
2.4.0 (main):0 > r ||= 'nwo'
=> "roo tiger"
2.4.0 (main):0 > r
=> "roo tiger"
```

If I'd like to keep `false` on initialize, it is not working.... :cry:

TIL: don't do under falsy condtion and don't do in your home.
VSCode Theme Highlight-able Indent Guides FTW 💯
Tags: vscode, code, vscodetheme
Published: 2018-05-13 14:07:29

---
title: VSCode Theme Highlight-able Indent Guides FTW 💯
published: true
description: VSCode 1.23 just got released and now you can style the active indent guides. 😲 VS Code can now highlight the active indent guide, as you move your cursor between various source code blocks. The color name is `editorIndentGuide.activeBackground`.
tags: vscode, code, vscode theme
---



VSCode `v1.23` just got released and now you can style the active indent guides. 😲 VS Code can now highlight the active indent guides, only if your VSCode theme has support for that. 

>So, as you move your cursor between various source code blocks. The color name is `editorIndentGuide.activeBackground`.
![VSCode.pro](https://on.ahmda.ws/rYBv/c)


## 🔥[Shades of Purple for VSCode](https://marketplace.visualstudio.com/items?itemName=ahmadawais.shades-of-purple)

As soon as this feature was released, I update my 💜Purple theme called [Shades of Purple for VSCode](https://marketplace.visualstudio.com/items?itemName=ahmadawais.shades-of-purple) which you can use right now and get most out of your 🆚Code :)

- For the theme authors use this editorIndentGuide.activeBackground: Color of the active editor indentation guide.
- For users, try [Shades of Purple for VSCode](https://marketplace.visualstudio.com/items?itemName=ahmadawais.shades-of-purple)
- I shared this as a [VSCode Tip](https://vscode.pro/tip/7)→
- I shared a GIF on Twitter.


{%tweet 992141467228491776 %}

Peace! ✌️
An Introduction to Event Sourcing for Rubyists
Tags: ruby, rails, eventsourcing, ddd
Published: 2018-05-13 09:36:13

---
title: An Introduction to Event Sourcing for Rubyists
published: true
description: Video here https://skillsmatter.com/skillscasts/11903-an-introduction-to-event-sourcing
tags: ruby, ruby on rails, eventsourcing, ddd
---


Video here: https://skillsmatter.com/skillscasts/11903-an-introduction-to-event-sourcing

Slides here: https://speakerdeck.com/mottalrd/an-introduction-to-event-sourcing-for-rubyists

Code here: https://gist.github.com/mottalrd/52a99a0a67275013df5a66281a4a1b11

Event sourcing is a design pattern to build applications that are domain centric and easy to extend. The pattern is based on the usage of a persistent event log which substitutes the more classical relational database model for Rails applications.

Last week I gave this presentation at the London Ruby User Group. You can find the details of what I learned over the last year using such pattern, hope you enjoy it!
The best Easter Egg you ever did leave
Tags: eastereggs, discuss
Published: 2018-05-13 07:15:28

---
title: The best Easter Egg you ever did leave
published: true
description: discussion about the best Easter Egg you've ever left or found in an application or code base. 
tags: Easter eggs, discuss
---

Where I work, a developer left an Easter Egg long ago where if you came to our ERP self service dashboard by way of 302 and had an expired SSO cookie, you'd be greeted by a little page saying "Dude, you got no cookie." Luckily it was a rare occurrence, and flew under the radar for a long long time. 

Recently I reimplemented that middleware component. Part of the project requirement was removing that message. To keep the spirit of the Easter egg alive though, I have Dude you have no cookie written to the console instead. I feel good about what I've done. I think Easter Eggs in code are an important part of the job.

Does anyone have a story about an Easter Egg they've written or found that was particularly delightful?
Telegram user responses to database/form. Any recommendations?
Tags: help, bot, integration
Published: 2018-05-13 06:36:36

---
title: Telegram user responses to database/form. Any recommendations?
published: true
description: 
tags: help, bot, integration
---

I'm building out a telegram bot that takes answers given to questions from a user and submits them "somewhere" for a client to read through, search, filter etc.

Obviously a database would normally make sense, however I'm really not wanting to build out a bunch of database integration and also then a nice little UI for a user to view the responses received.This is a proof of concept project.

I was thinking of using something like google sheets to act as the "database" and UI. Whilst this would work nicely, once again the integration and setup into Google is a slight pain generating keys or oAuth etc for a simple task.

I fully expect there is a service that will allow a nice and easy POST request to an API which will then also allow a user to view / search / edit the data behind the scenes without much integration work being needed.

This is really about wanting to keep to MVP and not go overboard straight away until we have confirmed that the customer would like to continue on, we can then look to enhancing.

Any recommendations?
Shopoji - Pusher Presence Channels are cool
Tags: pushercontest, inprogress
Published: 2018-05-13 02:16:11

---
title: Shopoji - Pusher Presence Channels are cool
published: true
description: So I'm rewriting my app a week before the deadline
tags: pushercontest, inprogress
---

The original vision for this app was a single player shop game that was minorly affected by other people playing in their own game. Pusher public channels seemed to fit this use case nicely.

Though any time I wanted to do something cooler, it was locked behind Pusher presence channels. 

So... I guess I'm rewriting my app logic.

If I can't get it to work, I'll submit what I have. It has solid MVP (*minimum* viable product) features enabled, an [information site](http://shopji.xyz), and a playable demo (that right now is pointed to a broken dev branch so no touchy pls), but there's so much more that would just be better intuitively with Presence channels.

1. I could do client triggers
2. I could give a little more context to my triggered messages regarding who all is triggering them
3. Most importantly, I can fix a pretty large logic bug in my global market by knowing how many shops are in the market at any given time

# What's New

SO MUCH

![Screenshot demo](http://shopoji.xyz/public/assets/img/demo.png)

You can buy more inventory. You can sell your inventory. You can make money. The UI is now Bootstrap so it isn't too terrible.

# What's Left

Once I rewrite stuff to be more presence-y, I'm calling it for the competition. There's more on the to-do list, but I'll be at the point of diminishing returns.

Though seriously, if I can't get auth working for presence channels within like an hour tomorrow I'm calling it done for now 😛 Scope creeeeeeeeeeeep.
Is their any API where I could get all my posts from the site?
Tags: help, site
Published: 2018-05-13 01:12:53

---
title: Is their any API where I could get all my posts from the site?
published: true
tags: help, site
---

Hey guys, I’m thinking on killing the blog on my site and just publishing my content here. But, I’d still like to fetch all my posts and display them in my site. Any idea if there’s an endpoint to get them?
What is a system?
Tags: discuss
Published: 2018-05-12 18:03:38

---
title: What is a system?
published: true
description: 
tags: discuss
---

I never feel 100% certain what people mean when they use the word “system”. It’s not that I don’t know what they are trying to communicate, but I’m often unsure what people specifically mean when they use that word in our industry.

Can someone unpack this for me?
How to get the user id after registering an user in ASP .NET Core Identity
Tags: beginners, aspnetcore, netcore, csharp
Published: 2018-05-12 16:08:19

---
title: How to get the user id after registering an user in ASP .NET Core Identity
published: true
description: How to get the user id after registering an user in ASP .NET Core Identity
tags: beginner, aspnetcore, netcore, csharp
---

Getting back to work on my side project I got into finishing the user registration trough the API. Following the [JSON API](http://jsonapi.org/format/#crud-creating-client-ids) spec, it requires returning a 201 created and the resource id when creating a database entry.

For somebody used with ASP this might seem trivial but it's not that obvious when creating a new user.

Let's take a simple example:
```csharp
var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
var result = await _userManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
    // do stuff here
}
```

Usually you would think that `result` would somehow contain the user's id but that's not the case.
However, if your operation succeeded, the `user` variable will contain the newly created database properties.

So you can do something like:
```
return StatusCode(StatusCodes.Status201Created, new {
    data = new { id = user.Id }
});
```
Works as shown: Elixir's doctest macro
Tags: elixir, testing
Published: 2018-05-12 15:57:34

---
title: Works as shown: Elixir's doctest macro
published: true
description: A succinct guide to Elixir's doctest macro
tags: #elixir #testing 
---

## What is doctest?

`doctest` is a macro that searches a specified module for code examples and automatically generates test cases.


## Why use doctest?

Primarily to ensure the correctness of your module documentation. Doctest examples are also easy to write, can replace simple unit tests, and provide a standard format for specifying code examples and demonstrating your module's API.

Untested documentation trends toward incorrectness over time and eventually becomes worse than not having documentation at all.

## A small example

```elixir
# lib/small_math.ex
defmodule SmallMath do
  @doc """
  Adds two numbers together.

  ## Examples
    iex> SmallMath.add(1, 2)
    3

    iex> SmallMath.add(5, 7)
    23
  """
  def add(a, b), do: a + b
end

# test/small_math_test.exs
defmodule SmallMathTest
  use ExUnit.Case, async: true
  doctest SmallMath
end
```

### Output

```
$ mix test

Compiling 1 file (.ex)
.

  1) doctest SmallMath.add/2 (2) (SmallMathTest)
     test/small_math_test.exs:3
     Doctest failed
     code: SmallMath.add(5, 7) === 23
     left: 12
     stacktrace:
       lib/small_math.ex:9: SmallMath (module)

Finished in 0.03 seconds
2 doctests, 1 failure


Randomized with seed 888764
```

As we see, doctest generated two test cases from our documentation, one of which failed. 

## How does it work?

`doctest` looks for code examples by searching for lines beginning with `iex>` and evaluates them as if it were a user sitting at the console. Afterward, a line that specifies a bare value (i.e. does not begin with `iex>` or `...>`) is interpreted as a result, and a test is generated to assert that the value specified is what a user would see if they had evaluated the last expression.

```elixir
@doc """
iex> 5 + 5  # expression
10          # result
"""
```

### Multiline expressions

You can use `...>` to build a multiline expression.

```elixir
@doc """
  iex> add_one_fn = fn(number) ->
  ...>   number + 1
  ...> end
  iex> add_one_fn.(5)
  6
"""
```

### Testing for exceptions

Writing an example demonstrating an exception is also supported!

```elixir
@doc """
  iex> 1 + "hello"
  ** (ArithmeticError) bad argument in arithmetic expression
"""
```

## Caveats

Tests generated by `doctest` do not run in isolation of each other. Code that generates side effects is not a good match. Binding variables or defining code inside of a doctest also carries the risk that your code will be reused in another test.
Demoting My Career To Be A Social Agile Coach
Tags: culture, career, agile, coaching
Published: 2018-05-11 15:10:36

---
title: Demoting My Career To Be A Social Agile Coach
published: true
description: I'm at a crossroads where I've decided to take a step back in my career to do agile and culture coaching free online!
tags: #culture #career #agile #coaching
---

After working in corporate America for so many years, **I have a “filter” that I'm trying to lose**.

It’s been hard for me to talk about some of the problems with tech culture that I want to fix online - because I’m used to being a consultant.

I usually have to be _very careful_ what I say due to the company politics at my clients.

My videos might be controversial at some companies...

But someone has to talk about this stuff!

I get tired of trying to help software teams and then having to leave, only to find out later they didn’t implement my recommendations!

But online, I can be completely honest and can help you fix your company without hiring an “agile coach” or someone else like me.

It feels like the purpose of my career at this point, is to share what I've learned from consulting for free online, to help as many people as possible.

I'm probably going to just get a remote senior developer position for now to support my family.

No commute will give me time to make more videos, do live streams, and find other better ways to serve you.

# [📺 Watch on YouTube](https://www.youtube.com/watch?v=dSIdMxhxI-w)

Or listen as a podcast:
[🎧 Soundcloud](https://soundcloud.com/jayme-edwards-media/the-de-corporatization-of-jayme)

<hr />[🔔 Subscribe for 90+ videos on healthy software development](https://YouTube.com/c/JaymeEdwardsmedia?sub_confirmation=1)
How would you convince your company to implement unit tests?
Tags: discuss, career, testing
Published: 2018-05-12 13:40:38

---
title: How would you convince your company to implement unit tests?
published: true
description: You already know how good unit tests can be, but your company doesn't, how would you convince your company to implement unit tests?
tags: discuss, career, testing
---

##Scenario

Suppose you are working in a super cool company, your coworkers are great and your job is fulfilling, but your company doesn't implement unit testing as it doesn't see any benefit from a business point of view.

##What would you do?

As the title asks, how would you convince your company unit tests are beneficial? Would you try to convince from a technical point of view or a business point of view?

It would be great to read your comment!! ☺️☺️☺️
[Entry] Photo Fight Application
Tags: pushercontest, express, photopolling, javascript
Published: 2018-05-12 11:22:16

---
title: [Entry] Photo Fight Application
published: true
description: An app/hack submitted to the first-ever DEV Community contest. 
tags: pushercontest, express, photo-polling, javascript
---

# What I built

{% youtube yxcz9pRJEmY %}

This is a simple live photo polling application which updates the chart in real time and also the count of votes in homepage. This application has admin panel which allows admin to start and stop the competition.

__Admin Login :__ 
email : admin@admin.com
password : 123456789


###*PUSHER CHANNELS:*

I'm using 3 channels in my application :

    
  > Home Channel for updating the homepage vote counts.


  > Admin Channel for updating the poll chart of the admin page.


  > User Channel for informing the owner of a photo when the competition starts or ends.


## Demo Link

https://photo-fight-app.herokuapp.com/

## Link to Code

https://github.com/mashish584/photo-fight-app


# How I built it 

 I used : 
 
 _Express JS for creating the backend of this application._
 _mLab for for hosting Mongo Database._
 _Cloudinary for hosting image files._
 _Pusher API for notifications and live updates._
 _Heroku for app deployment._
   



# Additional Resources/Info 

I learned Pusher, Woaah.

Special thanks to Dev.to team for this contest, Zan Markan for clearing my doubts and Traversy Media for short and simple pusher tutorial intro series.
Cannot call pointer method on Literal
Tags: go, question, help
Published: 2018-05-12 11:09:00

---
title: Cannot call pointer method on Literal
published: true
description: 
tags: golang,question, help
---

I tried to call pointer method on struct literal.

```
package main

import "fmt"

type Greeter struct {
        name string
}

func (h *Greeter) hello() {
        fmt.Printf("hello %s!\n", h.name)
}

func main() {
        (Greeter{"hitoshi"}).hello()
}
```

But it fails with the following message.

```
./hoge.go:14:22: cannot call pointer method on Greeter literal
./hoge.go:14:22: cannot take the address of Greeter literal
```

Applying & operator makes it work. 
According to [stackoverflow post](https://stackoverflow.com/a/25601963/1824552), this is because a literal does not have an address.  

My question is when we apply & operator on a literal, is a instance of the literal created on memory, and is thus allocated an address?
Linux Mail Server
Tags: linux, beginners
Published: 2018-05-12 07:00:27

---
title: Linux Mail Server
published: true
description: 
tags: #linux #beginners
---

1 Linux SMTP Server
2 Mail Service Components
3 Setup Email Server
4 Configure Linux Mail Server
4.1 myhostname
4.2 mydomain
4.3 myorigin
4.4 mydestination
4.5 mail_spool_directory
4.6 mynetworks
4.7 smtpd_banner
4.8 inet_protocols
5 Checking the Mail Queue
6 Test Linux Mail Server
7 Secure Mail Boxes From Spam Using SpamAssassin
8 Securing SMTP Connection
9 Using Let’s Encrypt Certificates
10 POP3 and IMAP Protocol Basics
11 Installing Dovecot
12 Configure Dovecot
13 Secure Dovecot

https://likegeeks.com/linux-mail-server/

Hope you like it.
Regards,
what are the best out-of-the-box solutions for a commenting system?
Tags: commentschatsdk
Published: 2018-05-12 01:52:16

---
title: what are the best out-of-the-box solutions for a commenting system?
published: true
description: I'm looking for a solution to build a commenting system like Facebook has it with nested replies. I prefer a service to easily put things together, such as sendbird, though sendbird doesn't seem to support that usecase. Are there any other popular solutions out there specificity focused on chat / comments to get it done?

tags: comments chat sdk
---
A Collection of Essential Vscode Extensions
Tags: code, editors, extensions
Published: 2018-12-04 12:51:16

---
title: A Collection of Essential Vscode  Extensions
published: true
tags: code, editors, extensions
canonical_url: https://www.giftegwuenu.com/a-collection-of-essential-vscode--extensions/
---


_Code Editors are one of the essential tools for a Developer as long as you write code. But an interesting fact is every developer loves to enhance their workflow and be more productive. I mean why waste time trying to achieve a task when there's a tool to do that. That brings us to the topic extensions for Vscode. These tools go a long way in helping developers maintain their codebase and also promote productivity. Ever since I switched to Vscode I've found the following extensions to be my holy grail. I pretty much can't do without them don't get me wrong I mean they're awesome tools to have around. Let's cut to the chase shall we._

**[PRETTIER:](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)** _is an awesome tool for keeping consistent codebase. It is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary._

![prettier](https://github.com/remimarsal/prettier-now-vscode/raw/master/prettier-now2.gif)


**[ESLINT:](https://github.com/Microsoft/vscode-eslint)**  _i have a love-hate relationship with this tool because it's automated and I get to know what I'm doing wrong at a glance. The extension uses the ESLint library installed in the opened workspace folder. If the folder doesn't provide one the extension looks for a global install version. If you haven't installed ESLint either locally or globally do so by running `npm install eslint` in the workspace folder for a local install or `npm install -g eslint` for a global install._

![esint](https://cdn-images-1.medium.com/max/800/1*W1gdb9Ae62PH0W2ZnquVCg.gif)

**[GITLENS:](https://github.com/eamodio/vscode-gitlens)** _This extension is powerful in ways you can't imagine. It has the ability to provide Git information (most recent commit, list of authors) in CodeLens, on-demand inline blame annotations, a blame explorer, and commands to compare changes with the working tree or previous versions._

![](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/gitlens-preview.gif)

**[VUE 2 SNIPPETS:](https://marketplace.visualstudio.com/items?itemName=sdras.vue-vscode-snippets)**
_This extension will supercharge your Vue workflow. Easily scaffold Vue directives like v-for, v-if, v-show and more without running to the docs to confirm if you got the syntax right._

**[MARKDOWNLINT:](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint)** _Markdownlint is a Visual Studio Code extension that includes a library of rules to encourage standards and consistency for Markdown files. It is powered by markdownlint for Node.js which is based on markdownlint for Ruby._


#### 💡 Awesome Resource for VScode Tips [VSCODECANDOTHAT](https://vscodecandothat.com/)