teleren/devto huggingface dataset:
Custom git credential helper
Tags: git, python
Published: 2019-05-02 13:08:34

---
title: Custom git credential helper
published: true
description: 
tags: git, python
---

### Git credential helper:
Git credential helper is used to save user credentials, so that user does not require to enter credentials on each git operation.
Git provides few default git credential helpers, [see how to use them](https://git-scm.com/docs/gitcredentials).
This blog will demonstrate on how to build custom git credential helper.


**Simple python cli:**
- Let's write a python cli called `auth_helper.py`

  ```python
  #!/usr/bin/env python
  import argparse

  class Credential(object):
      def get(self):
          # logic to get username/password from auth file
          pass
      def store(self):
          # logic to store username/password to auth file
          # its better to encrypt password if its in plain text
          pass
      def erase(self):
          # logic to delete auth file
          pass

  def main():
      parser = argparse.ArgumentParser()
      parser.add_argument('operation', action="store", type=str,
              help="Git action to be performed (get|store|erase)")
      # parser all arguments
      arguments = parser.parse_args()
      # get credentials
      credentials = Credential()

      if arguments.operation == "get":
          creds = credentials.get()
          print("username={0}".format(creds.get("username")))
          print("password={0}".format(creds.get("password")))
      elif arguments.operation == "store":
          credentials.store()
          # if credentials are already stored do not store again
      elif arguments.operation == "erase":
          credentials.erase()
      else:
          print "Invalid git operation"

  if __name__ == "__main__":
      main()
  ```

- This cli takes three git operations as cli arguments `get`, `store` and `erase`.
- These arguments are not coincident, they are used by git. Let's know more about them.


**Git credentials store:**
- Git credentials store looks for three arguments
    - `get`: called when triggered git pull, git fetch, git push etc.
    - `store`: called when triggered git pull, git fetch, git push etc.
    - `erase`: if our provided credentials fail, git will fallback to its own credentials prompt, if this fails as well `erase` is called.


**Git helper configuration:**
- To configure our cli as git helper, trigger the below command

  ```bash
  git config --global credential.https://git.company.com.helper "./path/to/cli/auth_helper.py"
  ```

- This will define `auth_helper.py` under `credential` section of `.gitconfig` file (user's home directory).
- `https://git.company.com` is the domain where git is hosted.


**Done!!** Next time we use git, our `auth_helper.py` should provide credentials for git authorization.
Custom ansible modules
Tags: python, ansible
Published: 2019-05-02 12:58:56

---
title: Custom ansible modules
published: true
description: 
tags: python, ansible
---

### How to write ansible custom modules
Ansible modules are easy way to interact between an existing application and ansible playbook. This blog covers how to write your own ansible module.


**Module**
- Create a python file called `greet.py` with following content

  ```python
  def main():
      module = AnsibleModule(
          argument_spec = dict(
              message = dict(required=True, type="str"),
          ),
          supports_check_mode=True
      )

      # get module params
      message = module.params.get("message")

      try:
          module.exit_json(changed=True, msg=message)
      except:
          module.fail_json(msg="It's bad not to greet someone")

  from ansible.module_utils.basic import AnsibleModule
  if __name__ == "__main__":
      main()
  ```

- File name `greet.py` is considered as ansible module.
- Arguments defined in ansible playbooks will be parsed by `AnsibleModule` class.
- Ansible module always returns json, for convenience ansible provides two methods, one for success and other for failure

  ```python
  # For success
  module.exit_json(changed=True, msg=message)

  # For failure
  module.fail_json(msg="It's bad not to greet someone")
  ```

**Usage**
- Create an ansible playbook called `playbook.yml`

  ```bash
  touch playbook.yml
  ```

- Create directory `library` alongside `playbook.yml` and copy `greet.py` to `library`

  ```bash
  mkdir library
  cp greet.py library
  ```

- Now our directory structure should look like

  ```bash
  library
      |- greet.py
  playbook.yml
  ```

- We can now use `greet` module with our `playbook.yml`

  ```yaml
  ---
  - hosts: localhost
    tasks:
    - name: Lets start greeting
      greet:
          message: "Good morning"
  ```
What do you do when you don't feel productive
Tags: productivity, discuss
Published: 2019-05-02 12:48:28

---
title: What do you do when you don't feel productive
published: true
description: 
tags: #productivity #discuss
---

We all have those days where we feel really not productive, your brain is just like "Not today".

I was wondering if you have tips to still be productive by doing some other stuff and not stay staring at your computer waiting for miracles.
Setup NFS and SMB server on Raspberry Pi
Tags: nfs, smb, raspberrypi
Published: 2019-05-02 12:44:16

---
title: Setup NFS and SMB server on Raspberry Pi
published: true
description: 
tags: nfs, smb, raspberrypi
---

### NFS server
- Install server

  ```bash
  sudo apt install nfs-common nfs-server
  ```

- Create directory you wanna share

  ```bash
  mkdir /media/storage
  ```

- Edit file `/etc/exports` with below content

  ```bash
  /media/storage 192.168.1.0/24(rw,all_squash,insecure,no_subtree_check)
  # <directory> <who_can_access> <options>
  ```

- Restart services

  ```bash
  sudo service nfs restart
  /etc/init.d/nfs-kernel-server restart
  ```

- Connecting from client (MacOS)

  ```bash
  mkdir /Users/username/nfs_shared
  sudo mount -v -o "resvport" 192.168.1.9:/media/storage /Users/username/nfs_shared
  ```


### Samba server
- Install server

  ```bash
  sudo apt-get install samba samba-common-bin
  ```

- Create samba password for system user

  ```bash
  sudo smbpasswd -a pi
  ```

- Create directory you wanna share

  ```bash
  mkdir /media/storage
  ```

- Edit file `/etc/samba/smb.conf` with below content

  ```bash
  [PI]
  comment = Pi workspace
  path = /media/storage
  create mask = 0775
  directory mask = 0775
  read only = no
  browseable = yes
  public = no
  force user = pi
  only guest = no
  ```

- Restart service

  ```bash
  sudo service samba restart
  ```

- Connecting from client (MacOS)

  ```bash
  mkdir /Users/username/smb_shared
  mount -t smbfs //pi@192.168.1.9/pi /Users/username/smb_shared
  ```
PC DECODE ep1_in the beginning
Tags: podcast, thetealpickle, bornbklyn, beginners
Published: 2019-05-02 12:32:18

---
title: PC DECODE ep1_in the beginning 
published: true
description: The influencers of the computer
tags: #podcast #thetealpickle #bornbklyn #beginners
---

EPISODE 1 of the B0RN BKLYN PC DECODE podcast series is out!
PC DECODE: Decoding the Personal Computer.

💻 The influencers of the computer 💻
😍 Ada Lovelace, Charles Babbage, Konrad Zuse, John Von Neumann, and Alan Turing made MAJOR MOVES 😍

Check out the podcast to find out how things went down 🤯

<a href="https://www.google.com/podcasts?feed=aHR0cHM6Ly9hbmNob3IuZm0vcy85NTVkY2IwL3BvZGNhc3QvcnNz"><b>Google Podcasts</b></a>

<a href="https://open.spotify.com/show/5gbbRUOUCrADmLmZgfueyB"><b>Spotify</b></a>

<a href="https://www.breaker.audio/b0rn-bklyn"><b>Breaker</b></a>

<a href="https://pca.st/wuM8"><b>Pocket Casts</b></a>

<a href="https://open.spotify.com/show/5gbbRUOUCrADmLmZgfueyB"><b>Anchor</b></a>

<a href="https://radiopublic.com/b0rn-bklyn-GqkB3o"><b>Radio Public</b></a>
What Makes Good Developer Tools... Good?
Tags: discuss, javascript, webdev, productivity
Published: 2019-05-02 12:20:02

---
title: What Makes Good Developer Tools... Good?
published: true
description: Our world is filled with tools that promise to make our lives easier... what separates the good from the bad?
tags: discuss, javascript, webdev, productivity
---

I've known for a long time that developer tools are _the thing I care about_ in tech – making other developers lives even easier is something I aspire to. Often, though, I wonder if my ideas of what makes developer tools good is also what _others_ think makes developer tools good.

So, I'd like to ask:

> **What makes your favorite developer tool _good_?**


Would love to hear from you in the comments so I can better understand from _your_ perspective ❤️
The Impact of Artificial Intelligence on Business
Tags: artificial, intelligence, impactofaionbusiness, aiinbusiness
Published: 2019-05-02 11:39:44

---
title: The Impact of Artificial Intelligence on Business
published: true
description: Artificial Intelligence in Business. The impact of Artificial Intelligence on business. Progressed artificial intelligence (AI) methods are improving business forms from the plant floor to the client's entryway. Used further bolstering its fullest good fortune, AI can possibly change each part of the business: from the store network and coordination to HR and showcasing even to client care and past.
tags: Artificial, intelligence, impact of AI on business, AI in business
---
<img src="https://thepracticaldev.s3.amazonaws.com/i/helr78zk83nbqkg13hxk.png">

Artificial Intelligence in Business. The impact of Artificial Intelligence on business. Progressed artificial intelligence (AI) methods are improving business forms from the plant floor to the client's entryway. Used further bolstering its fullest good fortune, AI can possibly change each part of the business: from the store network and coordination to HR and showcasing even to client care and past.

Read the full article here: https://www.decipherzone.com/blog-detail/The-Impact-of-Artificial-Intelligence--AI--on-Business

In any case, that potential regularly accompanies detours that could avert a full acknowledgement of the proposed advantages. Organizations who actualize AI arrangements without first mapping out these conceivable hindrances may not be designating their assets in the most ideal ways that could be available.
Making commands complicated
Tags: hacks, hardmode
Published: 2019-05-02 11:27:35

---
title: Making commands complicated
published: true
description: Why do things the easy way? Go even further beyond your limits!
tags: #hacks #hard-mode
---

Sometimes running the same ol'boring `git checkout` can be disinteresting, often rendering your brain zombified. Frozen in this malaise and unable to try anything else, your weary, dreary soul is left with entering repetitive commands all night long.

Why not spice things up a bit? Try changing up one of your more frequent commands to be 👩🏻‍💻, 💪🏻 and 🥇.

##### Easy 🚮 
`git checkout virt-server-things`

#### Better ❕
`git checkout ($(git branch | Select-String "virt") -replace " ", "")`

Of course, this all fails if there's 2 branches with that name ... but who has one more than 1 active branch 😅 

What trivial commands have you converted to hard-mode? Seen any over-complicated code in your codebase? 

#### Remove all docker images that I had used for Kubernetes training
`docker rmi $(docker images | grep "k8s" | awk '{ print $3 }')`
On-prem ansible galaxy
Tags: python, ansible
Published: 2019-05-02 11:12:51

---
title: On-prem ansible galaxy
published: true
description: 
tags: python, ansible
---

Generic ansible roles can be shared through [ansible galaxy](https://galaxy.ansible.com), however, its hard to access ansible-galaxy from within corporate network. A good alternative is to host something similar to ansible-galaxy on-prem.


**On-prem galaxy repository**
- For this blog stash is considered (https://stash.company.com), however, gitlab, gogs or similar should work as well
- Create a new project on stash `Ansible Galaxy` with key `AG`
- Create repo for each generic ansbile role.
- All generic ansbile roles can be browsed at https://stash.company.com/projects/AG
- Now these roles can be used with multiple ansible playbooks.


**Usage**
- Create a new file `requirements.yml` alongside ansible `playbook.yml`.
- For this blog purposes I am considering `awscli` as an generic ansible role with its own repo, which resides in our newly created stash project `Ansible Galaxy (AG)`
- Copy/paste below content to `requirements.yml`

  ```yaml
  ---
  name: awscli
  src: git+https://stash.company.com/scm/ag/awscli
  version: master
  path: ~/.ansible/roles

  # name - name of role
  # src - location of role
  # version - which branch the role should be installed from
  # path - where we want to install roles
  ```

- The `requirements.yml` files acts as a role dependency list for our `playbook.yml`


**Installation**
- Once we define our ansible playbook dependencies, its time to install them.

  ```bash
  sudo ansible-galaxy install -r requirements.yml
  # NOTE: no need to install ansible-galaxy seperately, it ships with default ansible installation
  ```

- Done! all the roles are now installed and ready to be used by our `playbook.yml`
SemVer versioning utility
Tags: python, semver, npm, dep
Published: 2019-05-02 10:57:21

---
title: SemVer versioning utility
published: true
description: 
tags: python, semver, npm, dep
---

### Versioner
Version reader/writer for popular package managers as per [SemVer](https://semver.org/)

**Installation**

  ```bash
  pip install git+https://github.com/VeritasOS/versioner.git
  ```

**Current support**
- npm
- dep
- json
- toml
- yaml (currently multi doc in single file not supported)


**Usage**
- Read version (run command from project root)

  ```bash
  > versioner read npm  # projects based on npm
  "0.0.1"

  > versioner read dep  # golang projects
  "0.1.1"
  ```

  - Write version (run command from project root)

  ```bash
  # package.json
  ....
  "version": "1.1.1",
  ....

  # Release patch version
  > versioner write npm --inc-patch

  # package.json
  ....
  "version": "1.1.2",
  ....

  # Release minor version
  > versioner write npm --inc-minor

  ....
  "version": "1.2.0",
  ....

  # Release major version
  > versioner write npm --inc-major

  ....
  "version": "2.0.0",
  ....
  ```

  - Read version from custom file

  ```bash
  > versioner read yaml --file /root/app/version.yaml --key-depth metadata,version
  0.0.2

  version.yaml
  ---
  metadata:
    version: 0.0.2
  ```

- Write version to custom file

  ```bash
  > versioner write yaml --inc-major --file /root/app/version.yaml --key-depth metadata,version

  version.yaml
  ---
  metadata:
    version: 1.0.0
  ```

#### Development

  ```bash
  git clone https://github.com/VeritasOS/versioner.git
  cd versioner
  pip install -e .
  ```

**NOTE**
- This utility is tested for npm and dep.
- Read/write for custom file may break, please feel free to send a patch.

{% github VeritasOS/versioner %}
Introduction to Vue Render Functions (w/ examples)
Tags: javascript, webdev, showdev, vue
Published: 2019-05-07 14:14:31

---
title: Introduction to Vue Render Functions (w/ examples)
published: true
tags: javascript, webdev, showdev, vue
canonical_url: https://snipcart.com/blog/vue-render-functions
---

![Introduction to Vue Render Functions (w/ examples)](https://snipcart.com/media/204322/vue-js-render.jpeg)

Lately, I’ve been reading Dr. Harari’s book “Sapiens.” If you haven’t read it yet, you should. 

It’s killer.

Plus, it makes you appreciate our specie’s progress through the creative use of technology. And just like our ancestors' living 10,000 years ago, we’re constantly using new tools to advance and evolve (we’ve just come very far from sticks and stones). But the only way to make sure you’re using a tool as efficiently as possible is to first understand exactly how it works. 

So, today, for us digital sapiens, I want to dive into Vue render functions so that you can have a better understanding of [Vue.js](https://snipcart.com/blog/vue-js-seo-prerender-example) as a whole. 

More specifically, I’m going to:


- Define Vue render functions
- Show when render functions are useful
- Demonstrate how to compile templates into render functions
- Teach you how to create a component that allows you to override a template

And as you’ve probably come to expect, we’ll provide plenty of examples along the way :) 

Let’s dive in!

  

→ Read the full post [here](https://snipcart.com/blog/vue-render-functions)
Can You Actually Learn JavaScript From an Online Course?
Tags: javascript, beginners
Published: 2019-05-02 13:49:51

---
title: Can You Actually Learn JavaScript From an Online Course?
published: true
tags: JavaScript, Beginner
canonical_url: https://carlanderson.xyz/can-you-learn-javascript-from-a-course/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/7pn644zzz90y2esfez0r.jpg
---

When you see someone on Udemy promising to take you from JavaScript Zero to JavaScript Hero in only 2 weeks, it's easy to be skeptical. What about courses like FreeCodeCamp? Can you _actually_ become a developer solely by doing an online course?

The answer is... _kind of._

To be a developer (in any language), you need two sets of skills:  
1. You need to know a programming language  
2. You need to know how to _build software_ (or websites, etc)  
  
Online courses do a very good job of teaching you #1 - if you complete an online course for JavaScript, you'll come out with a good knowledge of the building blocks of JavaScript.

Where you will be weak is knowing how to apply that knowledge - even courses that promise to teach you using "real projects" will often have you copy-paste large swaths of code, but do very little to help you go out and apply that knowledge on your own.

## Learning to build

So how do you learn to build software?

It can be tempting to start learning with a big project (you can learn JavaScript while you build your big business idea: Uber for Parsnips, right?), I'd recommend against it - _big projects do not make for good learning_.

The best way to learn to build software is to create small, bite-sized projects that you can complete somewhere between an hour and a weekend. What this means depends entirely on you, and how comfortable you are with coding.

In general, focus on learning one thing at a time, and stack them. Coding tends to build off previous knowledge, so paying attention to simpler concepts and taking the time to get comfortable will help you _dramatically_ when you move into more difficult concepts.

Most importantly: _do the work_.

[Having a hard time learning JavaScript? Sign up to my newsletter for articles like this straight to your inbox](https://pages.convertkit.com/9f030a68c9/cd303b3d7b).
data science
Published: 2019-05-02 09:51:16

---
title: data science
published: true
description: 
tags: 
---

hi fellow devs,

So I have recently completed my bsc degree in Computer Science and have recently started an internship. My biggest issue right now is I have been given a Data Science project, mind you I have no knowledge in data science so I am kind of confused on where to begin, and wanted to know if there are any free data science courses online. can somebody help me :) .
UnityのAnimation Eventで関数定義と関数選択が分かりにくかった
Tags: unity3d
Published: 2019-05-02 09:44:00

---
title: UnityのAnimation Eventで関数定義と関数選択が分かりにくかった
published: true
tags: Unity
date: 20190502T09:44Z
canonical_url: https://qiita.com/shiena/items/ea2dd27b593d8f87be51
---
# はじめに

[アニメーションイベントの使用 - Unity マニュアル](https://docs.unity3d.com/ja/current/Manual/animeditor-AnimationEvents.html)と[[Unity] Animation Eventを使いこなそう！](https://qiita.com/yun_T/items/58e77d3396ded286affc)を参考に自作アニメーションにAnimation Eventをつけようとしたのですがインスペクターの挙動が分かりにくいのでまとめました。

# Animation Eventの関数定義

1. プロジェクトタブでAnimationファイルを選択します。
1. アニメーションタブでAnimation Eventを選択します。
1. インスペクターに関数定義が出てきます。

![image.png](https://dev-to-uploads.s3.amazonaws.com/i/vmijuat7n5pviypidsk5.png)

# Animation Eventの関数選択

1. ヒエラルキーで上記Animationを含むAnimation Controllerを関連付けたゲームオブジェクトを選択します。
1. アニメーションタブでAnimation Eventを選択します。
1. インスペクターに関数選択が出てきます。

![image.png](https://dev-to-uploads.s3.amazonaws.com/i/6p6bl3bu7d9hcfbdl64c.png)

# まとめ

何でこんな挙動なのか考えてみると分かったのですが、関数定義はAnimation Eventの定義はAnimation自体にあるのでファイルを選択してから、関数選択は同じゲームオブジェクトにアタッチしたスクリプトから選ぶのでヒエラルキーのゲームオブジェクトを選択してからなので納得できます。とは言え直前に選択したもので挙動が変わるのは分かりづらい…

# 参考リンク

* [アニメーションイベントの使用 - Unity マニュアル](https://docs.unity3d.com/ja/current/Manual/animeditor-AnimationEvents.html)
* [[Unity] Animation Eventを使いこなそう！](https://qiita.com/yun_T/items/58e77d3396ded286affc)
search_flip v2.0.0 - Chainable Elasticsearch Queries
Tags: ruby, elasticsearch, rails
Published: 2019-05-02 09:35:41

---
title: search_flip v2.0.0 - Chainable Elasticsearch Queries
published: true
tags: #ruby, #elasticsearch, #rails
---

<a href="https://github.com/mrkamel/search_flip">search_flip</a>, the ElasticSearch client with elegantly chainable queries and a minimal set of dependencies is just released as v2.0.0 now. This version includes a huge bunch of great new features: improved alias, routing, bulk, analyze and connection support to name just a few. Great docs included.

<a href="https://github.com/mrkamel/search_flip">https://github.com/mrkamel/search_flip</a>
How to redirect COM port in Virtual Machine - 2019 full guide
Tags: comport, serialport, virtualmachine
Published: 2019-05-02 09:33:49

---
title: How to redirect COM port in Virtual Machine - 2019 full guide
published: true
description: The simplest way to access com port in virtual machine - software to forward RS232 in virtual machine and manual to work with COM port.
tags: com port, serial port, virtual machine
---
Virtualization provides us a simple and efficient way to use multiple OS environments on the identical pc. By running a virtual machine on your current OS, you get the flexibility to test out different operating systems, access software system or applications designed for them, produce OS backups, etc. What’s convenient is that you just solely need one set of physical resources, like CPU and RAM and disk drive space.

![Virtual machine serial port](https://www.serial-server.net/imgnew/products/sec/splash/img4@2x.png)

If you have got a serial printer, modem or any other COM-based peripheral connected to your local computer and need to attach this device to your virtual machine, you'll be able to do that via a virtual com port. want to know a way to change a COM port in a virtual machine? Well, it all depends on the virtualization software system you use. Some virtualization apps allow you to connect to your host’s serial devices when you just create some additional configurations, whereas alternative solutions supply no access to physical serial ports of the host pc unless you use a dedicated third-party tool operating over the network.

[In this article](https://www.serial-server.net/com-port-in-virtual-machine.html), I’ll describe several common strategies to change COM port redirection in a virtual machine.