teleren/devto huggingface dataset:
How to overload functions in Swift
Tags: swift, ios, function
Published: 2019-05-06 14:33:18

---
title: How to overload functions in Swift
published: true
description: 
tags: swift,ios,function
---

## Function

Functions in Swift are distinguishable by

- parameter label
- parameter type
- return type

so that these are all valid, and works for `subscript` as well

```swift
struct A {

  // return type
  func get() -> String { return "" }
  func get() -> Int { return 1 }

  // mix of parameter type and return type
  func get(param: String) -> String { return "" }
  func get(param: String) -> Int { return 1 }
  func get(param: Int) -> Int { return 1 }
  func get(param: Int) -> String { return "" }

  subscript(param: String) -> String { return "" }
  subscript(param: String) -> Int { return 1 }
  subscript(param: Int) -> Int { return 1 }
  subscript(param: Int) -> String { return "" }

  // parameter label
  func set(int: Int) {}
  func set(string: String) {}

  // concrete type from generic
  func get(param: Array<String>) -> String { return "" }
  func get(param: Array<Int>) -> Int { return 1 }

  subscript(param: Array<String>) -> String { return "" }
  subscript(param: Array<Int>) -> Int { return 1 }
}

```

When you specialize a generic type, like `Array<Int>`, you're actually using a concrete type

Unfortunately, this does not work for NSObject subclass

> Method 'get()' with Objective-C selector 'get' conflicts with previous declaration with the same Objective-C selector

```swift
class B: NSObject {

  func get() -> String { return "" }
  func get() -> Int { return 1 }
}
```

## Generic function

We can overload generic functions as well

```swift
func f<T>(t: T) {
  print("T")
}

func f(string: String) {
  print("String")
}

func f(int: Int) {
  print("Int")
}
```


Original post https://github.com/onmyway133/blog/issues/211
The 7 Most Popular DEV Posts from the Past Week
Tags: top7
Published: 2019-05-06 14:12:34

---
title: The 7 Most Popular DEV Posts from the Past Week
published: true
description: A round up of the most-read and most-loved contributions from the community this past week.
tags: icymi
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sfwcvweirpf2qka2lg2b.png
---
Every Monday we round up the previous week's top posts based on traffic, engagement, and a hint of editorial curation. The typical week starts on Monday and ends on Sunday, but don't worry, we take into account posts that are published later in the week. ❤️


#1. Containerize!

A short and simple Docker guide: the why, the how, and an example!

{% link https://dev.to/akanksha_9560/docker-for-frontend-developers-1dk5 %}

#2. Great Investigation 🔍

How a complaining user led to an interesting discovery about JavaScript methods. 

{% link https://dev.to/uilicious/javascript-array-push-is-945x-faster-than-array-concat-1oki %}

#3. Tips & Tricks

An overview of the critical rendering path and how to improve web performance. 

{% link https://dev.to/yashints/improve-html-and-css-performance-4o08 %}

#4. Constant Change

Kaleb breaks down the origins/dimensions of imposter syndrome and shares ways to handle it through understanding the Dunning Kruger Effect.

{% link https://dev.to/avatarkaleb/battling-imposter-syndrome-by-understanding-the-dunning-kruger-effect-904 %}

#5. A Human Activity

Erika explains why they view programming as a form of art, and how not all artists are the same.

{% link https://dev.to/erikaheidi/the-art-of-programming-21gg %}

#6. A Silver Lining

The majority of accessibility errors can be grouped into a small handful of categories -- Alvaro shows us how to fix these easy-to-prevent problems.

{% link https://dev.to/alvaromontoro/fix-85-of-your-web-accessibility-issues-in-5-easy-steps-pnf %}

#7. Don't miss out!

Sebastian shares their collection of settings, extensions and shortcuts that makes their life as a web developer easier.

{% link https://dev.to/selrond/tips-to-use-vscode-more-efficiently-3h6p %}

_That's it for our weekly wrap up! Keep an eye on dev.to this week for daily content and discussions...and if you miss anything, we'll be sure to recap it next Monday!_
How do I learn Python in depth?
Tags: python, learn
Published: 2019-05-06 13:07:38

---
title: How do I learn Python in depth?
published: true
description: python, learn
tags: python, learn
---
<img src="https://cdn.pixabay.com/photo/2014/05/02/21/48/blogger-336371_960_720.jpg" alt="learn python">

There's no shortcut, read lots of code then write lots of code.

**1. Start and learn the basics**

First start by installing Python. Choose Python 3.x, setup your coding environment, configure the Python path etc. 

To get started, there are some online tutorials that can assist you:
 
* https://pythonbasics.org/
* https://www.tutorialspoint.com/python/
* https://pythonprogramminglanguage.com/

**2. Master libraries**

Libraries or modules are building blocks that help you create your app. There are thousands of modules, so which one do you need for your app?

It depends on what you want to make. For web apps, it's popular to use Django or Flask. For Machine Learn, tensorflow and sklearn are popular modules. For desktop software, you can use wxwidgets, pyqt, tkinter or other modules.

**3. Study courses**

Courses can help to boost your knowledge. There are many courses out there, that will give you a kick start in developing software applications. Instead of struggling through the documentation, why not follow short video tutorials that explain clearly?

**4. Work on projects**

Once you mastered the basics and can use modules, it's time to make your own apps!
Learn to recognise the important bits
Tags: attitude, projects, motivation, yakshaving
Published: 2019-05-06 13:05:08

The most useful thing I learned in Uni was to tell the important from the trivial.

I studied Design. The [professor](https://medium.com/@ralphammer) who oversaw my interaction-design-projects was ruthless about calling out fake progress on my presentations.
The shiny, fashionable, trivial, [yak-shaving](https://americanexpress.io/yak-shaving/), turd-polishing parts.
Everything that didn't further or reinforce the core ideas.

The reason was simple:
If the core ideas and content aren't good on their own, no amount of sugarcoating will make them good. So don't waste time on paint until the house is standing.

Yak-shaving is dangerous, because it creates the illusion of progress. Keep it for when you answered the hard questions.

Of course it's important to have a good looking poster, but the people are not attending your show if you can't dance.

Next time you're working on a project, ask yourself whether you already solved the important bits.
[SOLVED] How I use a synchronous queries with mongoose on NodeJS with ExpressJS
Tags: node, express, mongoose, mongodb
Published: 2019-05-06 13:02:59

---
title: [SOLVED] How I use a synchronous queries with mongoose on NodeJS with ExpressJS
published: true
description: I want to process several querys synchronously one after the other. When I execute the code below, nothing happens. No error message or the same. What am I doing wrong?
tags: nodejs, expressjs, mongoose, mongodb
---

I want to process several querys synchronously one after the other. When I execute the code below, nothing happens. No error message or the same. What am I doing wrong?

{% gist https://gist.github.com/sm-a/b349ef8968db02ee553528c3e3559ad1.js %}
The Building an Indie Business Podcast- My Experience on Minds.com
Tags: podcast, startup
Published: 2019-05-06 13:00:14

---
title: The Building an Indie Business Podcast- My Experience on Minds.com
published: true
description: 
tags: podcast, startup
---

https://overcast.fm/+RG5jzbAUM

[Episode Page](https://baib-podcast.com)
[Revenue Research](https://revenueresearch.co/)
Learn how YOU can build a Serverless GraphQL API on top of a Microservice architecture with PHP
Tags: async, php, reactphp, graphql
Published: 2019-10-14 13:30:31

---
title: Learn how YOU can build a Serverless GraphQL API on top of a Microservice architecture with PHP
published: true
date: 2019-05-06 12:56:40 UTC
tags: async,php,reactphp,graphql
canonical_url: https://medium.com/@dotbox/learn-how-you-can-build-a-serverless-graphql-api-on-top-of-a-microservice-architecture-with-php-4cd8dac39ab4
---

![](https://cdn-images-1.medium.com/max/1024/1*CGmVEHr9ZF-qzSjXLzv_3g.png)

A few weeks earlier I read a very interesting article from Chris Noring about [“Learn how YOU can build a Serverless GraphQL API on top of a Microservice architecture, part 1”](https://dev.to/azure/learn-how-you-can-build-a-serverless-graphql-api-on-top-of-a-microservice-architecture-233g) which he entirely build with Node.js and Express and I thought to myself: _you could do this in PHP and_ [_ReactPHP_](https://reactphp.org/)_!_

_Disclaimer: This is not a JavaScript vs. PHP rant!_

### The big picture

As Chris Noring did in his original article, I created two microservices exposing a REST-API, one serving products and another one serving reviews to said products. Those two Microservices will be only available internal and not exposed to the internet, but nevertheless there should be customer facing API. For this purpose I will use GraphQL as a high level API combining the results of the two Services.

As you can imagine, there is nothing original in my article, I just did the same but with PHP and ReactPHP. You can find the [source code on GitHub](https://github.com/flow-control/php-graphql-microservice), so I will limit myself to the highlights.

### Highlights

#### Services

The two services are pretty straight forward. Just a bit of ReactPHP-Code asynchronous handling incoming HTTP-Requests. For the sake of the example both are returning a static JSON-String. In a more in depth example you could connect to a database and look up the data.

#### GraphQL

When using GraphQL in PHP there are a couple of libraries, but only [webonyx/graphql-php](https://github.com/webonyx/graphql-php) seems mature enough, also it has an asynchronous interface supporting ReactPHP. So this was the perfect match for this case.

When using the async-Interface, you need to call `GraphQL::promiseToExecute` instead of `GraphQL::executeQuery` and give it the promise adapter as a first parameter, which in my case was an instance of `GraphQL\Executor\Promise\Adapter\ReactPromiseAdapter`

When initialized and used this way the method call to `promiseToExecute` will return a ReactPHP Promise, on which you can register your `then`-Handler. Also your `resolve`-Functions can now return a ReactPHP Promise, which means you can write async code everywhere.

**What you get is a pure asynchronous GraphQL-API written in PHP.**

Find the source code at GitHub

{% embed https://github.com/flow-control/php-graphql-microservice %}

Happy coding!
Custom Validation Rules in Laravel
Tags: laravelvalidation, customvalidation
Published: 2019-05-06 12:27:38

---
title: Custom Validation Rules in Laravel
published: true
description: In this post, we will look at how we can create custom validation rules for Laravel Form Requests.
tags: laravel validation, custom validation
---

In this post, we will look at how we can create custom validation rules for Laravel Form Requests. In our previous post, Laravel Form Request Demystified we looked at how we can extract the validation from controller to custom request class, today we will create custom rules to use in the request class.

Laravel provides an easy way to create custom validation rules. You can create custom rules based around your own business needs and use them anywhere in your application.


 
This post is the continuity of Laravel Form Request Demystified post, so you should read this first.

Read full article at [https://www.larashout.com/custom-validation-rules-in-laravel](https://www.larashout.com/custom-validation-rules-in-laravel)
Completed My First Major React Project
Tags: react, javascript, webdev, begginers
Published: 2019-05-06 12:04:00

---
title: Completed My First Major React Project
published: true
description: Very proud that I was able to wrap up my project.
tags: #react, #javascript, #webdev, #begginers
---

### http://tbhbeyond.com (My App)
### https://github.com/steelvoltage/tbhbeyond (Github Repo)

Back in November, when I first started programming I told myself I wanted to be able to make a site like [D&D Beyond] (https://www.dndbeyond.com/). As a huge tabletop RPG fan, I had no idea at the time that the site was built using React. I didn't even know what React was. 

Fast-forward to this week, and I finished my first major React project, which is a site inspired by D&D Beyond. It allows you to create and manage your characters for another indie tabletop RPG called [The Black Hack](https://www.drivethrurpg.com/product/255088/The-Black-Hack-Second-Edition). Sure, this homage to D&D's site is at a much smaller scale. But, I'm only one person. I imagine their site has an entire team of devs behind it, based on the robust functionality.

Still. I can say I accomplished what I set out to do! Coding the site alone took well over a month. I didn't have any guide, other than my concept. The site was built using create-react-app and taps into Firebase for a back-end database and authentication. It's hosted on Netlify and I even purchased a domain for it. 

I charged headlong into building it with functional components, the Context API for state, and hooks to tap into state and side-effects. There's even a custom hook called useAuth to pull down the user authentication information in there.

It's hard to summarize the multitude of lessons that this project taught me. But, I can say my confidence with React grew exponentially. If I had to pick the most valuable thing I learned, I would say it's simple perseverance. There were times where I felt overwhelmed, lost, and wanted to quit. But, banged my fingers against the keyboard and prowled Google for hours at a time, until I sorted my issues.

In the end, I shattered through the multitude of challenges the project presented and finished strong. And, much to my surprise, after sharing it on a few tabletop RPG groups, I even got myself a few users!

Knowing that someone finds it useful and will use it alone makes it worth the effort.

To other beginners out there, if you're working on a project, don't give up. Get it done, pluck away at it whenever you can. Because, we're after this career to make cool things, and we should **finish** our cool things.
Compile OpenCV4
Tags: opencv
Published: 2019-05-06 11:53:18

---
title: Compile OpenCV4
published: true
description: 
tags: OpenCV
---

Since OpenCV4 does not generata .pc file by default, we need to compile it from source and turn on the `OPENCV_GENERATE_PKGCONFIG` option if other programs need the pkg-config file.

Another problem I encountered is a number of errors similar to `undefined reference to TIFFReadRGBAStrip@LIBTIFF_4.0`. To solve that, the `BUILD_TIFF` option needs to be turned on.

And following is the script for compilation and installation.


```sh
wget https://github.com/opencv/opencv/archive/4.1.0.zip
unzip opencv-4.1.0.zip
cd opencv-4.1.0
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=YES -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_TIFF=ON
sudo make -j`nproc`
sudo make install
```
Build your free Full-Stack Developer Resume
Tags: jobs, maker, startup, showdev
Published: 2019-05-06 11:27:44

---
title: Build your free Full-Stack Developer Resume
published: true
description: Full-Stack Developer Jobs and Candidate Resumes, Vue/Go based project
tags:  jobs, maker, startup, showdev
---

As announced about 3 weeks ago, I want to offer Job Candidates to show up to qualified Job Recruiters with a well-prepared Resume/Candidate Profile.
For Recruiters we offer the possibility to get access to qualified candidate.

And all of this, as with the Job Positions, based on quality and not quantity. I will check and accept only real Full-Stack Developer Candidates and same for Recruiters, which can be qualified companies, recruiter agencies and head-hunters.

Register now for free and build your Online Resume as a Full-Stack Developer:
https://fullstackjob.com/developer/resumes

![](https://thepracticaldev.s3.amazonaws.com/i/v1w2xinwrh7qhjrr15ci.png)
What dream has technology enabled for you?
Tags: technology
Published: 2019-04-27 23:19:30

---
title: What dream has technology enabled for you?
published: true
description: Reminiscing how technology has enabled new capabilities
tags: technology
---

This week I came across a little 16-page book that I wrote when I was inspired by author R.L. Stine back in the 90s. It got me thinking about what enabled me to start writing, and then reminisce on the nearly two decades I've been using technology and what has changed.

My story began with a collision of several events: buying each book in the Goosebumps series and getting access to the internet and web development on the free hosting site (at the time) GeoCities. It's a long story, but I'll keep it short. I would write two-page short stories, print them out, and imagine releasing the two page stories in a regular cadence  (I think it was weekly) like Stine did. 

I hosted my first website on GeoCities, showcasing a newsletter featuring the latest story and behind-the-scenes. I didn't have much of an audience, my family was already well aware of my writing, being passive supportive recipients of a "free print subscription" printed on a Dot Matrix printer.

Regardless of the audience or popularity, this process enabled me to find an interest in writing. It enabled me to discover HTML, JavaScript, and Perl. Over the years, CSS, PHP, and Node.js (and many others) entered into my vocabulary. I've moved on from fiction to tutorials and real-life blogs, scattered across the internet on many websites.

So as the next generation of kids get started using technology, I [wonder what they will build](https://dev.to/jeancarl/how-to-help-your-child-learn-tocode-j3g) using much more advanced technology available to them from nearly anywhere in the world.

Looking back at the release of the smartphone and tablet that we know today, it was revolutionary in making technology accessible in the classroom. Every child seems to have some device available to them. Access to technology and the internet isn't such a stumbling block that it used to be.

In the last decade, there's a new crop of acronyms that have become accessible: AI, AR/VR, ML to name a few. Most of these have a plethora of online courses that can lead a newcomer through the ropes to learning the technology. [Free](http://glitch.com) or inexpensive hosting (now referred to as the Cloud) make it relatively easy to spin up hardware to make it happen, and tear down when finished. [Github](https://github.com) makes it easy to find code, to share code, and to collaborate with others. The investment is no longer about money and physical space, but rather time and interest. 

What has technology enabled for you?
Writing and Previewing Markdown in Real Time with Vim 8+
Tags: beginners, markdown, productivity, vim
Published: 2019-05-06 11:20:43

---
title: "Writing and Previewing Markdown in Real Time with Vim 8+"
published: true
description: "Here's a short video going over my workflow for writing Markdown documents with Vim. The preview is styled using GitHub's CSS."
tags: beginners, markdown, productivity, vim
cover_image: https://thepracticaldev.s3.amazonaws.com/i/zyzcgf7w4h7g7mbyrbyd.jpg
canonical_url: https://nickjanetakis.com/blog/writing-and-previewing-markdown-in-real-time-with-vim-8
---

**This article was originally posted on April 9th 2019 at: https://nickjanetakis.com/blog/writing-and-previewing-markdown-in-real-time-with-vim-8*

---

I'm about 2 months into [using Vim](https://nickjanetakis.com/blog/getting-productive-with-vim-in-a-week-without-hating-it) and it's going great. In this video I'd like to cover my general Markdown writing set up with Vim.

Documentation is such an important aspect of being a developer and having a Markdown set up with real time previews really helps writing README files. Especially with the preview being styled up to match GitHub's CSS.

## Demo Video Showing How It Works

{% youtube 22JAs0kNA9k %}

#### Timestamped Table of Contents

- 0:48 -- Going over Markdown related Vim plugins
- 2:01 -- Limelight and Goyo for distraction free writing
- 4:20 -- Writing Markdown to see how it all works
- 5:37 -- Previewing Markdown in a browser
- 6:52 -- GitHub styled CSS for the preview
- 8:59 -- Disabling conceal with the vim-markdown plugin
- 10:18 -- Dealing with code folding on Markdown headers
- 12:01 -- Adding an image to the Markdown README file
- 12:48 -- Pushing the example README file to GitHub
- 13:17 -- Configuring Vim as an editor for git commits

#### Reference Links

- Dotfiles: [https://github.com/nickjj/dotfiles](https://github.com/nickjj/dotfiles)
- vim-markdown: [https://github.com/plasticboy/vim-markdown](https://github.com/plasticboy/vim-markdown)
- markdown-preview.nvim: [https://github.com/iamcco/markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim)
- github-markdown-css: [https://github.com/sindresorhus/github-markdown-css](https://github.com/sindresorhus/github-markdown-css)
- limelight.vim: [https://github.com/junegunn/limelight.vim](https://github.com/junegunn/limelight.vim)
- goyo.vim: [https://github.com/junegunn/goyo.vim](https://github.com/junegunn/goyo.vim)

**What are some of your Markdown related tips for Vim? Let me know below.**
Visual Studio Code debugging for TypeScript files and Mocha
Tags: vscode, typescript, mocha
Published: 2019-05-06 11:06:29

---
title: Visual Studio Code debugging for TypeScript files and Mocha
published: true
description: 
tags: vscode, typescript, mocha
---

I found this great article. A little outdated but still worked after some tinkering.

[Debugging TypeScript in VS Code without compiling, using ts-node](https://medium.com/@dupski/debug-typescript-in-vs-code-without-compiling-using-ts-node-9d1f4f9a94a)

If you run into issues check my configuration:

https://gist.github.com/mjmaix/749de8954c9c6777c08641151ae519b5


===
So this is why I need to debug.

I'm not really into algorithms and competitive programming but I feel like my brain needs some practice so I started LeetCode-ing. Not a fan of the interface so I made a VSCode project setup with TS/Mocha. (Is anyone interested with the template?)

Sometimes my brain can't handle the stress of console logging so I need to step by step understand the code/process I'm in.