Hegwin.Me

Time doth transfix the flourish set on youth. And delves the parallels in beauty's brow.

Windows 10 upgrade from Windows 7 dual boot with Ubuntu

Windows7 + Ubuntu 双系统下,如何升级到 Windows 10

I have a desktop computer purchased in 2014. It was a dual system of Windows 7 + Ubuntu 14.04 and I had been considering upgrading Windows 7 to Windows 10 for a long time, but there were potential problems with the process that made me hesitate to do so. I finally took the plunge and upgraded it recently, and I'll...

Format Your Output in Terminal with Ruby

Ruby命令行格式化输出

If we want to output content in the command line, generally speaking, Ruby basic methods are enough, such as `puts`, `print`, and `sprintf`; but if we want to output color in the terminal, table, and progress bar, etc., it will be more difficult to achieve. Here, I want to share gems that I feel good using in this situation: -...

Execute System Commands in Ruby

在Ruby中运行系统命令

There are several ways to invoke system commands in Ruby: 1. Backquotes `` or `%x()`, 2. The `system` method, 3. The `File` class, 4. The Open3 lib. The difference between backquotes and `%x()` and `system` is that: `system` only returns true/false; while `%x` returns the stdout of the command when the command execution succeeds, and an empty string `""` when...

Run specific version of bundler

运行特定版本的 bundler

Ruby Little (Useless) Trick (Skill) series. When you have two versions of bundler installed at the same time, say 2.0.1 and 1.17.2, by default `bundle exec` and other commands use the latest version of bundler; If you are maintaining an old program, then you may run into this magic problem due to the incompatibility of bundlers like this: ``` Bundler...

Hello World in Rust

第一个Rust程序

When learning a new programming language, there is a tradition of writing a simple program that outputs "Hello, World!" on the screen at first. Installation steps can be easily found on the official rust-lang website. Rust is a language that uses the `rustup` tool to manage versions and toolchains. In the official "Getting Started", we can see that the installation...

Different methods in Ruby to manipulate directories and files

Ruby中目录和文件操作的几种方式

Creating a directory: Method 1: You can create a directory using Dir.mkdir with an optional parameter to mark the permissions of the directory. For example, if I want to create a `ruby` subdirectory in the /Users/hegwin/Workspace directory, I can do this Dir.mkdir('/Users/hegwin/Workspace/ruby') After normal creation, Dir.mkdir will return the integer 0. This method is similar to the Linux command `mkdir`,...

Excerpt from Home Deus A Brier Histroy of Tomorrow

读《未来简史》以及摘抄

I finally finished reading the book "A Brief History of Tomorrow" today. I did not see or buy this book in a bookstore. Coincidentally, I had some expiring points from China Unicom and I had to spend them on exchanging something before they were no longer valid. Inadvertently I got the electronic edition of this book with those points. Although...

Improve Memory for Your Rails App

Rails 应用的内存优化

I was in Zhengzhou today for the two-day Ruby Summit China 2018; the Summit was held at the "Big Corn" in Zhengzhou. I didn't expect that a city like Zhengzhou, where the density of Internet companies is not that high, could host an Internet conference of this scale (Ruby Summit was just one of the sessions). What was even more...

Soft Girl Gone Determined - Excerpt from Moon and Sixpense and Gone with The Wind

小女孩总会长大的 - 《月亮和六便士》《飘》摘抄

To improve my English, I read English novels. I recently read Maugham's The Moon and Sixpense, and Margaret Mitchell's Gone with the Wind. The result is that although I felt their fine diction and subtlety of expression, I didn't actually learn much English expression, rather my emotions followed the ebb and flow of the novel's plot. Especially the growth and...

Notes of CPR from a First Aid Training

成人心肺复苏(CPR)学习笔记

I attended a two-day first aid training last weekend. I am quite interested in saving the injured and giving help; Even in the game World of Warcraft, I play a healing class in - Priest. The first aid training actually covered a lot of topics, including the general management of burns, cuts, and choking, but more important to me was...