teleren/devto huggingface dataset:
CallerMemberName and Interfaces
Tags: net, softwarearchitecture, csharp
Published: 2018-09-01 13:42:39

---
title: CallerMemberName and Interfaces
published: true
tags: .NET,Software Architecture, CSharp
canonical_url: http://www.dotnetindia.com/2018/08/callermembername-and-interfaces.html
---

[CallerMemberName] is a attribute that is available in C# 5.0. It is a very useful functionality especially when doing common app framework components like logging, auditing etc.

One of the things that you usually try to do in your common logging infrastructure is to log the function that generated that log.

So before C# 5.0 it was most common to interrogate the stack to find the caller, which can be an expensive operation. Or the caller information is passed from the source function, which hard codes its name in the call.

Something like

```cs
_logger.Debug("Message", "myFunctionName");
```

This becomes hard to maintain and so in most cases the logger actually interrogates the stack to get this information and as mentioned before that comes with a performance penalty.

Using this new attribute, you can write something like the following for your log function:

```cs
public void Debug(string Message, [CallerMemberName] string callerFunction = "NoCaller")
```

The second parameter here is not passed by the caller, but is rather filled up by the infrastructure (i.e. .NET Framework). The parameter needs to be an optional parameter for you to be able to use this attribute. And this does not have a performance penalty as the compiler will fill in this parameter at compile time and so no run-time overheads.

This works fine, except when you use Interfaces. Again interfaces are generally a pattern that is often used in framework components like logging. So you will have a ILogger interface that will have a definition like about which is implemented by your actual Logger class and the caller use the Interface to talk to your implementation.

If you do something like this, the gotcha is that the interface also needs to have the attribute defined, or the value will not be auto filled. This is something that is easy to miss and is not well documented from whatever I could find. So your interface definition for this function will have the attribute defined like below:

```cs
void Debug(string Message, [CallerMemberName] string callerFunction = "")
```

for the caller value to flow through to your implementation.

When you are designing your interfaces this is so easy to miss and can take a long time to figure out why.
Language Idea: Limit custom types to three arguments
Tags: elm
Published: 2018-09-23 19:35:20

---
title: Language Idea: Limit custom types to three arguments
published: true
description: The general rule should be to name your data, even when using custom types.
tags: elm
---

_Language Idea is a new series where I note down some ideas I have on how Elm could improve as a language. Each post isn't necessarily a fully thought out idea, as part of my thinking process is writing stuff down. This is more a discussion starter than anything else._

In Elm 0.19 you can no longer create tuples which contains more than three elements. The reasoning behind this is that it's easy to lose track of what the elements represents after that. As an example:

```elm
(0, 64, 32, 32)
```

Is a bit more cryptic than:

```elm
{ xPosition = 0
, yPosition = 64
, width = 32
, height = 32
}
```

The rule here is quite simple, if you feel yourself in need of a tuple containing more than three elements you're better of using a record with named fields.

There is, however, another way in which you can work around this restriction in Elm 0.19.

## Custom Types

Yes. Custom types can still contain more than three parameters. Which is strange, as there is little to separate tuples from custom types with the exception of syntax and comparability.

Let me be clear though, you should prefer records with named fields. Names provide basic documentation, and records let you forget about what order parameters are in. I'd say that even when you're using custom types, you should always limit them to three (maybe even two) parameters and use records if you need more than that.

As to why Elm allows more than three parameters in custom types; I don't know. It might just be an oversight.

So here is a question: should Elm limit the number of parameters in custom types to three, as it does with tuples?

I think it should.

_Edit: The idea here is that one can do `type Person = Person { name : String, age : Int }` instead of `type Person = Person String Int` as it would make it more obious what each parameter is. It should then be encouraged to use records within custom types if there are many fields to store within the custom type._
Progressive Web Apps tutorial from scratch
Tags: pwa, progressivewebapp, javascript, serviceworker
Published: 2018-09-06 14:42:51

---
title: Progressive Web Apps tutorial from scratch
published: true
description: What are progressive web apps? And how do you learn about them?
tags: pwa, progressive web app, javascript, service worker
cover_image: https://i.imgur.com/80fkZFD.jpg
---


The modern web is super exciting. There's a whole new range of possibilities for us web developers thanks to a set of new Web APIs, collectively popularized under the term Progressive Web Apps. 

When somebody asks me what is a PWA, it's always hard to come up with a concise definition that doesn't include a lot of technical terms. However, I finally came up with a definition that holds true in most scenarios:

> **A Progressive Web App is a modern Website that consistently delivers a superior User Experience.** ✨

The reason why I think this holds true in most scenarios is because it covers most of the technical features possible by PWAs. Here's an example:
Making your website work offline is about the User Experience. If your user gets interrupted with the Offline Dinosaur because they briefly lost connection, then this is a bad User Experience.


> **Everything revolves around User Experience.**
 


## How do you learn it?


Now the big question is, how do we learn Progressive Web Apps?

Here's why I have an extremely important 3-step recommendation:
1. Set your front-end framework of choice aside
2. Learn Progressive Web Apps from scratch
3. Apply what you learned in PWAs to your front-end framework

Front-end frameworks are great, but the web platform has been moving so fast that we as web developers need to keep up with it by understanding how these new Web APIs work.

Having a wrapper on top of these APIs is great for productivity, but terrible for understanding how something works.

![Github repo screencast](https://i.imgur.com/AFAHXfN.png)

This is exactly why I recorded a free video series on YouTube that teaches Progressive Web Apps from scratch. We start from a repository with a simple index.html, app.js & app.css all the way to building a simple PWA.

![PWA video series](https://i.imgur.com/pJKxBqS.jpg)

Watch the [📽 PWA Video series](https://www.youtube.com/watch?v=GSSP5BxBnu0&list=PLIiQ4B5FSuphk6P-zg_E3W9zL3J22U4dT&index=1) for free!
New to Reactjs (I want to REACT to this)
Tags: react, newbie
Published: 2018-09-06 19:08:52

---
title: New to Reactjs (I want to REACT to this)
published: true
description: 
tags: reactjs, newbie
---


Hello, I am Michael Owolabi from Nigeria and I am new to React js, hope to explore more as I progress in this journey. plz, if you have anything that you think might help me grow as fast and solid as possible kindly get in touch.

Thanks.
Working Remotely
Tags: help, remote
Published: 2018-09-07 19:46:28

---
title: Working Remotely
published: true
description: 
tags: help, remote
---

I really want to start looking for remote web developer positions but I'm not sure where to start. I know HTML and CSS fairly well and I'm getting there with JavaScript. I feel like at this point I can look up anything that I don't know (which I'm understanding is normal even for the most experienced developers).

My question is, do I need to know more before I start looking for a job? If not, can anyone suggest where I should start looking? I really want to get a good start in this field and I'm really tired of holding down jobs that have nothing to do with where my heart is. Any advice would be appreciated.
Software that helps
Tags: discuss
Published: 2018-09-09 21:37:13

---
title: Software that helps
published: true
tags: discuss
---
I am wondering who of you write software that „truly“ helps other people.

In a way, all software does. But I am thinking e.g. about software that runs a pacemaker, or maybe you’re developing software for a non-profit that deals with social issues.
Back to the basics, you're gonna NOT need hypes to drive you crazy
Tags: css, javascript, html
Published: 2018-09-10 04:37:49

---
title: Back to the basics, you're gonna NOT need hypes to drive you crazy
published: true
description: 
tags: #css, #javascript, #html
---

For all of us, want to master the real fundamentals of frontend development, just learn from [this](https://www.w3schools.com/howto/default.asp) is more than enough.

Stop chasing for hypes, courses, frameworks, library, articles, blogs, twitters, or ebooks, focus on it and you'll get very far. Seriously.
One Command to Change the Last Git Commit Message
Tags: git, bash, zsh
Published: 2018-09-14 10:35:53

---
title: One Command to Change the Last Git Commit Message 
published: true
description: Ever wanted to amend the git commit message that you just committed and pushed it to remote as well. Well, I wrote one single bash function to deal with it.
tags: git, bash, zsh
---

🔥 Hot-tip: Do you mess up git commit messages quite often? I DO!

![image](https://on.ahmda.ws/0e213760255b/c)

Most of the time I have to amend the last git commit message. So, I made a small bash function out of it. 

```sh

# Amend the last commit message.
# Push the changes to remote by force.
# USAGE: gamend "Your New Commit Msg"
function gamend() {
	git commit --amend -m "$@"
	git push --force-with-lease
}
```

> ⚠️ Avoid `--force` unless it is absolutely necessary and you can be sure that nobody else is syncing your project at the same time.

> ℹ️ Why git push --force-with-lease! If someone else pushed changes to the same branch, you probably want to avoid destroying those changes. The --force-with-lease option is the safest, because it will abort if there are any upstream changes.

✅ Amend git commit in one go
🤖 Put it in .bashrc/.zshrc etc files
👌 Sharing this quick-tip is a fun thing to do


{%tweet 1040539814536392709 %}
Contributing to an open source project for the first time! 
Tags: googletest, cpp, algos
Published: 2018-09-14 12:46:23

---
title: Contributing to an open source project for the first time! 
published: true
description: Things I realized when I started contributing
tags: #GoogleTest #CPP #Algos
---


Alright, so here is the truth. I have been testing everyone's code, except my own! To be more precise, I've been involved in customer acceptance testing more than integration testing and NEVER in unit testing.
I started working early, so I practically never had much free time and never contributed to any open source projects. When I moved to Germany, I was pretty sure I could finally make time to contribute, thinking I was the one "giving". 
The task I'm at is pretty easy, "write down the shunting yard algorithm and test it". Did the first part in a few minutes, and have been stuck for two to three days since! I mean... Testing was my job, it was what I did for 6 years, wasn't it!? I should've been way better at it!
I've been reading on and clicking on every single documentation page of GoogleTest to figure out where it goes wrong.
Apart from the frustration I feel, there's something else I feel as well, satisfaction. I am finally learning to "learn" and understanding that contribution isn't about me "giving" but also about me becoming aware of what I do not know. 

P.S. probably very bad timing to get stuck on googleTest since I also have a couple of exams in October :-D
Simple snippet to make Node's built in modules globally accessible
Tags: javascript, node, snippet
Published: 2018-09-16 13:18:42

---
title: Simple snippet to make Node's built in modules globally accessible
published: true
description: This will create a global.fs, global.childProcess, global.http and so on.
tags: javascript, node, snippet 
---

I am very lazy and don't want to type the same _fs = require('fs')_ in every little thing I'm doing and every temporary file that is just a means to an end and will never be used in production. 

I decided to share this little snippet that iterates Node's internal (built in) modules and globalizes only the _valid_ ones. The invalid ones are those you can't or shouldn't require directly such as internals and 'sub modules' (containing a '/').  Simply include _globals.js_ or copy paste from below.

The [camelcase](https://github.com/sindresorhus/camelcase/blob/master/index.js) function is only there to convert *child_process* into *childProcess*. If you prefer to have no NPM dependencies then just copy paste the function from GitHub or _leave it out entirely_ because camelcasing is only cute and not necessary.

#### globals.js

```js
/* https://github.com/sindresorhus/camelcase/blob/master/index.js */
const camelCase = require('camelcase')

Object.keys(process.binding('natives')).filter(el => !/^_|^internal/.test(el) && [
    'freelist',
    'sys', 
    'worker_threads', 
    'config'
].indexOf(el) === -1 && el.indexOf('/') == -1).forEach(el => {
    global[camelCase(el)] = require(el) // global.childProcess = require('child_process')
})
```

Just require that somewhere and all built in modules are global.

```js
require('./globals')

fs.writeFileSync('dir.txt', childProcess.execSync('dir'))
```

These are the modules exposed to the global scope (Node v10.10.0)

```text
asyncHooks
assert
buffer
childProcess
console
constants
crypto
cluster
dgram
dns
domain
events
fs
http
http2
https
inspector
module
net
os
path
perfHooks
process
punycode
querystring
readline
repl
stream
stringDecoder
timers
tls
traceEvents
tty
url
util
v8
vm
zlib
```
> Um. I suggest we start using the [#snippet](https://dev.to/t/snippet) tag to share snippets with each other. =)
Shell Aliases For Easy Directory Navigation #OneDevMinute
Tags: onedevminute, devtips, shell, zsh
Published: 2018-09-21 16:24:48

---
title: Shell Aliases For Easy Directory Navigation #OneDevMinute
published: true
description: Shell Aliases For Easy Directory Navigation #OneDevMinute
tags: OneDevMinute, DevTips, Shell, Zsh
---

> 🔥 #OneDevMinute is my new series on development tips in one minute. Wish me luck to keep it consistent on a daily basis. Your support means a lot to me. Feedback on the video is welcomed as well.

Ever had that typo where you wrote `cd..` instead of `cd ..` — well this tip not only addresses that typo but also adds a couple other aliases to help you easily navigate through your systems directories. More in the video…
 

[![OneDevMinute](https://on.ahmda.ws/e2c49e90907e/c)](https://www.youtube.com/watch?v=x-on-xD3OdE&feature=youtu.be)


```sh
################################################
# 🔥 #OneDevMinute
#
# Daily one minute developer tips.
# Ahmad Awais (https://twitter.com/MrAhmadAwais)
################################################

# Easier directory navigation.
alias ~="cd ~"
alias .="cd .."
alias ..="cd ../.."
alias ...="cd ../../.."
alias ....="cd ../../../.."
alias cd..="cd .." # Typo addressed.
```
---

> Copy paste these aliases at the end of your `.zshrc`/`.bashrc` files and then reload/restart your shell/terminal application.


{%tweet 1043164426860408832 %}


> If you'd like to [📺 watch in 1080p that's on Youtube →](https://www.youtube.com/watch?v=x-on-xD3OdE)
> This is a new project so bear with me. Peace! ✌️
How to conduct project post-mortem? 
Tags: discuss
Published: 2018-09-22 14:56:14

---
title: How to conduct project post-mortem? 
published: true
description: 
tags: #Discuss
---
What are your tips or strategies in conducting a post-mortem?
Can it be conducted offline?
When is the best time to do it?
Any memorable/funny/insightful post-mortem experience?
Build Chatbot for Twitter Direct Message
Tags: twitterchatbot, node, twitterapi, directmessage
Published: 2018-09-23 06:18:42

---
title: Build Chatbot for Twitter Direct Message
published: true
description: Sample scripts to get started with Twitter's premium Account Activity API (Direct Messages Activities). Written in Node.js. Full documentation for this API can be found on developer.twitter.com
tags: Twitter Chatbot, node.js, twitter api, direct message
cover_image: https://thepracticaldev.s3.amazonaws.com/i/jo95kfgwwoymilunmypw.jpg
---

#Step 1: Get Developer account
https://developer.twitter.com/en/apply-for-access
Note: Review & approval usually takes 10–15 days.

#Step 2: Create Twitter App & Dev Environment
https://developer.twitter.com/en/account/get-started

#Step 3: Generate app access token for the direct message using twitter developer portal
Note: Change the app permissions to "Read, write, and direct messages" & generate the access token.

#Step 4: Create the Node module & run it.
{% codepen https://codepen.io/sandeshsuvarna/pen/gdyXWg %}
Run command: node app.js

#Step 5: Tunnel to your localhost webhook using Ngrok
run the following command on the same directory using terminal/command prompt: ngrok http 1337
Copy the "https" url. (It will be something like https://XXXXXX.ngrok.io)

#Step 6: Download account activity dashboard
Git clone https://github.com/twitterdev/account-activity-dashboard.git
run the module using "npm start" using the terminal/command prompt

#Step 7: Attach Webhook
open "localhost:5000" on the browser.
Click on "Manage Webhook"
Paste the "ngrok url" into "Create or Update Webhook" field & click submit

#Step 8: Add a user/page subscription
Open terminal/Command prompt
Goto "account activity dashboard" folder
execute "node example_scripts/subscription_management/add-subscription-app-owner.js -e <TWITTER_DEV_ENV_NAME>"
note: Add user subscription for the user that owns the app.

##Goto Twitter DM & start talking to your bot


###Thanks for reading! :) If you enjoyed this article, hit that heart button below ❤ Would mean a lot to me and it helps other people see the story.
Instabot
Tags: bot, instagram, python3, python
Published: 2019-04-14 19:21:28

---
title: Instabot
published: true
description: Instagram promotion and SMM scripts. Forever free. Written in Python.
tags: bot, instagram, python3, python
---

# Instabot

Instagram promotion and SMM scripts.
Forever free. Written in Python.

---
### [Read the Docs](https://instagrambot.github.io/docs/) | [Contribute](https://github.com/instagrambot/docs/blob/master/CONTRIBUTING.md)
---

[![Telegram Chat](https://img.shields.io/badge/chat%20on-Telegram-blue.svg)](https://t.me/instabotproject)
[![paypal](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/okhlopkov)
![Python 2.7, 3.5, 3.6, 3.7](https://img.shields.io/badge/python-2.7%2C%203.5%2C%203.6%2C%203.7-blue.svg)
[![PyPI version](https://badge.fury.io/py/instabot.svg)](https://badge.fury.io/py/instabot)
[![Build Status](https://travis-ci.org/instagrambot/instabot.svg?branch=master)](https://travis-ci.org/instagrambot/instabot)
[![codecov](https://codecov.io/gh/instagrambot/instabot/branch/master/graph/badge.svg)](https://codecov.io/gh/instagrambot/instabot)


### Installation
Install `instabot` with:
```
pip install -U instabot
```
#### or see [this](https://instagrambot.github.io/docs/en/#installation) for more details.



![Instabot is better than other open-source bots!](https://raw.githubusercontent.com/instagrambot/docs/master/img/instabot_3_bots.png "Instabot is better than other open-source bots!")

If this library solved some of your problems, please consider buying me a coffee. :wink:

<a href="https://www.buymeacoffee.com/okhlopkov" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>
How Direct and Regular Mutual Funds Differ
Tags: learn, directmutualfunds, netassetvalue, regularmutualfunds
Published: 2018-09-29 09:17:05

---
title: How Direct and Regular Mutual Funds Differ
published: true
tags: Learn,Direct Mutual Funds,Net Asset Value,Regular Mutual Funds
canonical_url: 
---

It is hard to digest that though Direct and Regular Mutual funds have similar investment objectives, one must know the fact how they differ. This article is for mutual fund investors who want to know about how the direct and regular mutual funds are similar in terms of portfolio and how do they differ when it comes to returns.

The post [How Direct and Regular Mutual Funds Differ](https://mfrepublic.com/how-direct-and-regular-mutual-funds-differ/) appeared first on [MF Republic](https://mfrepublic.com).
I made a remote control application for iTunes Windows
Tags: showdev, firstpost, utilities, python
Published: 2018-09-29 19:19:52

---
title: I made a remote control application for iTunes Windows
published: true
description: Control your iTunes Windows application over LAN
tags: showdev, firstpost, utilities, python
cover_image: https://thepracticaldev.s3.amazonaws.com/i/q59j2b2wynh87lle56ep.png
---
## A minimal web based remote control for iTunes Windows application

To make life a little easy, here is my tiny application

A nodeJS server looks for requests on a local network and spawns a python script to perform the remote actions

Google assistant doesn't talk to iTunes on your PC? Let's fix that – \*poof\* **pyTunes**

Just head over to [Dialogflow](https://dialogflow.com/) and set up your Google Actions and Fulfillment URL as your server address (Use ngrok to expose localhost to public)

Name of the repo is pyTunes and minority of the code is in python 🙃
![REALLY FUNNY IMAGE](https://thepracticaldev.s3.amazonaws.com/i/cg21rsziyaf6ab1fetcl.PNG)

Thanks for reading!

Here's a cake 🍰 and [pyTunes](https://goo.gl/eDZ3np)

Good day/night. Cheers 🍻
Hiring process: should I review some candidate's code looking for errors or potential for being better?
Tags: discuss
Published: 2019-04-16 02:00:10

---
title: Hiring process: should I review some candidate's code looking for errors or potential for being better?
published: true
tags: discuss
---

My experience is that it is much more common to look for errors when reviewing code submited by a candidate during the hiring process, things like:
- this class has too much responsibility
- that class does too little
- pattern X is not implemented correctly
- etc...

My current company is like this, and after reviewing their code we invite the candidate to discuss it: we read/explain our comments and they defend their decisions. After the discussion I'm feeling really tired (the mood is more confrontation than collaboration,) and I'm not sure what kind of person does well in this kind of process.

So I thought about it and realized that instead of looking for errors I could look for potential for making that code better, just like normal code review:
- this class has too much responsibility, what about extract this and that into another class?
- this class does too little, what about moving it into that other class?
- if you change this and that the code will implement pattern X

On one hand this leads the candidate to an easy answer but on the other hand we know how they respond the a code review.

Any thoughts/experience on reviewing code for hiring?