# Lazarus Lazaridis

Lazarus Lazaridis' personal blog with posts mostly related to programming and opensource. And cats.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## stup - Daily notes in the terminal

DevFeed: [stup - Daily notes in the terminal](<https://devfeed.tech/articles/stup-daily-notes-in-the-terminal-37457.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2020/04/20/stup-cli-notes>)

Author: Lazarus Lazaridis

Published: 2020-04-20T09:00:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Terminal](<https://devfeed.tech/topics/terminal.md>), [Code](<https://devfeed.tech/topics/code.md>), [opensource](<https://devfeed.tech/topics/opensource.md>)

Tags: [bash](<https://devfeed.tech/tags/bash.md>), [blocking](<https://devfeed.tech/tags/blocking.md>), [cli](<https://devfeed.tech/tags/cli.md>), [code](<https://devfeed.tech/tags/code.md>), [linux](<https://devfeed.tech/tags/linux.md>), [meetings](<https://devfeed.tech/tags/meetings.md>), [opensource](<https://devfeed.tech/tags/opensource.md>), [productivity](<https://devfeed.tech/tags/productivity.md>), [programming](<https://devfeed.tech/tags/programming.md>), [scripts](<https://devfeed.tech/tags/scripts.md>), [terminal](<https://devfeed.tech/tags/terminal.md>), [tools](<https://devfeed.tech/tags/tools.md>)

### AI overview

The article introduces stup, an open-source command-line tool for recording, organizing, and retrieving daily work notes from a terminal. It explains the tool's note categories, date-based storage, and commands for adding, viewing, and listing notes over time.

### Source excerpt

Over the past few years I have been participating in Stand-up meetings and it took me some time to find a convenient and effective way for keeping notes about what I was doing every day. I needed to be able to: keep notes on the issues I worked on, the meetings I participated in and stuff that blocked my work easily access these notes based on their date have an overview of what I did for example the last week all of the above from inside a terminal without having to manually structure and update a single document having to manually create a document for each day stup I created stup (the name derives from stand-up), an opensource CLI tool that deals with these issues and allows to easily save, access and organize my notes. The source code of the project is available on GitHub here. Usage examples Find below some examples showing the most important usage of stup. Adding notes # Adding a note to the default category at current date stup add -n "Worked on issue #ABC123" # Adding a note to the default category setting the current date explicitly stup add today -n "Worked on issue #ABC123" # Adding a note to the meetings category stup add today -c "meetings" -n "2 hours with @phoebe for the project kick off" # Adding a note to the blocking category for April 10th, 2020 stup add @ 2020-04-10 -c "blocking" -n "connectivity issues" Showing notes # Showing yesterday's notes $ stup # Showing yesterday's notes explicitly setting the date $ stup yesterday # Showing today's notes $ stup today # Showing notes on a specific date $ stup show @ 2020-04-18 # Showing notes on a specific date for the meetings category $ stup show @ 2020-04-18 -c "meetings" Retrieving all notes for a period of time # List current week's notes stup log week # List previous week's notes stup log previous-week # List notes between January 20th, 2020 and March 2nd, 2020 stup log --from 2020-01-20 --to 2020-03-02 # List meeting notes between January 20th, 2020 and March 2nd, 2020 stup log --from 2020-01-20 -

## Find palindrome dates in the Linux command line - explained

DevFeed: [Find palindrome dates in the Linux command line - explained](<https://devfeed.tech/articles/find-palindrome-dates-in-the-linux-command-line-explained-37456.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2020/02/06/shell-palindrome-dates>)

Author: Lazarus Lazaridis

Published: 2020-02-06T10:00:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [Terminal](<https://devfeed.tech/topics/terminal.md>)

Tags: [awk](<https://devfeed.tech/tags/awk.md>), [bash](<https://devfeed.tech/tags/bash.md>), [climagic](<https://devfeed.tech/tags/climagic.md>), [command-line](<https://devfeed.tech/tags/command-line.md>), [commands](<https://devfeed.tech/tags/commands.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [linux](<https://devfeed.tech/tags/linux.md>), [opensource](<https://devfeed.tech/tags/opensource.md>), [programming](<https://devfeed.tech/tags/programming.md>), [scripts](<https://devfeed.tech/tags/scripts.md>), [terminal](<https://devfeed.tech/tags/terminal.md>)

### AI overview

A tutorial explains a Linux command-line pipeline for finding palindrome dates. It breaks down brace expansion, date formatting, whitespace removal, reversing and comparing date strings with standard command-line tools.

### Source excerpt

Yesterday I saw a great command that finds the palindrome dates between now and x days ago. The command was posted on Twitter by @climagic (a great account to follow if you want to find awesome command line stuff). In this post we are going to break it down and explain how it works. What is a palindrome Palindrome is a word/number/phrase or other sequence of characters that reads the same backward as forward. - Palindrome - Wikipedia Few days ago, the date was 02/02/2020 which was a palindrome: The command printf "now - %d days\n" {1..332044} |date -f- +%Y%_m%_d$'\n'%Y%m%d |tr -d ' ' > alldates.txt; rev alldates.txt >revdates.txt; paste alldates.txt revdates.txt |awk '$1==$2{print $1}' And here's a more readable version using new lines after each pipe. printf "now - %d days\n" {1..332044} | date -f- +%Y%_m%_d$'\n'%Y%m%d | tr -d ' ' > alldates.txt; rev alldates.txt >revdates.txt; paste alldates.txt revdates.txt | awk '$1==$2{print $1}' I am going to explain each part of the command separately. Note that the output of each part is the input of the next part (following the pipe |). printf "now - %d days\n" {1..332044} The first part seems pretty straight forward but it does have an interesting part, the brace expansion mechanism, which I didn't know of. Open a terminal and type the following commands: # From 1 to 10 $ echo {1..10} 1 2 3 4 5 6 7 8 9 10 # From a to z $ echo {a..z} a b c d e f g h i j k l m n o p q r s t u v w x y z # From 10 to 20 $ echo Before-{10..20}-After Before-10-After Before-11-After Before-12-After Before-13-After Before-14-After Before-15-After Before-16-After Before-17-After Before-18-After Before-19-After Before-20-After As you can see, the brace expansion allows the generation of values based on a "sequence" we set. Learn more about the Brace expansion mechanism here. Part explained we print the phrase "now - x days" so many times as the number of values expanded from the sequence {1..332044} will generate 332044 values starting from 1 and in

## Vim

DevFeed: [Vim](<https://devfeed.tech/articles/vim-37455.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/12/20/thy-vim>)

Author: Lazarus Lazaridis

Published: 2019-12-20T07:00:00Z

Content type: article

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [Vim](<https://devfeed.tech/topics/vim.md>), [Processes](<https://devfeed.tech/topics/processes.md>)

Tags: [devhumor](<https://devfeed.tech/tags/devhumor.md>), [file](<https://devfeed.tech/tags/file.md>), [humor](<https://devfeed.tech/tags/humor.md>), [i](<https://devfeed.tech/tags/i.md>), [linux](<https://devfeed.tech/tags/linux.md>), [poem](<https://devfeed.tech/tags/poem.md>), [process](<https://devfeed.tech/tags/process.md>), [programming](<https://devfeed.tech/tags/programming.md>), [shell](<https://devfeed.tech/tags/shell.md>), [vim](<https://devfeed.tech/tags/vim.md>)

### AI overview

A humorous poem about learning Vim describes editing files, encountering read-only behavior, and struggling with shell commands and processes.

### Source excerpt

Roses are red Violets are blue I have stuck in vim And so have you. Vim ain't for newbies But I'm a curious soul So I went down That shell rabbit hole. I tried to edit hosts Everything went wrong The file remained open For two hours long. When I found the magic Semicolon double-u q The file was readonly You've been there too. The bells started ringing As I controlled + c What was I thinking I WANT TO BE FREE I had to stop the panic Said it'll all be fine I will just kill the process Using minus nine. -- iridakos

## Descriptive variable names

DevFeed: [Descriptive variable names](<https://devfeed.tech/articles/descriptive-variable-names-37454.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/12/12/descriptive-variable-names>)

Author: Lazarus Lazaridis

Published: 2019-12-12T07:00:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [Tool](<https://devfeed.tech/topics/tool.md>), [API](<https://devfeed.tech/topics/api.md>), [Development](<https://devfeed.tech/topics/development.md>), [Variable](<https://devfeed.tech/topics/variable.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [development](<https://devfeed.tech/tags/development.md>), [devhumor](<https://devfeed.tech/tags/devhumor.md>), [easily](<https://devfeed.tech/tags/easily.md>), [guide](<https://devfeed.tech/tags/guide.md>), [humor](<https://devfeed.tech/tags/humor.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [programming](<https://devfeed.tech/tags/programming.md>), [tool](<https://devfeed.tech/tags/tool.md>), [variable](<https://devfeed.tech/tags/variable.md>)

### AI overview

The supplied text describes an introduction and guide for installing and using DuckRails, a development tool for mocking API endpoints dynamically. It also states that a Docker image is available.

### Source excerpt

[others]: Variable names must be descriptive. [me]: $help-help-help: #F1F1F1;

## Introduction and guide to using DuckRails for dynamically mocking API endpoints

DevFeed: [Introduction and guide to using DuckRails for dynamically mocking API endpoints](<https://devfeed.tech/articles/pizza-commit-37452.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/12/04/pizza-commit>)

Author: Lazarus Lazaridis

Published: 2019-12-04T09:00:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [Tool](<https://devfeed.tech/topics/tool.md>), [Mocking](<https://devfeed.tech/topics/mocking.md>), [API](<https://devfeed.tech/topics/api.md>), [Docker](<https://devfeed.tech/topics/docker.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [devhumor](<https://devfeed.tech/tags/devhumor.md>), [docker](<https://devfeed.tech/tags/docker.md>), [guide](<https://devfeed.tech/tags/guide.md>), [humor](<https://devfeed.tech/tags/humor.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [mocking](<https://devfeed.tech/tags/mocking.md>), [programming](<https://devfeed.tech/tags/programming.md>), [tool](<https://devfeed.tech/tags/tool.md>)

### AI overview

An introduction and installation guide for DuckRails, a development tool for mocking API endpoints dynamically. The document also notes that a Docker image is available.

### Source excerpt

Me: $ git commit -m "Closes issue #13" * Remove obsolete reference to core entity * Refactor module generating values * Log every ac... Colleague: "Hey, the pizza is heeeere" Me: * backspaces * $ git commit -m "Fixes"

## DuckRails: A Guide to Installing and Using a Tool for Mocking API Endpoints

DevFeed: [DuckRails: A Guide to Installing and Using a Tool for Mocking API Endpoints](<https://devfeed.tech/articles/what-do-you-get-after-you-lose-your-data-from-an-ssd-37453.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/12/04/ptssd>)

Author: Lazarus Lazaridis

Published: 2019-12-04T07:00:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [Development](<https://devfeed.tech/topics/development.md>), [Tool](<https://devfeed.tech/topics/tool.md>), [API](<https://devfeed.tech/topics/api.md>), [Mocking](<https://devfeed.tech/topics/mocking.md>), [Docker](<https://devfeed.tech/topics/docker.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [development](<https://devfeed.tech/tags/development.md>), [devhumor](<https://devfeed.tech/tags/devhumor.md>), [docker](<https://devfeed.tech/tags/docker.md>), [guide](<https://devfeed.tech/tags/guide.md>), [humor](<https://devfeed.tech/tags/humor.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [mocking](<https://devfeed.tech/tags/mocking.md>), [programming](<https://devfeed.tech/tags/programming.md>), [tool](<https://devfeed.tech/tags/tool.md>)

### AI overview

An introduction and installation guide for DuckRails, a development tool for mocking API endpoints dynamically. The source also notes that a Docker image is available.

### Source excerpt

PTSSD

## Installing and Using DuckRails to Mock API Endpoints

DevFeed: [Installing and Using DuckRails to Mock API Endpoints](<https://devfeed.tech/articles/i-am-talking-to-my-code-37451.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/12/03/talking-to-my-code>)

Author: Lazarus Lazaridis

Published: 2019-12-03T19:00:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [Development](<https://devfeed.tech/topics/development.md>), [API](<https://devfeed.tech/topics/api.md>), [Mocking](<https://devfeed.tech/topics/mocking.md>), [Tool](<https://devfeed.tech/topics/tool.md>), [Docker](<https://devfeed.tech/topics/docker.md>), [Docker Image](<https://devfeed.tech/topics/docker-image.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [development](<https://devfeed.tech/tags/development.md>), [devhumor](<https://devfeed.tech/tags/devhumor.md>), [docker](<https://devfeed.tech/tags/docker.md>), [docker-image](<https://devfeed.tech/tags/docker-image.md>), [guide](<https://devfeed.tech/tags/guide.md>), [humor](<https://devfeed.tech/tags/humor.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [mocking](<https://devfeed.tech/tags/mocking.md>), [programming](<https://devfeed.tech/tags/programming.md>), [tool](<https://devfeed.tech/tags/tool.md>)

### AI overview

An introduction and guide to installing and using DuckRails, a development tool for mocking API endpoints dynamically. The article also notes that a Docker image is available.

### Source excerpt

I am talking to my code but according to my cat, this is the least worrying.

## Introduction and guide to installing and using DuckRails for dynamically mocking API endpoints

DevFeed: [Introduction and guide to installing and using DuckRails for dynamically mocking API endpoints](<https://devfeed.tech/articles/i-37449.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/11/22/i>)

Author: Lazarus Lazaridis

Published: 2019-11-22T15:00:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [Development](<https://devfeed.tech/topics/development.md>), [API](<https://devfeed.tech/topics/api.md>), [Docker](<https://devfeed.tech/topics/docker.md>), [Docker Image](<https://devfeed.tech/topics/docker-image.md>), [Mocking](<https://devfeed.tech/topics/mocking.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [development](<https://devfeed.tech/tags/development.md>), [devhumor](<https://devfeed.tech/tags/devhumor.md>), [docker](<https://devfeed.tech/tags/docker.md>), [docker-image](<https://devfeed.tech/tags/docker-image.md>), [guide](<https://devfeed.tech/tags/guide.md>), [humor](<https://devfeed.tech/tags/humor.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [mocking](<https://devfeed.tech/tags/mocking.md>), [poem](<https://devfeed.tech/tags/poem.md>), [programming](<https://devfeed.tech/tags/programming.md>), [tool](<https://devfeed.tech/tags/tool.md>)

### AI overview

An introduction and guide to installing and using DuckRails, a development tool for mocking API endpoints dynamically. The document also notes that a Docker image is available.

### Source excerpt

Roses are red Violets are blue I was looping forever And then I found you. i was your name I think j was next to you Born inside a for Died in there too. I saw you getting bigger Loop over loop over loop And j was getting smaller You were a great group. And then you just vanished You left me there alone Condition wasn't true At least nothing was thrown.

## Mongoid - Inheritance: change embedded document's type via nested attributes

DevFeed: [Mongoid - Inheritance: change embedded document's type via nested attributes](<https://devfeed.tech/articles/mongoid-inheritance-change-embedded-document-s-type-via-nested-attributes-37450.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/11/22/mongoid-nested-attributes-embedded-type>)

Author: Lazarus Lazaridis

Published: 2019-11-22T07:00:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [file](<https://devfeed.tech/topics/file.md>), [Rails](<https://devfeed.tech/topics/rails.md>), [Polymorphism](<https://devfeed.tech/topics/polymorphism.md>), [Forms](<https://devfeed.tech/topics/forms.md>)

Tags: [class](<https://devfeed.tech/tags/class.md>), [code](<https://devfeed.tech/tags/code.md>), [create](<https://devfeed.tech/tags/create.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [mongodb](<https://devfeed.tech/tags/mongodb.md>), [mongoid](<https://devfeed.tech/tags/mongoid.md>), [opensource](<https://devfeed.tech/tags/opensource.md>), [programming](<https://devfeed.tech/tags/programming.md>), [rails](<https://devfeed.tech/tags/rails.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

### AI overview

This tutorial examines problems that arise when changing the type of an embedded Mongoid document through nested attributes. Using a Rails console example with Book and BoardGame subclasses of Item, it demonstrates failed attribute assignments, leftover attributes, and incorrect validators caused by the in-memory object retaining its previous type.

### Source excerpt

I recently faced some issues when trying to update a nested document's type via nested attributes using the mongoid gem. Bare with me if this sentence doesn't make any sense yet. Use case Suppose we have a document named Person that embeds a document that can be any of the types Book or BoardGame which inherit from the class Item. Item class Item include Mongoid::Document embedded_in :person, inverse_of: :item field :name end Book class Book < Item field :authors, type: Array end BoardGame class BoardGame < Item field :players, type: Integer end Person class Person include Mongoid::Document embeds_one :item, inverse_of: :person accepts_nested_attributes_for :item, allow_destroy: true end The problems To simplify the post I won't go with the scenario of building the forms and the controller actions to demonstrate the problems but instead I will simulate the behavior in the rails console. Let's create a Person with a Book as an Item. >> person = Person.create!({ item_attributes: { _type: "Book", name: "Jitterbug Perfume", authors: ["Tom Robbins"] } }) => #<Person _id: 5dd7b01ec2889856ab8a619f, > >> person.item => #<Book _id: 5dd7ae76c2889856ab8a619e, name: "Jitterbug Perfume", _type: "Book", authors: ["Tom Robbins"]> Failing attribute assignments Let's try to change the person's item from Book to BoardGame with 5 players. >> person.update_attributes({ item_attributes: { _type: "BoardGame", name: "Ticket to Ride", players: 5 } }) Traceback (most recent call last): 1: from (irb):9 Mongoid::Errors::UnknownAttribute () message: Attempted to set a value for 'players' which is not allowed on the model Book. summary: Without including Mongoid::Attributes::Dynamic in your model and the attribute does not already exist in the attributes hash, attempting to call Book#players= for it is not allowed. This is also triggered by passing the attribute to any method that accepts an attributes hash, and is raised instead of getting a NoMethodError. resolution: You can include Mongoid::

## How to write better emails

DevFeed: [How to write better emails](<https://devfeed.tech/articles/how-to-write-better-emails-37448.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/06/26/composing-better-emails>)

Author: Lazarus Lazaridis

Published: 2019-06-26T13:30:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [email](<https://devfeed.tech/topics/email.md>), [DateTime](<https://devfeed.tech/topics/datetime.md>)

Tags: [communication](<https://devfeed.tech/tags/communication.md>), [email](<https://devfeed.tech/tags/email.md>), [examples](<https://devfeed.tech/tags/examples.md>), [featured](<https://devfeed.tech/tags/featured.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [need](<https://devfeed.tech/tags/need.md>), [productivity](<https://devfeed.tech/tags/productivity.md>), [programming](<https://devfeed.tech/tags/programming.md>), [tips](<https://devfeed.tech/tags/tips.md>), [write](<https://devfeed.tech/tags/write.md>)

### AI overview

A practical guide to writing clearer, more effective emails. It recommends emphasizing important text, using specific dates and bookmarkable links, structuring long messages with headings and paragraphs, and making requests explicit about who should act and by when.

### Source excerpt

Email communication is not my favorite but since I can't avoid it, I am trying to compose messages in a way that I think it makes it easier for both me and the recipient: to quickly address what is being communicated avoid misunderstandings save time Here are some tips. They don't apply to all type of messages, I provide before and after examples to better describe each case. Emphasize text with bold/underlined font Emphasizing the appropriate parts of a message, especially when it's a long one, you help readers quickly get an idea of what the email is about and easily locate the important stuff after going back to it at some point in the future. Examples Before Hello all, I noticed that there are many logs for blabla the last few days and I don't think that it is normal. I believe the problem is the updated version of gem blabla. I have opened an issue describing the case in Redmine (#455) in the current version. Feel free to change its priority in case blabla. Thanks, Lazarus After Hello all, I noticed that there are many logs for blabla the last few days and I don't think that it is normal. I believe the problem is the updated version of gem blabla. I have opened a Redmine issue (#455) describing the case in the current version. Feel free to change its priority in case blabla. Thanks, Lazarus Use specific dates instead of yesterday, tomorrow etc The moment you send an email is not the moment that it will be read by its recipients. Avoid using only temporal adverbs/nouns like yesterday, today, tomorrow, two hours ago etc but include also the specific dates/times otherwise they might be misunderstood or require from recipients to check the email's sent date/time to calculate the actual time. Examples Before Dear QA, Yesterday we released a fix for the bug 455 on staging and we plan to release it next Monday if you give us the green light by tomorrow end of day. Thanks, Lazarus After Dear QA, Yesterday, June 25th, 2019 we released a fix for the bug #455 on staging a

## How to remove duplicate lines from files preserving their order

DevFeed: [How to remove duplicate lines from files preserving their order](<https://devfeed.tech/articles/how-to-remove-duplicate-lines-from-files-preserving-their-order-37447.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/05/16/remove-duplicate-lines-preserving-order-linux>)

Author: Lazarus Lazaridis

Published: 2019-05-16T08:30:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [Script](<https://devfeed.tech/topics/script.md>), [file](<https://devfeed.tech/topics/file.md>)

Tags: [approach](<https://devfeed.tech/tags/approach.md>), [awk](<https://devfeed.tech/tags/awk.md>), [bash](<https://devfeed.tech/tags/bash.md>), [featured](<https://devfeed.tech/tags/featured.md>), [file](<https://devfeed.tech/tags/file.md>), [files](<https://devfeed.tech/tags/files.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [linux](<https://devfeed.tech/tags/linux.md>), [programming](<https://devfeed.tech/tags/programming.md>), [scripts](<https://devfeed.tech/tags/scripts.md>)

### AI overview

A tutorial explains how to remove duplicate lines from a text file with awk while preserving their original order. It breaks down the associative array, line-occurrence tracking, negation, post-increment behavior, and why other approaches may not preserve order.

### Source excerpt

Suppose you have a text file and you need to remove all of its duplicate lines. TL;DR To remove the duplicate lines preserving their order in the file use: awk '!visited[$0]++' your_file > deduplicated_file How it works The script keeps an associative array with indices equal to the unique lines of the file and values equal to their occurrences. For each line of the file, if the line occurrences are zero then it increases them by one and prints the line, otherwise it just increases the occurrences without printing the line. I was not familiar with awk and I wanted to understand how is this accomplished with such a short script (awkward). I did my research and here is what is going on: the awk "script" !visited[$0]++ is executed for each line of the input file visited[] is a variable of type associative array (a.k.a. Map). We don't have to initialize it, awk will do this for us the first time we access it. the $0 variable holds the contents of the line currently being processed visited[$0] accesses the value stored in the map with key equal to $0 (the line being processed), a.k.a. the occurrences (which we set below) the ! negates the occurrences value: In awk, any nonzero numeric value or any nonempty string value is true By default, variables are initialized to the empty string, which is zero if converted to a number That being said: if visited[$0] returns a number greater than zero, this negation is resolved to false. if visited[$0] returns a number equal to zero or an empty string, this negation is resolved to true. the ++ operation increases the variable's value (visited[$0]) by one. If the value is empty, awk converts it to 0 (number) automatically and then it gets increased. Note: the operation is executed after we access the variable's value. Summing up, the whole expression evaluates to: true if the occurrences are zero/empty string false if the occurrences are greater than zero awk statements consist of a pattern-expression and an associated action. <patter

## How to manage nested objects in Elasticsearch documents

DevFeed: [How to manage nested objects in Elasticsearch documents](<https://devfeed.tech/articles/how-to-manage-nested-objects-in-elasticsearch-documents-37446.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/05/02/add-update-delete-elasticsearch-nested-objects>)

Author: Lazarus Lazaridis

Published: 2019-05-02T12:30:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [elasticsearch](<https://devfeed.tech/topics/elasticsearch.md>), [kibana](<https://devfeed.tech/topics/kibana.md>), [API](<https://devfeed.tech/topics/api.md>)

Tags: [elasticsearch](<https://devfeed.tech/tags/elasticsearch.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [kibana](<https://devfeed.tech/tags/kibana.md>), [nested-objects](<https://devfeed.tech/tags/nested-objects.md>), [opensource](<https://devfeed.tech/tags/opensource.md>), [programming](<https://devfeed.tech/tags/programming.md>), [script](<https://devfeed.tech/tags/script.md>), [scripts](<https://devfeed.tech/tags/scripts.md>), [update](<https://devfeed.tech/tags/update.md>)

### AI overview

This tutorial explains how to manage nested objects in Elasticsearch documents using Kibana. It covers defining a nested mapping, indexing a document containing cats, and adding, removing, and updating nested objects through the Update API and scripts.

### Source excerpt

In this post we are going to manage nested objects of a document indexed with Elasticsearch. The nested type is a specialised version of the object datatype that allows arrays of objects to be indexed in a way that they can be queried independently of each other. - Nested datatype - Official Elasticsearch reference Prerequisites To follow this post you need: an up and running Elasticsearch instance I use 6.7 here an up and running Kibana instance to interact with Elasticsearch Preparation The document of our index will represent a human and its nested objects will be cats (no surprises). Create the index Open your Kibana dev console and type the following to create the index. # Create the index PUT iridakos_nested_objects { "mappings": { "human": { "properties": { "name": { "type": "text" }, "cats": { "type": "nested", "properties": { "colors": { "type": "integer" }, "name": { "type": "text" }, "breed": { "type": "text" } } } } } } } Human has: a name property of type text a cats property of type nested Each cat has: a colors property of type integer a name property of type text a breed property of type text Add a human In the Kibana console, execute the following to add a human with three cats. # Index a human POST iridakos_nested_objects/human/1 { "name": "iridakos", "cats": [ { "colors": 1, "name": "Irida", "breed": "European Shorthair" }, { "colors": 2, "name": "Phoebe", "breed": "European" }, { "colors": 3, "name": "Nino", "breed": "Aegean" } ] } Confirm the insertion with: GET iridakos_nested_objects/human/1 You should see something like this: { "_index": "iridakos_nested_objects", "_type": "human", "_id": "1", "_version": 1, "found": true, "_source": { "name": "iridakos", "cats": [ { "colors": 1, "name": "Irida", "breed": "European Shorthair" }, { "colors": 2, "name": "Phoebe", "breed": "European" }, { "colors": 3, "name": "Nino", "breed": "Aegean" } ] } } Done, moving on. Managing nested objects Add a new nested object Suppose that iridakos got a new Persian

## How to alias and navigate to directories with autocomplete in Linux

DevFeed: [How to alias and navigate to directories with autocomplete in Linux](<https://devfeed.tech/articles/how-to-alias-and-navigate-to-directories-with-autocomplete-in-linux-37445.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/04/10/shell-navigation-with-autocomplete>)

Author: Lazarus Lazaridis

Published: 2019-04-10T13:00:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [Shell](<https://devfeed.tech/topics/shell.md>), [Script](<https://devfeed.tech/topics/script.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [Utility Software](<https://devfeed.tech/topics/utility.md>), [Scripting, bash](<https://devfeed.tech/topics/scripting-bash.md>)

Tags: [aliases](<https://devfeed.tech/tags/aliases.md>), [bash](<https://devfeed.tech/tags/bash.md>), [completion](<https://devfeed.tech/tags/completion.md>), [directory](<https://devfeed.tech/tags/directory.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [installation](<https://devfeed.tech/tags/installation.md>), [linux](<https://devfeed.tech/tags/linux.md>), [opensource](<https://devfeed.tech/tags/opensource.md>), [productivity](<https://devfeed.tech/tags/productivity.md>), [programming](<https://devfeed.tech/tags/programming.md>), [script](<https://devfeed.tech/tags/script.md>), [scripts](<https://devfeed.tech/tags/scripts.md>), [shell](<https://devfeed.tech/tags/shell.md>), [tools](<https://devfeed.tech/tags/tools.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

### AI overview

This tutorial introduces goto, a shell utility for navigating to registered directory aliases with autocomplete. It explains installation, alias management, navigation, cleanup, help, version commands, and directory-stack features.

### Source excerpt

I use the terminal a lot and in my day to day work I tend to navigate to the same bunch of directories. There are some awesome tools out there (like autojump or z) but sometimes, especially when the directories are similarly named, there is a need to be explicit to navigate to the proper one. I decided to write a script to overcome this issue and to avoid having to edit my .bash* files to manage aliases each time I wanted to add or remove a directory. goto goto is a shell utility to quickly navigate to aliased directories with autocomplete (tab completion). goto repo at GitHub User registers directory aliases, for example: goto --register dev /home/iridakos/development and then cds to that directory with: goto dev Find below documentation on the script but make sure you check the script's documentation page for updates. Sorry for the name, I know it brings back memories but it's not what it seems :) Installation To install goto all you have to do is clone the repository locally: git clone https://github.com/iridakos/goto.git navigate to it cd goto and execute: sudo ./install You need to restart your shell after installation. Usage Change to an aliased directory Register an alias Unregister an alias List aliases Expand an alias Cleanup Help Version Extras Push before changing directories Revert to a pushed directory Change to an aliased directory To change to an aliased directory, type: goto <alias> Example goto dev Register an alias To register a directory alias, type: goto -r <alias> <directory> or goto --register <alias> <directory> Example goto -r blog /mnt/external/projects/html/blog or goto --register blog /mnt/external/projects/html/blog Notes goto expands the directories hence you can easily alias your current directory with: goto -r last_release . and it will automatically be aliased to the whole path. Pressing the tab key after the alias name, you have the default directory suggestions by the shell. Unregister an alias To unregister an alias, use: goto -u <

## Dockerizing a Rails application

DevFeed: [Dockerizing a Rails application](<https://devfeed.tech/articles/dockerizing-a-rails-application-37444.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/04/07/dockerizing-a-rails-application>)

Author: Lazarus Lazaridis

Published: 2019-04-07T01:00:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [Docker](<https://devfeed.tech/topics/docker.md>), [Rails](<https://devfeed.tech/topics/rails.md>), [container](<https://devfeed.tech/topics/container.md>), [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>), [Redis](<https://devfeed.tech/topics/redis.md>), [Dockerfile](<https://devfeed.tech/topics/dockerfile.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [configuration](<https://devfeed.tech/topics/configuration.md>), [Ubuntu](<https://devfeed.tech/topics/ubuntu.md>), [Development](<https://devfeed.tech/topics/development.md>)

Tags: [actioncable](<https://devfeed.tech/tags/actioncable.md>), [apt](<https://devfeed.tech/tags/apt.md>), [certificates](<https://devfeed.tech/tags/certificates.md>), [chat](<https://devfeed.tech/tags/chat.md>), [cli](<https://devfeed.tech/tags/cli.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [container](<https://devfeed.tech/tags/container.md>), [curl](<https://devfeed.tech/tags/curl.md>), [docker](<https://devfeed.tech/tags/docker.md>), [docker-image](<https://devfeed.tech/tags/docker-image.md>), [installation](<https://devfeed.tech/tags/installation.md>), [postgres](<https://devfeed.tech/tags/postgres.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [programming](<https://devfeed.tech/tags/programming.md>), [rails](<https://devfeed.tech/tags/rails.md>), [redis](<https://devfeed.tech/tags/redis.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [run](<https://devfeed.tech/tags/run.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>), [ubuntu](<https://devfeed.tech/tags/ubuntu.md>)

### AI overview

A tutorial on Dockerizing a Rails chat application. It covers installing Docker, configuring the application for PostgreSQL, building a Docker image with a Dockerfile, and running PostgreSQL, Redis, and application containers.

### Source excerpt

Hey! In this post we are going to: create a docker image for the Rails chat application that we created in the previous post configure the Docker environment and run the application by: creating a container for the PostgreSQL database creating a container for the Redis server creating a container with the required configuration from the image we built Prerequisites Install docker The first thing you need in order to follow this tutorial is to install Docker on your machine. We are going to use the Docker Community Edition. Follow the installation instructions matching your system. I'm on Ubuntu 18.04 LTS so following the instructions, I had to: Uninstall previous versions with: sudo apt-get remove docker docker-engine docker.io containerd runc I chose to install the application using the repository. sudo apt-get update sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - and I verified that I had the key with the proper fingerprint after executing: sudo apt-key fingerprint 0EBFCD88 I set up the repository with: sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" The installation took place with these commands: sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io I checked that the installation was successful with: $ sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:... Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new

## Creating a chat application from scratch using Rails and WebSockets

DevFeed: [Creating a chat application from scratch using Rails and WebSockets](<https://devfeed.tech/articles/creating-a-chat-application-from-scratch-using-rails-and-websockets-37443.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/04/04/creating-chat-application-rails-websockets>)

Author: Lazarus Lazaridis

Published: 2019-04-04T20:00:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [WebSocket](<https://devfeed.tech/topics/websocket.md>), [Rails](<https://devfeed.tech/topics/rails.md>), [web applications](<https://devfeed.tech/topics/web-applications.md>), [Ruby](<https://devfeed.tech/topics/ruby.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [actioncable](<https://devfeed.tech/tags/actioncable.md>), [application](<https://devfeed.tech/tags/application.md>), [bootstrap](<https://devfeed.tech/tags/bootstrap.md>), [chat](<https://devfeed.tech/tags/chat.md>), [code](<https://devfeed.tech/tags/code.md>), [devise](<https://devfeed.tech/tags/devise.md>), [featured](<https://devfeed.tech/tags/featured.md>), [programming](<https://devfeed.tech/tags/programming.md>), [rails](<https://devfeed.tech/tags/rails.md>), [redis](<https://devfeed.tech/tags/redis.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>), [websocket](<https://devfeed.tech/tags/websocket.md>), [websockets](<https://devfeed.tech/tags/websockets.md>)

### AI overview

A tutorial for building a chat web application from scratch with Rails and WebSockets. It explains WebSocket bidirectional communication and real-time data transfer, then introduces the Ruby and Rails versions used for the application.

### Source excerpt

Hey! It's been a while since my last post. I recently familiarized myself with the awesomeness of WebSockets and I finally found the time to write a tutorial about it. I hope you find it helpful. Update: I also published another post for dockerizing the application of this tutorial, you can find it here. Introduction In this tutorial we are going to create a chat web application from scratch using Rails and WebSockets. Code and comments You can find the code of this tutorial on GitHub. For feedback, comments, typos etc. please open an issue in the repository. What are WebSockets WebSocket is actually a protocol that enables bidirectional communication between the client and the server of a web application over a single long living TCP connection. The WebSocket protocol enables interaction between a web browser (or other client application) and a web server with lower overheads, facilitating real-time data transfer from and to the server. This is made possible by providing a standardized way for the server to send content to the client without being first requested by the client, and allowing messages to be passed back and forth while keeping the connection open. In this way, a two-way ongoing conversation can take place between the client and the server. The communications are done over TCP port number 80 (or 443 in the case of TLS-encrypted connections), which is of benefit for those environments which block non-web Internet connections using a firewall. Similar two-way browser-server communications have been achieved in non-standardized ways using stopgap technologies such as Comet. - WebSocket @ Wikipedia Why WebSockets Suppose you have to create a web page that shows the statuses of running processes. Without WebSockets you would have to either: Use AJAX with Javascript intervals to request and render the latest state of the processes or Automatically reload the page every x seconds (<meta http-equiv="refresh" content="x">) or Add a message on the page "The stat