Managing Python Virtual Environments with pyenv

When using Python, you’ll encounter various version environments. First, distributions like RedHat and Debian have their own system Python installed, and you can also use Python built from source on a per-account basis as needed. Python has major syntax and built-in library differences between 2.x and 3.x versions, and minor versions can have different behaviors or implementations in some features - a free but sometimes risky situation. Of course, if you only operate one project on a single system and the version will never change, you may not need to worry about this. However, generally, a single system can have various Python projects, and these may often be implemented based on different Python versions. If you reduce cohesion between projects through dependency isolation, individual projects don’t need to worry about other environments. ...

2017-04-02 · 12 min · 2421 words · Sung-Kyu Yoo

Understanding the alternatives Command

alternatives (or update-alternatives) is a GNU-licensed command-line tool that provides functionality to create, remove, manage, and query symbolic links. In other words, it allows defining default versions or paths for specific commands through symbolic links. Note that Debian-based Linux distributions only provide the update-alternatives command (the original alternatives script was reimplemented to remove perl language dependency), and there are some differences in functionality compared to RedHat-based Linux commands, but this article covers only common functionality and options. Examples are based on RedHat. ...

2017-03-17 · 9 min · 1815 words · Sung-Kyu Yoo

Ansible Galaxy - Managing Role Dependencies Using Git Repositories

Uploading Ansible Role to Git Repository First, create a Git repository for developing an Ansible Role. Then, generate the initial Ansible Role project structure using Ansible Galaxy. Clone the Git repository to your local machine. 1 $ git clone "https://github.com/xxxxx/sample-role.git" Generate Ansible Role initial directory and files. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 $ ansible-galaxy init --force sample-role - sample-role was created successfully $ tree sample-role/ sample-role/ ├── README.md ├── defaults │ └── main.yml ├── files ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── templates ├── tests │ ├── inventory │ └── test.yml └── vars └── main.yml After developing the Ansible Role, push to Git repository. 1 $ git commit * -m "Add ansible role" && git push Downloading Ansible Role from Git Repository Method 1) Download via Ansible Galaxy CLI 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 $ ansible-galaxy install git+https://github.com/xxxx/sample-role.git,master -p roles/ $ tree roles/ roles/ └── sample-role ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars └── main.yml Method 2) Specify in dependency file and download via CLI 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 $ vi requirements.yml - src: git+https://github.com/xxxx/sample-role.git version: master $ ansible-galaxy install -r requirements.yml -p roles/ - extracting sample-role to roles/sample-role - sample-role was installed successfully $ tree roles/ roles/ └── sample-role ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars └── main.yml Writing ‘requirements.yml’ src username.role_name: Used to download Ansible Roles registered in the official Ansible Galaxy repository. url: Used to download from SCMs supported by Ansible Galaxy. scm Specify the SCM name to integrate. Default is ‘git’ (as of ansible-galaxy 2.2.1.0, only git and hg are supported) version Specify tag name / commit hash / branch name. Default is ‘master’ Only used when downloading from SCM. name Specify the name of the downloaded Ansible Role. By default, uses the name registered in Ansible Galaxy or the Git repository name. See the examples below: ...

2017-02-16 · 7 min · 1425 words · Sung-Kyu Yoo

Deep Dive into Java 8 Lambda Expressions

Started as ‘Project Lambda’ in 2010, it was officially released in Java 8. This article details how functional programming was incorporated into the existing Java language. Brief Overview of Functional Programming Before introducing Java’s lambda expressions, we need to briefly understand functional programming. (Functional programming based on lambda calculus is a paradigm, and lambda expressions represent it!) Functional programming is a paradigm that creates output relying only on function input, avoiding changing external state, minimizing side-effects. Functional programming must satisfy the following conditions: ...

2016-11-09 · 16 min · 3199 words · Sung-Kyu Yoo

Exploring Java 8

This article summarizes the features added in Java 8. It covers the overall content, and more detailed information can be found in the attached related links. Summary of New Features Lambda Expression (a.k.a Anonymous Method) The foundation of Java’s lambda expressions is based on ’lambda calculus’ proposed by Alonzo Church in the 1930s. It’s a formal system that abstracts function definition, function application, and recursive functions! For more details, refer to Lambda Calculus Wiki. ...

2016-10-25 · 13 min · 2605 words · Sung-Kyu Yoo