VS Code process "ruby" on MacOS running at 100% CPU: how to fix? - visual-studio-code

When running Visual Studio Code for my Ruby on Rails development project, there is a 'ruby' process constantly running at almost 100% CPU making my fans spin like crazy. Looking at the Open Files and Ports of that process in the Activity Monitor, it looks like this is being caused by some process (node_modules.asar?) scanning through data directories (my_project/public/system/**):
cwd
/Users/pascal/projects/RoR/my_project
txt
/Users/pascal/.rbenv/versions/2.4.4/bin/ruby
txt
/usr/local/Cellar/gmp/6.1.2_2/lib/libgmp.10.dylib
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/enc/encdb.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/enc/trans/transdb.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/stringio.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/etc.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/digest/sha1.bundle
txt
/usr/local/Cellar/openssl/1.0.2o_2/lib/libcrypto.1.0.0.dylib
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/digest.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/openssl.bundle
txt
/usr/local/Cellar/openssl/1.0.2o_2/lib/libssl.1.0.0.dylib
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/io/nonblock.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/io/console.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/zlib.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/socket.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/io/wait.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/enc/windows_31j.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/json-2.1.0/lib/json/ext/parser.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/json-2.1.0/lib/json/ext/generator.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/ripper.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/cgi/escape.bundle
txt
/Library/Preferences/Logging/.plist-cache.KjBd2ZgB
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/readline.bundle
txt
/usr/local/Cellar/readline/7.0.3_1/lib/libreadline.7.0.dylib
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/date_core.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/psych.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/strscan.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/enc/utf_16le.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/enc/utf_16be.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/racc/cparse.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/enc/trans/single_byte.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/nokogiri-1.8.5/lib/nokogiri/nokogiri.bundle
txt
/usr/local/Cellar/xz/5.2.4/lib/liblzma.5.dylib
txt
/usr/lib/dyld
0
->(none)
1
->(none)
2
->(none)
3
->0xebb30f785d0d6639
4
->0xebb30f785d0d4fb9
5
->0xebb30f785d0d70b9
6
->0xebb30f785d0d7b39
7
/dev/null
8
->0xebb30f785d0d7bf9
9
->0xebb30f785d0d6e79
10
localhost:59701
11
localhost:59701->localhost:59702
12
[ctl com.apple.netsrc id 9 unit 64]
13
->0xebb30f7867f30159
14
192.168.10.31:59810->151.101.0.70:https
15
/Users/pascal/projects/RoR/my_project
16
/Users/pascal/projects/RoR/my_project/public
17
/Users/pascal/projects/RoR/my_project/public/system
18
/Users/pascal/projects/RoR/my_project/public/system/dragonfly
19
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test
20
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images
21
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662
22
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662/2017
23
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662/2017/12
24
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662/2017/12/08
25
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662/2017/12/08/13
26
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662/2017/12/08/13/11
27
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662/2017/12/08/13/11/27
36
/dev/ptmx
38
/private/var/folders/fn/wjmjy_xj1vv2n8lhfcsjb3480000gn/T/com.microsoft.VSCode.ShipIt.3TPnSs1E/Visual Studio Code.app/Contents/Resources/app/node_modules.asar
I'm hoping that some exclude folders settings would fix this, but I cannot find any relevant setting. Or is there another solution for this?

This turned out to be caused by the Solargraph gem. According to this explanation of the author, the exclude settings of this gem in the .solargraph.yml file don't work very well. Instead one should use more specific include settings. In my case I was using - **/*.rb as a single include setting. I've now changed this to:
include:
- app/**/*.rb
- db/migrate/**/*.rb
- db/seeds/**/*.rb
- config/**/*.rb
- lib/**/*.rb
- spec/**/*.rb
Since then the ruby process seems to be tamed.

Related

Relative path MS Word with INCLUDETEXT

I am trying to use INCLUDETEXT to automate a Table of Contents with number of pages from various other .docm files in folders below main folder.
I have trouble using relative paths in MS Word per: relative path includetext in MS Word
Here is my effort which results in an
"Error! Not a valid filename":
{INCLUDETEXT "{FILENAME \P } \..\..\Div 22 Plumbing\SECTION 22 07 80.DOCM" Pages}
Div 22... folder is one level the FILENAME path. Pages is a bookmark in the .docm file.
I tried like this too with same negative result:
{INCLUDETEXT "{FILENAME \P } \\..\\Div 22 Plumbing\SECTION 22 07 80.DOCM" Pages}
I am able to get the contents of Pages into my TOC if I just use the INCLUDETEXT from an external file in the same folder, I just can't seem to get the contents from a file in a subfolder.
in your example, you put this:
{INCLUDETEXT "{FILENAME \P } \\..\\Div 22 Plumbing\SECTION 22 07 80.DOCM" Pages}
did you mean this:
{INCLUDETEXT "{FILENAME \P } \\..\\Div 22 Plumbing\\SECTION 22 07 80.DOCM" Pages}

Error when trying to use custom tessdata file

I have generated a box file from a png image then I followed this tutorial:
https://pretius.com/how-to-prepare-training-files-for-tesseract-ocr-and-improve-characters-recognition/ to generate custom traineddata file.
I encountered an error when I tried to use the generated traineddata alongside with Pytesseract.
and i got this kind of error:
raise TesseractError(proc.returncode, get_errors(error_string))
pytesseract.pytesseract.TesseractError: (-4, "read_params_file:
Can't open txt read_params_file: Can't open txt read_params_file: Can't open txt read_params_file: Can't open txt Error: LSTM requested, but not present!! Loading tesseract. mgr->GetComponent(TESSDATA_NORMPROTO, &fp)
:Error:Assert failed:in file adaptmatch.cpp, line 552")
I'm using Tesseract version 5.0
This is my config options
traineddata = f'+eng+lav+lav2'
config = f'-l {traineddata} --oem 1 --psm 3 {tessdata_dir}'
I followed the same tutorial and encountered the exact same error. At my first tries the ***.traineddata didn't generated well, and I findout that one file was missing (normproto). So I just cleaned all the generated files (except the corrected .box files) and rerun the train process, and everything worked fine on the second attempt.

Angular file upload - return name uploaded file

I'm using an angular-file-upload directive. When I uploading file I getting file's name before upload on callback.
$$hashKey: "object:19"_file: FilelastModified: 1429780959000lastModifiedDate: Thu Apr 23 2015 12:22:39 GMT+0300 (MSK)name: "av_1.png"size: 1278type: "image/png"webkitRelativePath: "" trueisUploading: falsemethod: "POST"progress: 100removeAfterUpload: false
name: "av_1.png" - name before upload
But I need to get name of file after upload. Name turns in 16 bit encoding and looks like 68b714b12c6a4336500a4c5a4b53c60e.png for example.
How can I return file's name after upload?

weird results on db_dump(berkeley db)

I have about 400MB sized berkeley db file.
$> ls -alh ses.db
-rw-rw-r-- 1 junyoung junyoung 391M 9월 23 17:32 ses.db
after dumping it, I've checked the size again.
$> db_dump ses.db > ses.db.dump
$> ls -alh ses.db.dump
-rw-rw-r-- 1 junyoung junyoung 2.2M 9월 23 18:09 ses.db.dump1
the result file size is too small than I expected.
what's the reason of this? any comments?
There could be many reasons for this, to be sure. But possibly the most common reason is that the database once held many more records which were later deleted. This space is not returned to the filesystem.
See this thread in the Oracle forums for more information https://community.oracle.com/thread/879030 . And, as it says in there, try the db_stat command to get some visibility into what's going on in your database.

What is the use of Hash in Nginx Upload module?

I have made the Nginx Upload working normally with Python (Tornado). I save the paths of the uploaded files in the database.
However, I wonder why the upload module has to split my uploads and put them into 10 different folders /var/www/.../uploads/0,1,2,3,4,5...9 ? The comment below says the files were hashed, what and why the module does this?
# Store files to this directory
# The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist
upload_store /var/www/...uploads 1;
# filesystem location where we store uploads
#
# The second argument is the level of "hashing" that nginx will perform
# on the filenames before storing them to the filesystem. I can't find
# any documentation online, so as an example, say we were using this
# configuration:
#
# upload_store /tmp/uploads 2 1;
#
# A file named '43829042' would be written to this path:
#
# /tmp/uploads/42/0/43829042
#
# I hope that's clear enough. The argument is required and must be
# greater than 0. You can see the implementation here:
#
# http://lxr.evanmiller.org/http/source/core/ngx_file.c#L118
Source: http://bclennox.com/extremely-large-file-uploads-with-nginx-passenger-rails-and-jquery