Sekai 🌐 🗺

Sekai (世界) is the kanji for “the world”. That’s a great word because of the scale that it designates.

Passed Codingame Java Certification Test

A note to some forgotten methods

String regex replace using capture groups

Since Java SE 9, java.util.regex.Matcher’s replaceAll() method supports lambda expressions.

// import java.util.regex.*;
String varName = "random_string";
Pattern pattern = Pattern.compile("_([a-z])");
Matcher matcher = pattern.matcher(varName);
String result = matcher.replaceAll(m -> m.group(1).toUpperCase());

Source: Arvind Kumar Avinash’s answer on Stack Overflow

Check characters properties using Character’s static methods

The Character class provides some static predicates like

  • isAlphabetic(char c)
  • isDigit(char c)
  • isLowerCase(char c)

Source: Java Character isAlphabetic() Method on Javapoint

[Read More]

Fixed Archetype Error for This Site

Background

In Customized Archetype for This Site, I was using

{{ slicestr .Name 11 | humanize | title }}

in the title attribute in my site’s archetypes/default.md, so that the first 11 characters (YYYY-MM-DD-) would be taken out if I type this command.

$ hugo new post/$(date -I)-<MY_POST_TITLE>.md

In practice, <MY_POST_TITLE> can be replaced to any title, like my-post-title.

Problem

I wanted to create my IntelliJ cheatsheet, so I typed this command.

[Read More]
Hugo 

Exploration of My First IntelliJ Project

We’ll try to stay in the project root if possible.

Find all non-hidden files to know the file structure.

$ find -path './.*' -prune -o -type f -print
./Algo-init.iml
./out/production/Algo-init/fr/eql/ai114/algo/init/demo/_1_HelloWorld.class
./src/fr/eql/ai114/algo/init/demo/_1_HelloWorld.java
  • -prune returns true for the chosen path and prevents find from descending.

  • -o means OR, so the paths matching -prune won’t pass through -o.

  • -type f selects files, not folders.

  • By default, AND is used to connect different conditions.

    [Read More]

Reuse Commands with Shell Arguments

My arguments for arguments, functions and alias

Background

We often want to test the output with different values for a parameter. Here’s an example: we have a parameter that pandoc icon pandoc uses to / compile source code files to PDF / M$ Word / etc.

rm output.html; param=0; pandoc input$param.txt -o output.html; \
echo param = $param

In practice, a parameter can be a font, the font size, etc, and there can be multiple parameters.

[Read More]
linux  tcsh 

Finding Pandoc Logo

Background

I’m writing my guide for preparing simple documents. I hope that users can prepare documents efficiently and the prepared documents look smart.

Problem

To help readers get my message in the linked guide, I used many icons from Font Awesome. However, it doesn’t include pandoc’s logo. I tried searching that using the search string “pandoc logo filetype:svg”. Duckduckgo couldn’t find any results. Luckily, Google found many SVGs. The first result linked to a relevant discussion on Google Groups. However, all posts were collapsed, and the desired SVG didn’t show up.

[Read More]
pandoc  SVG 

Some Public APIs to Be Viewed

API description
JSON Placeholder mock REST APIs for development only
Google Translate generate free translations up to a certain limit
Open Weather Map weather prediction across the world
REST Countries info about the world’s countries
IP API data about IP addresses
Random Data API like the first one, but with a sharper focus on random data
Pokemon API info about Pokemon with recent introduction of GraphQL API

Merge Two PDF to Single Encrypted PDF

Problem

I have unprotected

  1. input1.pdf
  2. input2.pdf

and I want to create one single encrypted.pdf.

My try

I looked up QPDF’s manual and tried the following command.

qpdf --empty --pages input{1,2}.pdf --encrypt upw opw 256 -- encrypted.pdf

but I got this error.

qpdf: unrecognized argument --encrypt (pages options must be terminated with --)

For help:
  qpdf --help=usage       usage information
  qpdf --help=topic       help on a topic
  qpdf --help=--option    help on an option
  qpdf --help             general help and a topic list

Solution

The sentence inside the parentheses says it all.

[Read More]
PDF  QPDF