teleren/devto huggingface dataset:
Weird behavior in Go: encoding/gob
Tags: gob, go, workrecord
Published: 2019-11-01 03:07:56

---
title: Weird behavior in Go: encoding/gob
published: true
date: 2019-10-31 00:00:00 UTC
tags: gob,go,workrecord
canonical_url: https://dannypsnl.github.io/docs/weird-behavior-gob/
---

Consider the following program:

```go
type AState uint8

const (
	S1 AState = iota
	S2
	S3
)
```

This is quite usual in Go. But we want to make it more expressive. So we have:

```go
func (s *AState) ToS1() { *s = S1 }
func (s *AState) ToS2() { *s = S2 }
func (s *AState) ToS3() { *s = S3 }
```

p.s. Replace `ToS1` and others functions with meaningful names since it’s a real case in the product, I don’t want to show them directly.

Now consider a structure:

```go
type Foo struct {
	AState *AState
}
```

With decoding:

```go
	foo := NewFoo()
	var buf bytes.Buffer
	enc := gob.NewEncoder(&buf)
	_ = enc.Encode(foo)
	unmarshalFoo := &Foo{}
	decBuf := bytes.NewBuffer(buf.Bytes())
	dec := gob.NewDecoder(decBuf)
	dec.Decode(unmarshalFoo)
```

Guess what, the field `AState` has `nil` value. This is out of expected. A least, I thought it should be a pointer to `S1` as what `"encoding/json"` does.

We have two ways to solve this.

First, remove the pointer from the field type.

```go
type Foo struct {
	AState AState
}
```

Or we can use `iota + 1`

```go
const (
	S1 AState = iota + 1
        // ...
)
```
SDK Version 10.0.0
Tags: engineering, sdk, version
Published: 2020-09-16 05:50:01

---
title: SDK Version 10.0.0
published: true
date: 2019-10-31 00:00:00 UTC
tags: Engineering,SDK,Version
canonical_url: https://www.loginradius.com/engineering/blog/sdk-version-10-0-0/
---

We're delightfully Announcing SDK Version 10.0.0. This full-version release includes major changes with several improvements and optimizations, the details have been given below. For complete information please visit LoginRadius API documents. New Features Added: Added PIN…

   
[Read On](https://www.loginradius.com/engineering/blog/sdk-version-10-0-0/)
What are your learning plans for November ?
Tags: javascript, webdev, advanced
Published: 2019-10-30 23:58:25

Hi All, 

This is my first post ever, excuse me if something not right in my writings

Just to give little background about my self before I dive into the topic, I have been working in the frontend around 5+ years mostly in the frameworks, started with Angularjs, angular, express and reactjs, typescript, ionic and lot of other  stuffs in this journey. 

I keep wondering whats coming next and where should I focus and invest time to climb up in my career ladder? As many things I see my learning interest, One answer I have found myself to the question is to look at the job openings and their JD to find out whats hot in the market and I try to align myself with my current project or a separate learning and also helps me to prioritize my wish list. 

Recently I came up with a thought has to have set of learning plans for the month and just stay focused on those 1 or two items for the month, rather than trying to attempt too many things or nothing. 

Here is what I have and plans for next month, 

For October: 
 - I did go through nodejs project architecture from this blog post [bullet proof nodejs](https://dev.to/santypk4/bulletproof-node-js-project-architecture-4epf). 
 - implemented CRUD operations with express to build a user management
 
and nothing more than that I can think off.

For next month:
 - would like to concentrate on building nodejs project with express
 - fundamentals of mongodb
 - build REST API with project architecture 
 - upgrade myself to the react 16.8

So my goal are around aligning myself as backend developer and improving on the Frontend skills I have been working. 

Now comes moto behind by writing a blog post like this, 
1. I can keep track my learning and have focus on something by setting a monthly 
goal
2. I can see your goals and directions in the learning, so that I can get improvements for the next month planning
3. And I can keep sharing something with other developers to improve my writing

So help me with your learning plans and views on this,
Whats there in your wish list and may I know why?
Catch Your Suspense Errors
Tags: react
Published: 2019-10-30 23:52:38

Not every promise resolves.
Some are rejected.

So, when we use `React.Suspense` to show loading and loaded states,
We need to consider exceptions as well.

## Error Boundary Crash Course

[Error boundaries](https://reactjs.org/blog/2017/09/26/react-v16.0.html#better-error-handling) were a flagship features of React 16 —
One of the first features to illustrate the potential of the [fiber rewrite](https://engineering.fb.com/web/react-16-a-look-inside-an-api-compatible-rewrite-of-our-frontend-ui-library/).

To use `Suspense` effectively, you have to to make use of `error boundaries`.

## Start with Copy and Paste

The React docs have a [copy and paste-able](https://reactjs.org/docs/error-boundaries.html#introducing-error-boundaries) `ErrorBoundary` component.

You really only need one of these things.
So copy and paste it into your code and customize to your needs.

```jsx
class ErrorBoundary extends React.Component {
  constructor(props) {
    super(props)
    this.state = { hasError: false }
  }

  static defaultProps = {
    fallback: <h1>Something went wrong.</h1>,
  }

  static getDerivedStateFromError(error) {
    return { hasError: true }
  }

  componentDidCatch(error, errorInfo) {
    console.log(error, errorInfo)
  }

  render() {
    if (this.state.hasError) {
      return this.props.fallback
    }

    return this.props.children
  }
}
```

<br />

This one is customized slightly for demos.

- It assumes you don't have a logging service and uses `console.logs`
- It takes a `fallback` prop for custom messages — much like `Suspense`

## Wrap Those Suspense Components

Wrap `Suspense` components with an error boundary to
Handle these three possible states:

- _pending_ — `Suspense fallback`
- _resolved_ — `Suspense children`
- _rejected_ — `ErrorBoundary fallback`

```js
import React from "react"
import ErrorBoundary from "./error-boundary"

const LazyLoadedComponent = React.lazy(() => import("./SomeComponent"))

function MyApp() {
  return (
    <ErrorBoundary
      fallback={
        <div>Stop trying to make fetch happen. It's not gonna happen.</div>
      }
    >
      <React.Suspense fallback={<div>Waiting...</div>}>
        <LazyLoadedComponent />
      </React.Suspense>
    </ErrorBoundary>
  )
}
```

<br />

## This Ain't No 1:1

I see a lot of people immediately jump to wrapping `ErrorBoundary` and `Suspense` together.

It's not a good look.

Separate, they give you nuanced control over your entire view.
Stick layout components in between,
Handle errors closely,
Or have only one `ErrorBoundary` around a bunch of `Suspense` components.

The world is your oyster.
Keep 'em separate and keep control.

## This is The Suspense API

Right now, we're using `React.lazy` to do the work of communicating _pending_, _resolved_, and _rejected_ states to our `Suspense` and `ErrorBoundary` components.

Next, we'll talk about creating our own wrappers to interact with this Suspense API.
WASM passing strings explained.
Tags: webassembly, javascript
Published: 2019-10-30 23:33:47

Today we cannot directly pass strings to WebAssembly, but we can pass a variety of TypedArrays, in other words an array of floats or numbers only. The one I particularly like is Unit8Array, it's an array of numbers that can have a max highest number of 255.
```js
[255, 6, 0]
```
What is also good to know is Utf8 is a map of numbers to characters. 
```js
"my string".charCodeAt(0) //int
```
Given you can lookup a char to an representative int, which correct me if I am wrong, fits within the 0 - 255 range? Either way you get the idea. So char by char you could produce a string to an array of chars,then map each char to utf8 using `charCodeAt`, that's going to give you an array of numbers that WASM can understand and the guest language could convert back. Nice ... An answer worthy of stack overflow, but ehat's that I hear you say 📯, there has to be a better way?

Well let's take a look at two exciting JavaScript built-in APIs I had no idea existed into yesterday,

### TextEncoder ⚡ TextDecoder
[_source MDN_](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder)
TextEncoder takes a stream of code points as input and emits a stream of bytes.

Example bellow encodes and decodes for no good reason.

```js
const encoder = new TextEncoder()
const view = encoder.encode('Hello DEV')
console.log(view); // Uint8Array

const output = someWasmFunc(view); // Uint8Array with some changes

const decoder = new TextDecoder();  // Uint8Array
const str = decoder.decode(output); // String "Hello Dev"
```

The wasm code usage for example in rust, might look like this.

```rust
use std::str;

// some bytes, in a vector, originally the same Uint8Array from above
let sparkle_heart = vec![240, 159, 146, 150];

// We know these bytes are valid, so just use `unwrap()`.
let sparkle_heart = str::from_utf8(&sparkle_heart).unwrap();

assert_eq!("💖", sparkle_heart);
```

That's all for now folks. ♥️
Promises in JS
Tags: promisesjavascriptes6
Published: 2019-10-30 22:34:16

---
title: Promises in JS
published: true
description: the 
tags: promises javascript ES6
---
A promise is an object that may produce a single value some time in the future - either a result or a reason it's not resolved (rejected).

The advantage of promises is that they run asynchronously in the background and it allows your code to run continue execution while the promise waits for a response (a common use case is to interact with API's as there may be some lag time).

You might already be familiar with promises: fetch() is a promise!

Basic syntax for creating a new promise:

```javascript
const promise = new Promise((resolve, reject) => {
  if (true) {
    resolve("it worked!");
  } else {
    reject("error! it did not work");
  }
});

promise
  .then(result => result + " some action taken on returned result")
  .then(
    secondResult => secondResult + " some action taken on the second result"
  )
  .catch(error => console.log("an error occurred", error));
```

Another useful tool is the Promise.all() call, which will take an array of multiple promises and once they have resolved, return all of them at the same time. For example:

```javascript
const oneSec = new Promise((resolve, reject) => {
  setTimeout(resolve, 1000, "One second resolved");
});

const twoSec = new Promise((resolve, reject) => {
  setTimeout(resolve, 2000, "One second resolved");
});

const fiveSec = new Promise((resolve, reject) => {
  setTimeout(resolve, 5000, "One second resolved");
});


Promise.all([oneSec, twoSec, fiveSec]).then(values => {
  console.log(values);
});
```

If you copy and paste all of the above code snippet into your terminal and count off the seconds, you'll notice that after five seconds, all of the values are returned, even though the first two would have taken less time to resolve if they were called individually. 
So the caveat with Promise.all() is that it can return multiple values, but will only return the values after the slowest call has resolved.
You can also see this in action by running the promises without the Promise.all() call. If you then run the Promise.all() it will be instant because they have already run and the result is now stored in the variables.
Playlist Downloader for codewithmosh.com
Tags: github, playlistdownloader, codewithmosh
Published: 2019-10-30 21:15:20

Hello People,

A few months back, I had created this project.

This is a python-based bash script downloader for the video tutorials available at [codewithmosh.com](codewithmosh.com)

The link to the repo [here](https://github.com/garganshul108/Code-With-Mosh-Playlist-Downloader)

Just here to spread the word!

I would love if you contribute and improve the code wherever required!

Hope you like it!
Don't forget to star the repository :)
Happy Coding!
My Most Embarrassing Mistakes as a Programmer
Tags: team, leadership, career
Published: 2019-10-30 20:07:45

My most embarrassing mistakes as a programmer, in no particular order:

* I didn't ask for help
* I was afraid of what others would think
* I didn't follow through on a promise
* I didn't step up and take responsibility
* I avoided conflict
* I didn't encourage others
* I didn't publicly celebrate the success of others

My biggest mistakes had nothing to do with programming.

The most difficult parts of any job, and the most _valuable_ activities of any job, have nothing at all to do with technology.

It's people. How we value ourselves. How we value others.

"Soft skills" is an awful term. The things we call "soft skills," such as listening, communication, team dynamics, empathy, ought to be given so much more priority in our workplaces. These are _core_ skills that apply to anyone in any profession.

Here's the mindset I want. 

> To be the most effective member of any team, I must first strive to model integrity and work ethic. I need to be respectful, helpful, patient, gracious, trustworthy, and hardworking. I need to be transparent, such as asking for help, owning mistakes, and asking forgiveness, regardless of my fear of the outcome, because it's the right thing to do. When I see a failure in our system, not just in the work we create but also our system of work and treatment of people, I need to take responsibility, speak up, and see it through correction. I need to give people the benefit of the doubt, try to understand their perspective and circumstance, be slow to anger, and be quick to forgive. I need to encourage and lift others up and help them to see their career and life through a bigger lens.

I am a work in progress. I may not achieve these things every day, but that's my goal.

I hope this post gets you thinking of ways you can have a positive impact on the people you work with.

Remember, every day is a fresh start to be more awesome!
Angular 9|8 SEO – Set Dynamic Page Title and Meta Tags in Universal App
Tags: angular, angular98, setdynamicpagetitle, metatagsinuniversalapp
Published: 2020-02-01 18:17:35

---
title: Angular 9|8 SEO – Set Dynamic Page Title and Meta Tags in Universal App
published: true
date: 2019-10-30 19:58:40 UTC
tags: Angular, Angular 9|8, Set Dynamic Page Title, Meta Tags in Universal App
canonical_url: https://www.positronx.io/angular-seo-set-dynamic-page-title-meta-tags-in-universal-app/
---

The post [Angular 8/9 SEO – Set Dynamic Page Title and Meta Tags in Universal App](https://www.positronx.io/angular-seo-set-dynamic-page-title-meta-tags-in-universal-app/) appeared first on [positronX.io](https://www.positronx.io).

**In this step by step Angular 8|9 SEO tutorial, we are going to learn how to make Angular app SEO friendly by adding the page titles, meta descriptions, keywords, and other SEO attributes in an Angular Universal Server-side rendering app.**

In the previous tutorial, we saw how to create an Angular Universal app from scratch with MongoDB. In this tutorial, we will take the Git clone from this .

[Click here to read more](https://www.positronx.io/angular-seo-set-dynamic-page-title-meta-tags-in-universal-app/)
Vue 3 launch date estimated to Q1 2020
Tags: vue
Published: 2019-10-30 19:42:48

Evan You did an update to the Vue 3 Roadmap where the launch is estimated to be in the 1st Quarter of the next year (2020), so be prepare guys, we are nearly than we thought!

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/i5jtkordhd49z16gwv8d.png)

If you want to check the roadmap visit this link -> https://github.com/vuejs/vue/projects/6
How to add inline stuff in Jekyll blog
Tags: jekyll, blog, ctr
Published: 2019-10-30 19:02:09

---
title: How to add inline stuff in Jekyll blog
published: true
description: There are many cases when you want to add inline stuff to your blog at regular intervals.
tags: Jekyll, Blog, CTR
---

There are many advantages of having a personal blog and hosting it on GitHub. Many people like to have a Jekyll blog and write regular posts related to things they are learning.

I have a similar blog and the post was first written on that blog only.

Earlier I used to write posts using the CMS that I personally created and hosted on Jeklog.com. But due to my work, I was not able to continue it and had to take it down. Currently, I am using [siteleaf](https://siteleaf.com) to write my blogs.

A big shoutout to them.

Here is the link to the repository of the code for [jeklog.com](https://github.com/singh1114/thejekyllproject).


Read the post on the blog.

[How to add Inline Ads in Jekyll blog](https://singh1114.github.io/blog/how-to-add-inline-ads-in-jekyll-blog/)
Traditional Functions or Arrow Functions in Javascript?
Tags: discuss, beginners, javascript, webdev
Published: 2019-10-30 18:41:14

Recently, I started my Web Dev journey, and these days I have been reading about functions in Javascript. I've noticed that there are many ways to declare a function. Two of them caught my attention though, which are **Traditional Functions** and **Arrow Functions**.

I have read about them and in my understanding, I have to take into consideration the following:


| Traditional Functions  | Arrow Functions           |
| ---------------------- |:-------------------------:|
| No matter where you declare<br>and call the function,<br>Hoisting is the key. | The order matters. Declare it<br>into a variable and then call it. |
| Once you declare it,<br>you won't lose it. | The code seems cleaner than a<br> traditional declaration. |
|                        | Once you override the variable<br> where the function lives, it's over. | 

So, I would like to put on the table this topic in order to clarify my mind a little bit more about it, and comprehend the best use case for each of them.

Which one do you usually use when you code functions in Javascript?
Oh, my shell? Oh My Zsh
Tags: shell, zsh
Published: 2019-10-30 18:03:34

Do you ever think about what program is running your terminal?  For a long time, I knew the answer for most Linux / OS X systems was [bash](http://www.gnu.org/software/bash/), a [shell](http://en.wikipedia.org/wiki/Shell_%28computing%29) program.  *But what else is available?*

Aside from the occasional script, I didn't pay much attention to bash.  bash helped me get around my computer and autocomplete stuff, and that felt like enough.  This was **profoundly** shortsighted.

Heavy command line users should think about their shell.  I finally devoted time to shell research, and I became a [Zsh](http://www.zsh.org/) convert.

Zsh is the power user's weapon of choice.  It has an amazing [set of features](http://www.slideshare.net/jaguardesignstudio/why-zsh-is-cooler-than-your-shell-16194692) that go far beyond bash.  For example, `cd ~/p/h` followed by a tab will quickly expand to `cd ~/projects/handroll/` on my computer.  Zsh is smart enough to determine what you mean when you want to change directories so you can type fewer characters.

On top of Zsh being awesome, it also has some great tools to extend its awesomeness.  One popular tool for the shell is [Oh My Zsh](http://ohmyz.sh/).  OMZ offers many plugins and themes that make Zsh excel even more.  I've added the `git` and `virtualenvwrapper` plugins to my setup, and they've already been a huge boon.  There are hundreds more.

Want to try out Zsh? Go for it with these commands:

```console
$ sudo apt-get install zsh
$ chsh -s /bin/zsh # Change shell to zsh.
$ curl -L \
    https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
```

This article first appeared on [mattlayman.com](https://www.mattlayman.com/blog/2015/oh-my-zsh/).
I am AWS Obsessed but I can't get hired at AWS. Have you ever faced such repeated rejection?
Tags: rejection, discuss, aws, career
Published: 2019-10-30 18:03:07

---
title: I am AWS Obsessed but I can't get hired at AWS. Have you ever faced such repeated rejection?
published: true
description: 
tags: rejection, discuss, aws, career
cover_image: https://thepracticaldev.s3.amazonaws.com/i/4npl86bhmzvv0b4y6ggw.jpg
---

I just want to tell you that rejection happens for all of us.
Whether you're a Bootcamp graduate or a 10x developer.

I think if you know one thing about me its that I'm AWS Obsessed and you may ask why don't I work at AWS? I've been told an endless amount of times by AWS employees to apply. 

So have I ever tried? and the answer is **Yes, more than you can imagine**.

I apply to AWS all the time and no matter:

* how many free AWS videos I produce
* how many AWS courses I create
* how much I evangelize on Dev.to, Startup School and in Toronto
* how many CloudFormation templates I publish 
* how many AWS Tech talks
* how many AWS Workshops
* how many contributions to the open-source docs
* how many times I rewrite my cover letters or resume
* how many startups I covert over to AWS

I just face waves of rejections 🌊. At this point, I simply hit apply to every AWS job posted in Toronto ritualistically. I have no reason to believe I will ever be considered.


![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/yra295imldr3k0p49wk2.png)

the list goes on and on...

I talk about being able to hack the job interview. But this one company has alluded me. I am beyond the point of frustration a long time ago and just accept how things are.

## So what do you do when you face rejection?

Whenever I am feeling down, I utter the famous words of Commander Peter Quincy Taggart. **Never Give up, Never Surrender.**

![](https://media.giphy.com/media/2rIDTzizHRQv6/giphy.gif)

## How has it been for you?

Have any of you faced such a crazy amount of rejection?
👇 Share in the comments below. 👇
Phalcon 3.4.5 released
Tags: php, phalcon, phalcon3, 34x
Published: 2019-11-11 22:24:15

---
title: Phalcon 3.4.5 released
published: true
date: 2019-10-30 15:00:36 UTC
tags: php,phalcon,phalcon3,3.4.x
canonical_url: 
---

We are happy to announce that we have released Phalcon [3.4.5](https://github.com/phalcon/cphalcon/releases/tag/v3.4.5).

This is a maintenance release, addressing several issues in particular with PHP 7.

We did state in the past that we will no longer support v3 since v4 is just around the corner. However we decided on this maintenance release so as to help users with v3 and some of their critical bugs.

## Changelog

### Fixed

- Fixed segfault in `Phalcon\Mvc\Micro\LazyLoader::__call()` when the handler has a syntax error. [#12396](https://github.com/phalcon/cphalcon/issues/12396)
- Fixed RuntimeException in `Phalcon\Db\Adapter\Pdo` Trying to call method upper on a non-object. [#14330](https://github.com/phalcon/cphalcon/issues/14330)
- Fixed `Phalcon\Storage\Adapter\Redis::delete()` deprecated warning from php-redis [#14281](https://github.com/phalcon/cphalcon/issues/14281)

As always, a huge thank you to our community!!

## Update/Upgrade

Windows DLLs are available from the Github [3.4.5](https://github.com/phalcon/cphalcon/releases/tag/v3.4.5) tag page.

Phalcon 3.4.5 can be installed from the [v3.4.5](https://github.com/phalcon/cphalcon/tree/v3.4.5) tag, if you don’t have Zephir installed follow these instructions:

```
git clone http://github.com/phalcon/cphalcon
cd cphalcon/build
sudo ./install

```

Note that running the installation script will replace any version of Phalcon installed before.

[PackageCloud.io](https://packagecloud.io/phalcon/stable) has been updated to allow your package manager (for Linux machines) to upgrade to the new version seamlessly.

> **NOTE** : The RPMs and DEBs will take a bit of time to be rebuilt, so they might not be immediately available.

> **NOTE** : Windows DLLs are now available in our [Github Release](https://github.com/phalcon/cphalcon/releases/tag/v3.4.5) page.

Users of v3 that need/want to port your code to PHP 7.3 you will need to use this version and as always a big thank you to our contributors!

<3 Phalcon Team
A Good Way to Learn Idiomatic Ruby
Tags: ruby, rails, codenewbie
Published: 2019-10-30 17:50:53

## Once I read that

> "A good way to learn Idiomatic Ruby is to read idiomatic Ruby" 

And I didn't know why I haven't thought about this while I was learning the other languages!

From now on, I am going to dig in the library files so I get more and more used to Ruby's Idiom.

## What do you do to read "good" Ruby code?