teleren/devto huggingface dataset:
Simple Bluebird.Js Cheat Sheet
Tags: cheatsheet, bluebird
Published: 2021-05-11 16:28:07

### Reference

* [Official documentation](http://bluebirdjs.com/docs/api-reference.html)
* [Bluebird.Js Cheat Sheet](https://cheatsheetmaker.com/bluebirdjs)

### Generators

```
User.login = Promise.coroutine(function* (email, password) {
  let user = yield User.find({email: email}).fetch()
  return user
})﻿
```

See [Promise.coroutine](http://bluebirdjs.com/docs/api/promise.coroutine.html).

### Promise-returning methods

```
User.login = Promise.method((email, password) => {
  if (!valid)
    throw new Error("Email not valid")

  return /* promise */
})﻿
```

See [Promise.method](http://bluebirdjs.com/docs/api/promise.method.html).

### Node-style functions

```
var readFile = Promise.promisify(fs.readFile)
var fs = Promise.promisifyAll(require('fs'))﻿
```

See [Promisification](http://bluebirdjs.com/docs/api/promisification.html).

### Chain of promises

```
function getPhotos() {
  return Promise.try(() => {
    if (err) throw new Error("boo")
    return result
  })
}

getPhotos().then(···)﻿
```

Use [Promise.try](http://bluebirdjs.com/docs/api/promise.try.html).

### Object

```
Promise.props({
  photos: get('photos'),
  posts: get('posts')
})
.then(res => {
  res.photos
  res.posts
})﻿
```

Use [Promise.props](http://bluebirdjs.com/docs/api/promise.props.html).

### Multiple promises (array)

*   [Promise.all](http://bluebirdjs.com/docs/api/promise.all.html)(\[p\]) - expect all to pass
*   [Promise.some](http://bluebirdjs.com/docs/api/promise.some.html)(\[p\], count) - expect `count` to pass
*   [Promise.any](http://bluebirdjs.com/docs/api/promise.any.html)(\[p\]) - same as `some([p], 1)`
*   [Promise.race](http://bluebirdjs.com/docs/api/promise.race.html)(\[p\], count) - use `.any` instead
*   [Promise.map](http://bluebirdjs.com/docs/api/promise.map.html)(\[p\], fn, options) - supports concurrency

```
Promise.all([ promise1, promise2 ])
  .then(results => {
    results[0]
    results[1]
  })

// succeeds if one succeeds first
Promise.any(promises)
  .then(results => {
  })
```

```
Promise.map(urls, url => fetch(url))
  .then(···)

```

Use [Promise.map](http://bluebirdjs.com/docs/api/promise.map.html) to "promisify" a list of values.### Multiple promises
```
Promise.join(
  getPictures(),
  getMessages(),
  getTweets(),
  function (pics, msgs, tweets) {
    return ···
  }
)﻿
```

Use [Promise.join](http://bluebirdjs.com/docs/api/promise.join.html)

### Multiple return values

```
.then(function () { return [ 'abc', 'def' ] }) 
```

Use [Promise.spread](http://bluebirdjs.com/docs/api/promise.spread.html)

### Example

```js
promise
  .then(okFn, errFn)
  .spread(okFn, errFn)        // *
  .catch(errFn)
  .catch(TypeError, errFn)    // *
  .finally(fn)
  .map(function (e) { ··· })  // *
  .each(function (e) { ··· }) // *
```

Those marked with `*` are non-standard Promise API that only works with Bluebird promises.
You're Hired!
Tags: career, beginners, learning, motivation
Published: 2021-05-17 16:23:00

I was near tears when I heard those words from my new manager.  After months and months of self-learning, both about myself and programming, I finally have my first job in the tech field and can happily say I made the switch from a career in Manufacturing Quality to Technology.  

![Celebration gif](https://media.giphy.com/media/w7RNR3fdYikm0HylB5/giphy.gif)

Starting May 24<sup>th</sup>, my new title will be that of a Software Test Engineer for Cox Automotive.  Now, I know what you're thinking, "Cory, your social media says you're a Full-Stack Developer.  Why are you happy with a Software Test Engineer role?".  Well, there are numerous reasons for that, such as the fact that I'm less than a year into my career path transformation, I've found a great company to work for, and understand that there is a lot more for me to learn and grow from within the tech industry itself.  I will go into further detail on all of these points, and more, within the other posts of this series, so be sure to stick around and read them when they come out.  One key item to remember when reading through these though; I'm not done yet.  

![Not done yet gif](https://media.giphy.com/media/U4M3GyO7QbaAsHTAoK/giphy.gif)

There will always be more to learn about in this industry, different ways to grow and develop yourself as an individual and programmer, and a better way to approach and solve issues that we must master.  This is what makes us engineers and what we must tackle day in and day out with an optimistic and joyful mindset.  Without these key values in our life, we're certain to fall behind the next person and be overlooked in our careers so it's vital to be continually improving.  The keyword here is *continually*.  Most people think they have to be *continuously* improving, but that frequently leads to stress, burnout, and overall poor results.  By *continually* improving, you provide yourself with sufficient breaks and pauses to relax and enjoy life.  Ralph Waldo Emerson once said, "Life is a journey, not a destination".  I strive to live my life every day by the message of his quote.  

While I work hard and push myself to get things done quickly and correctly, I never put my mental health and sanity over that of studying and work.  This is what I would like each and every one of you to take away from this series.  It's never too late or difficult to follow your dreams and make them a reality.  It of course will take hard work and dedication, but you can get there, just like I have and will continue doing.

![Follow your dreams gif](https://media.giphy.com/media/9fn7ogiJHmYG4/giphy.gif)

Be sure to stay tuned for the next post in the series by following me here and on social media too!  The links to my social media accounts can be found on the [contact page](https://corydorfner.com/contact/) of my personal website.  Thank you and I look forward to your comments below!:wave:
The importance of Magneto and Salesforce Integration
Tags: php, programming
Published: 2021-05-12 12:47:04

The enterprise of online product selling is growing these days. Particularly, regarding the pandemic time, whilst human beings had no preference but to the motel to eCommerce, structures to shop for critical products.

In this digital technology, there are so many effective structures to be had to create a similarly effective eCommerce website. Magento shop is considered one of them that enjoys an extraordinary deal of flexibleness and open-source functions to boost the income sample. However, [Magento Salesforce integration](https://www.orangemantra.com/services/salesforce-integration/) turns to magic for enterprises to higher understand clients, offer customized products, and offer a stronger level of customer service.

##what is Salesforce?
Salesforce is one of the main CRM (customer relationship management) platforms that offers an interactive view of consumer’s preferences and tendencies. It allows to prepare and quantify user’s information primarily based on personal info and buying patterns to apprehend the interest level.

With having Salesforce incorporated into your Magento keep, you will consolidate your advertising and marketing sports, automate e-mail methods, social media promotions, and strategize advertising activities.

Magento CRM integration calls for you to lease a Salesforce developer having years of knowledge in integrating technical components to automate behavior.

[Read more](https://www.orangemantra.com/blog/top-benefits-of-magento-salesforce-integration/)
Upcoming SaaS in robotic process automation in logistics
Published: 2021-05-12 13:43:35

Robotics technology is progressing slowly but surely in careful and thoughtful stages. Robots are among us right now.

Personal robots are busy cleaning the inside of our homes and helping to maintain our gardens. Commercial robots are busy with the manufacturing side of the supply chain, mainly in the automotive industry. But where are all the robots in the logistics environment? Why are there so many advanced robots in warehouses that help tackle today's distribution challenges? Robotics technology is progressing slowly but surely in careful and thoughtful stages. Robots are among us right now.

This article on Logistics Trends explores these issues in detail. You will find that designing an advanced robot is costly and a major technological challenge. You will find that the distribution environment is complex and difficult to automate. But every day, there are breakthroughs in robotics that help us overcome these challenges.

continue reading https://ardas-it.com/upcoming-saas-in-robotic-process-automation-in-logistics
Journey to the real world by cloning DEV.to backend server(part 1)
Published: 2021-05-12 16:26:16

In this long series we will explore  amazing library and framework by implementing dev.to backend server.

### Tools we will use

1. Nodejs

> Nodejs is a javascript runtime which allow javascript to run outside the browser. Nodejs was developed by Ryan Dahl which utilize google v8 javascript engine.
You can learn more about nodejs [here](https://nodejs.org/)

2. Graphql

> Graphql is a query language for API which provide full power to frontend developer to query data according to requirement without too much hassle.
Graphql is alternative to REST in REST we create a bunch of endpoints using different http verbs like GET , POST , PUT , DELETE etc.. but in graphql we have one and only one endpoint which will always make a POST request no matter what your intension about getting data or updating data.e
Graphql was developed and open source by facebook you can learn more about graphql [here](https://graphql.org/)

3. Apollo Server

> Apollo server is a graphql implementation for production use and can be used easily with any graphql client like relay , urql , apollo client etc..
You can explore much about apollo server [here](https://www.apollographql.com/docs/apollo-server/)



4. Express

> Express is a most popular , unopinionated  nodejs based web framework. We will use express as middleware to handle file server. You can explore about express js [here](https://expressjs.com/).


5. Prisma 2

> Prisma is a Next-Gen javascript and typescript ORM . It generate types for your model and provide highlight during development to work faster.
You can explore prisma 2 [here](https://www.prisma.io/)


For the sake of simplicity we will use javascript to develop complete backend.


From next series we will install dependencies required to setup our project
The Crazy decoupler - NestJs Emitter
Tags: nestjs, events, emitter, listener
Published: 2021-05-12 21:22:12

Those of us who have used NestJs are familiar of the architectural flow. We break code into modules. Modules have controller which are basically the public endpoints. And then there are services which can be injected on demand. 

It gets messy when we have to communicate across modules. Sure if you are using micro-services it's a different game altogether, but there is something in NestJs which gives crazy level of decoupling. And those are called Event Emitters.

By using this guy, you can emit an event in a controller/service and listen for it in another controller/service WITHOUT importing them into each other. How cool is that. Wonder why we don't use it more often. Hmm!!! Need to read up on the cons of this stuff too I guess.

But till then, here is how simple it is.

**THE EMITTER**

```
@Get("emit")
async emit()
{
    this.EventEmitter.emit
    (
        'hello',
        "My name is Antony Gonzalves!"
    );  
}
```

**THE LISTENER**

```
@OnEvent('hello')
handleOrderCreatedEvent(message) 
{
    console.log("I am expecting some messages now!");
    console.log(message);
}
```


Points to note -
1. The emitter and listener are two separate files - can be controllers or services - doesn't matter.
2. The emitter basically emits an event called "hello" with data "My name is Antony Gonzalves!".
3. The listener is waiting for an event "hello". As soon as it receives, it prints the message out.

Crazy simple.

Please comment on the cons of this approach if you guys know any.

Happy Programming !!!
The truth about Technical debt?
Tags: linkedinposts, projectmanagement, techlead
Published: 2021-05-12 23:39:49

###### I am always posting provoking post on my Linkedin, and I have decided to replicate those here. [Let's socialize!](https://www.linkedin.com/in/alexsandro-souza-dev)

Technical debt is widely used and discussed within engineering teams. However, in people mind, it looks like it accumulates because of some nasty, dirty practices.

Technical debt piles up even when you work with the best intentions and follow the best practices.

Why?

Because Tech debt is not ONLY a result of prioritizing speedy delivery or poor development skills but a natural result of writing code about something we don't have a proper understanding of the complete solution

Knowing that, a natural response is to invest more in the design phase. However, in reality, you can not capture and learn everything before start implementing the solution. The future is uncertain and might bring radical changes.

 A leaner cycle is the best option. Take a piece of the Design effort and move it forward in a refactoring phase that happens every time a few pieces have consolidated and are ready to be secured.

In this scenario, we accept debt creation, trusting our ability to repay it in the short term.

Like financial debt, tech debt can harm or help your organization. To use it wisely, engineers and team leaders must monitor how much technical debt they acquire and learn to manage it well.


### Free Advanced Java Course
I am the author of the [Advanced Java for adults course](https://www.udemy.com/course/advanced-java-for-adults/?referralCode=8014CCF0A5A931ADED5F). This course contains advanced and not conventional lessons. In this course, you will learn to think differently from those who have a limited view of software development. I will provoke you to reflect on decisions that you take in your day to day job, which might not be the best ones. This course is for middle to senior developers and we will not teach Java language features but how to lead complex Java projects. 

This course's lectures are based on a Trading system, an opensource project hosted on my [Github](https://github.com/apssouza22/trading-system).
Haml Cheat Sheet
Tags: haml, cheatsheet
Published: 2021-05-13 09:22:39


### Ruby

```haml
-# This is a comment
-# Anything starting with a hyphen signals to Haml that Ruby is coming
- @arr = [1, 2, 3]
- @str = "test"
-# Equal signals output
= render partial: "shared/header"
= yield
= link_to page_url
```
### Inline Attributes

Either hash syntax works

```haml
%meta{ name: "viewport", content: "width=device-width, initial-scale=1.0" }
%input{ :type => "text", :required => true }
```

### Classes and ID's

```haml
%p.class-example
.no-tag-defaults-to-div
%div#butItCanBeIncluded
```

### Tags

```haml
%html
  %head
    %title
  %body
    %h1 Hello World
    %br/
```

### Doctype

```haml
!!! 5
```

### Reference
* [Haml Cheat Sheet](https://cheatsheetmaker.com/haml) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
Sinon-Chai Cheat Sheet
Tags: sinonchai, cheatsheet
Published: 2021-05-13 11:21:56


### Should
```
    spy.should.have.been.called
    spy.should.have.been.calledOnce
    spy.should.have.been.calledTwice
    spy.should.have.been.calledThrice
    spy1.should.have.been.calledBefore(spy2)
    spy1.should.have.been.calledAfter(spy2)
    spy.should.have.been.calledWithNew
    spy.should.always.have.been.calledWithNew
    spy.should.have.been.calledOn(context)
    spy.should.always.have.been.calledOn(context)
    spy.should.have.been.calledWith(...args)
    spy.should.always.have.been.calledWith(...args)
    spy.should.always.have.been.calledWithExactly(...args)
    spy.should.always.have.been.calledWithExactly(...args)
    spy.should.have.been.calledWithMatch(...args)
    spy.should.always.have.been.calledWithMatch(...args)
    spy.should.have.returned(returnVal)
    spy.should.have.always.returned(returnVal)
    spy.should.have.thrown(errorObjOrErrorTypeStringOrNothing)
    spy.should.have.always.thrown(errorObjOrErrorTypeStringOrNothing)
```

### Assert
```
    expect(spy).called
    expect(spy).calledOnce
    expect(spy).calledTwice
    expect(spy).calledThrice
    expect(spy).calledBefore
    expect(spy).calledAfter
    expect(spy).calledWithNew
    expect(spy).alwaysCalledWithNew
    expect(spy).calledOn
    expect(spy).alwaysCalledOn
    expect(spy).calledWith
    expect(spy).alwaysCalledWith
    expect(spy).calledWithExactly
    expect(spy).alwaysCalledWithExactly
    expect(spy).calledWithMatch
    expect(spy).alwaysCalledWithMatch
    expect(spy).returned
    expect(spy).alwaysReturned
    expect(spy).threw
    expect(spy).alwaysThrew
```
### Initialization

```js
var sinon = require('cs/sinon');
require('cs/chai').use(require('cs/sinon-chai'));
```

### Reference
* [Sinon-Chai Cheat Sheet](https://cheatsheetmaker.com/sinon-chai) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
TYPO3 Talk with Tim: Author Of TYPO3 Blogger
Published: 2021-05-14 09:17:45

We have Tim Lochmüller with us this week for an interesting TYPO3 Talk! Tim Lochmüller is the author of TYPO3 Blogger and works for the TYPO3 agency HDNET and has been working with TYPO3 since 2004.
The TYPO3 Talk with Tim is interesting, so grab that cup of coffee to explore Tim's insights into his views, the history and potential of TYPO3 and the open-source community, and how we can build a better TYPO3 ecosystem together!

Interviewee :Tim Lochmüller
Company: HDNET GmbH & Co. KG
Designation: Author of TYPO3 Blogger
Topic: Together Building a Better TYPO3 Eco-system

Let's explore his journey with TYPO3 from then to now, and much more! https://t3terminal.com/blog/typo3-talk-with-tim-author-of-typo3-blogger/
Boken Engine
Tags: opensource, framework, swift, xcode
Published: 2021-05-14 11:34:04

Hi all, just joined the community. First time posting here, long time reading awesome published content.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/amrmtvl1te5uwxz998qq.png)

At my current job we have been working on a **Swift framework** for creating slides-based, non-linear visual stories and presentations.

Its name is **Boken Engine**, we got a beta version and it’s open source, so you can play with it and if you find any bugs you can leave a bug report and in case you know how to fix it we'd love to have new contributors. ;)

The idea is that any user, only with a few lines of codes, can generate **full fledged visual stories or slide based presentations for iOS devices**. It is based on SpriteKit and content is provided through JSON files (and additional image and sound assets to enrich your story).

You can visit the project on [GitHub](https://github.com/boken-engine/boken-engine)

Any feedback would be appreciate. Thanks in advance.
How to cartoonize an image with Python
Tags: python, tutorial, showdev, computervision
Published: 2021-05-22 08:43:08

In this tutorial, I will show you how to give a cartoon-effect to an image in Python with OpenCV.

OpenCV is an open-source python library used for computer vision and machine learning. It is mainly aimed at real-time computer vision and image processing. It is used to perform different operations on images which transform them using different techniques.

Many apps can turn your photos into cartoons, but you can do this on your own with few lines of code Python code. 

This is our test image:

![enter image description here](https://i.ibb.co/bFh6dM0/elon-musk.jpg)
 
 Let's jump to the code.


```python
import numpy as np
import cv2
```

after that we we read our image:

```python
filename = 'elon.jpeg'
```
then we will define our `resizeImage` :

```python
def resizeImage(image):
    scale_ratio = 0.3
    width = int(image.shape[1] * scale_ratio)
    height = int(image.shape[0] * scale_ratio)
    new_dimensions = (width, height)
    resized = cv2.resize(image, new_dimensions, interpolation = cv2.INTER_AREA)

    return resized
```
the we need to find contours:

```python
def findCountours(image):
    
    contoured_image = image
    gray = cv2.cvtColor(contoured_image, cv2.COLOR_BGR2GRAY) 
    edged = cv2.Canny(gray, 30, 100)
    contours, hierarchy = cv2.findContours(edged, 
    cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
    cv2.drawContours(contoured_image, contours, contourIdx=-1, color=1, thickness=1)
    cv2.imshow('Image after countouring', contoured_image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    
    return contoured_image
```
after that, we do a color quantization:

```python
def ColorQuantization(image, K=4):
    Z = image.reshape((-1, 3)) 
```
then we convert image to numpy float32:

```python
    Z = np.float32(Z) 
```

also we need to define critera and apply kmeans:

```python
    criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 10000, 0.0001)
    compactness, label, center = cv2.kmeans(Z, K, None, criteria, 1, cv2.KMEANS_RANDOM_CENTERS)
```

then we convert to `uint8` and apply to original image:

```python
   center = np.uint8(center)
   res = center[label.flatten()]
   res2 = res.reshape((image.shape))
    
   return res2
```

```python
if __name__ == "__main__":
    
    image = cv2.imread(filename)
    resized_image = resizeImage(image)
    coloured = ColorQuantization(resized_image)
    contoured = findCountours(coloured)
    final_image = contoured
    save_q = input("Save the image? [y]/[n] ")
    
    if save_q == "y":
           
        cv2.imwrite("cartoonized_"+ filename, final_image)
        print("Image saved!")
```

This is our final result:
![enter image description here](https://i.ibb.co/Qmpgwyn/cartoonized-elon-musk.jpg)

Thank you all.