Cloud-oriented Life

Cloud Native Technology Improves Lives

goworker

goworker is a Resque-compatible, Go-based background worker that runs 10 to 100,000* times faster than Ruby-based workers. It allows you to push jobs into a queue using an expressive language like Ruby while harnessing the efficiency and concurrency of Go to minimize job latency and cost.

goworker workers can run alongside Ruby Resque clients so that you can keep all but your most resource-intensive jobs in Ruby.

goworker - https://www.goworker.org/

Read more »

scenic

Scenic adds methods to ActiveRecord::Migration to create and manage database views in Rails.

Using Scenic, you can bring the power of SQL views to your Rails application without having to switch your schema format to SQL. Scenic provides a convention for versioning views that keeps your migration history consistent and reversible and avoids having to duplicate SQL strings across migrations. As an added bonus, you define the structure of your view in a SQL file, meaning you get full SQL syntax highlighting in the editor of your choice and can easily test your SQL in the database console during development.

Read more »

helm-alidns-webhook-cert-manager-example

Alidns-webhook-cert-manager is a cert-manager plugin to manage SSL certificates on Kubernetes.

Along with Nginx Ingress, you can configure HTTPS access to the website. With Let’s Encrypt provide free SSL certificates, all the free packs of cert-manager + Nginx Ingress + Let’s Encrypt are automatic generated. But cert-manager does not support Alidns(Alibaba Cloud’s DNS) by default.

You can modify it and use Alidns-webhook-cert-manager. There is some examplesabout installing it with Helm in the article.

Read more »

helm-cert-manager-example

cert-manager is a native Kubernetes certificate management controller. It can help with issuing certificates from a variety of sources, such as Let’s Encrypt, HashiCorp Vault, Venafi, a simple signing key pair, or self signed.

You can modify it and use cert-manager. There is some examplesabout installing it with Helm in the article.

Read more »

hexo-word-counter

Hexo is a fast, simple & powerful blog framework. It use plugins to provide features powerful APIs for limitless extensibility. Various plugins are available to support most template engines (EJS, Pug, Nunjucks, and many others). Easily integrate with existing NPM packages (Babel, PostCSS, Less/Sass, etc).

hexo-word-counter plugin will count symbols and time to read for Hexo articles.

Installation

Use npm to install hexo-word-counter package.

1
2
3
$ npm install hexo-word-counter --save

$ hexo clean

Configuration

You can set options of hexo-word-counter in the Hexo’s _config.yml (which locates in the root dir of your blog):

1
2
3
4
5
6
7
8
9
10
# _config.yml
symbols_count_time:
symbols: true
time: true
total_symbols: true
total_time: true
exclude_codeblock: false
awl: 4
wpm: 275
suffix: "mins."

If symbols_count_time option is not specified, the default parameters will be used.

Parameters

  • awl – Average Word Length (chars count in word). Default: 4. You can check this here.

    • CN ≈ 2

    • EN ≈ 5

    • RU ≈ 6

  • wpm – Words Per Minute. Default: 275. You can check this here.

    • Slow ≈ 200

    • Normal ≈ 275

    • Fast ≈ 350

  • suffix – If time to read less then 60 minutes, added suffix as string parameter.

    If not defined, mins. will be used as default.

  • exclude_codeblock – Allow to exclude all content inside code blocks for more accurate words counting.

    If not defined, false will be used as default.


Note for Chinese users: because in Chinese language average word length about ~1.5 and if you at most cases write posts in Chinese (without mixed English), recommended to set awl to 2 and wpm to 300.
But if you usualy mix your posts with English, awl to 4 and wpm to 275 will be nice.


NexT theme

This plugin integrated in «NexT» and after plugin enabled in main Hexo config, you may adjust options in NexT config:

1
2
3
4
5
6
7
# _config.next.yml

# Post wordcount display settings
# Dependencies: https://github.com/next-theme/hexo-word-counter
symbols_count_time:
separated_meta: true
item_text_total: false

Finally, you can visit your site in the browser, and check whether the site works correctly after Hexo restarted or regenerated.

References

[1] GitHub - next-theme/hexo-word-counter: ⏰ Symbols count and time to read of articles for Hexo. - https://github.com/next-theme/hexo-word-counter

[2] Hexo - https://hexo.io/

You can apply for the free JetBrains Products(IntelliJ IDEA, Clion, PyCharm, RubyMine, etc) License with your Open Source projects.

JetBrains will check the history of recent commits in your Open Source project. To approve the request, they need to see that regular commits have been made for the past 3 months or more. For an Open Source license renewal, they need to see how the granted licenses have been used throughout the past year.

Read more »

Configration

Hexo is a fast, simple & powerful blog framework. It use plugins to provide features powerful APIs for limitless extensibility. Various plugins are available to support most template engines (EJS, Pug, Nunjucks, and many others). Easily integrate with existing NPM packages (Babel, PostCSS, Less/Sass, etc).

By default, there are the following configuration(YAML or JSON) files in Hexo:

  • _config.yml

  • config[theme].yml

  • themes/[theme]/_config.yml

We can directly modify the above configuration file, but this is a litter intrusive for Hexo.

Recommend to use alternate site or theme configuration to minimal invasive site and theme configuration in Hexo.

Read more »

paranoia or acts_as_paranoid

paranoia is a re-implementation of acts_as_paranoid for Rails 3/4/5, using much, much, much less code.

When your app is using Paranoia, calling destroy on an ActiveRecord object doesn’t actually destroy the database record, but just hides it. Paranoia does this by setting a deleted_at field to the current time when you destroy a record, and hides it by scoping all queries on your model to only include records which do not have a deleted_at field.

Read more »

FAQs about Docker Containers or Kubernetes (K8S) Pods

Exit Code: 137

A Pod is terminated or restarted with exit code 137. It should happen Out Of Memory(OOM).

Run kubectl describe pod command to check pod state.

1
2
3
4
5
6
7
8
9
10
11
12
# kubectl describe pod <name>
...
State: Running
Started: Feb, 03 Sep 2020 02:46:17 +0800
Last State: Terminated
Reason: Error
Exit Code: 137
Started: Sat, 01 Feb 2020 11:32:03 +0800
Finished: Mon, 03 Feb 2020 02:46:12 +0800
Ready: True
Restart Count: 1
...

Run journalctl command to check journal logs.

1
2
3
4
5
6
7
8
9
10
11
# journalctl -k | grep -i -e memory -e oom
Feb 03 02:46:14 s1 kernel: [<ffffffff81bbb076>] out_of_memory+0x4b6/0x4f0
Feb 03 02:46:14 s1 kernel: [ pid ] uid tgid total_vm rss nr_ptes swapents oom_score_adj name
Feb 03 02:46:15 s1 kernel: Out of memory: Kill process 22739 (bundle) score 1325 or sacrifice child
Feb 03 02:46:15 s1 kernel: kthreadd invoked oom-killer: gfp_mask=0x3000d0, order=2, oom_score_adj=0
Feb 03 02:46:15 s1 kernel: [<ffffffffc03cb71a>] ? virtballoon_oom_notify+0x2a/0x70 [virtio_balloon]
Feb 03 02:46:15 s1 kernel: [<ffffffff81bba834>] oom_kill_process+0x254/0x3d0
Feb 03 02:46:15 s1 kernel: [<ffffffff81bba2dd>] ? oom_unkillable_task+0xcd/0x120
Feb 03 02:46:15 s1 kernel: [<ffffffff81bbb076>] out_of_memory+0x4b6/0x4f0
Feb 03 02:46:15 s1 kernel: [ pid ] uid tgid total_vm rss nr_ptes swapents oom_score_adj name
Feb 03 02:46:15 s1 kernel: Out of memory: Kill process 23056 (util.rb:22) score 1326 or sacrifice child
0%