Posts Tagged Mac

Fixing not working auto-completion for golang in Visual Studio Code

gophervsMy favorite code editor for GO  (Visual Studio Code with Go extenstion from lukehoban) on my Mac sometimes loses its intelligent behavior when suddenly code completion stops to work.

Usually just couple of commands in terminal recovers auto-completion back to life:

  1. Close Visual Studio Code
  2. Open terminal and stop gocode with gocode close
  3. Update gocode with the command `go get -u github.com/nsf/gocode`
  4. Start Visual Studio Code again and enjoy.

, , , , , ,

Leave a comment

Reinstall formula with brew from scratch

Uninstall

brew uninstall --force formula_name

Clear versions & cache

brew cleanup --force -s formula_name

Remove dead symbolic links

brew prune formula_name

Install again

brew install formula_name

Enjoy 🙂

, ,

Leave a comment

Delete certificates from System Roots in Keychain Access on Mac

Before you start deleting certificates from System Roots in your Keychain Access, make sure that you know what you are doing as you can harm your mac if you will delete some essential certificates.

You have been warned 🙂

1. Reboot mac in recovery mode (Hold cmd+R) during restart

2. Start terminal and switch off System Integrity Protection running the command

csrutil disable

3. Reboot in normal mode

4. Start keychain access and find the certificates you want to delete, check its name or unique fingerprint (Right click -> Get info -> Common name or SHA1)

5. Use command line below to delete the certificate using common name:

sudo security delete-certificate -c Common-Name /System/Library/Keychains/SystemRootCertificates.keychain

Or command line below if you are using SHA1 (delete all the spaces in SHA1 fingerprint before running the command)

sudo security delete-certificate -Z SHA1-fingerprint /System/Library/Keychains/SystemRootCertificates.keychain

6. Reboot your mac in recovery mode again (Hold cmd+R)

7. Start terminal and switch on System Integrity Protection running the command

csrutil enable

8. Reboot in normal mode

, , , , , , , , ,

Leave a comment

Using standard command “go get” for private golang packages on gitlab.com

I’m keeping my projects privately on gitlab.com and want to use for some of my golang packages standard “go get” command instead of using git clone/pull. When I’m trying to use standard commands I’m getting the error

go get gitlab.com/bykovme/my_package_here
# cd .; git clone https://gitlab.com/bykovme/my_package_here.git /home/bykov/gopath/src/gitlab.com/bykovme/my_package_here
Cloning into '/home/bykov/gopath/src/gitlab.com/bykovme/my_package_here'...
fatal: could not read Username for 'https://gitlab.com': terminal prompts disabled

As I’m using SSH keys to access the git repository, the following command solves the issue giving possibility to use standard go packages commands

git config --global url."git@gitlab.com:".insteadOf "https://gitlab.com/"

You can check if it was applied using the following command

cat ~/.gitconfig

The output of the command above should be like the text below

[url "git@gitlab.com:"]
    insteadOf = https://gitlab.com/

The command

go get gitlab.com/bykovme/my_package_here

is working now.

PS. The same solution is working for github.com

, , , , , , , ,

Leave a comment

Starting command line program/script in background as job (Linux, Mac)

It is important to  use the command “nohup” and also redirect everything, otherwise the job will be killed after leaving console

nohup ./your_program_or_script_here > copyout.log 2> copyout.err < /dev/null &

On the other side, if you need just to run something in background because you are afraid that you will loose the session, the best way for it is using tmux, it can be installed with “apt-get install tmux” in Ubuntu Linux or “brew install tmux” on Mac

Open new session:

tmux new -s session_name

Attach to the lost session:

tmux attach -t session_name

, , , , ,

Leave a comment

Install applications on Mac from command line

If you have .dmg file

  1. Mount dmg file: hdiutil mount your_favorite_app.dmg
  2. Copy app to “/Applications” folder: sudo cp -R “/Volumes/your_favorite_app/your_app.app” /Applications
  3. Unmount dmg file: hdiutil unmount “/Volumes/your_favorite_app/”

If you have .pkg file:

installer -pkg your_app.pkg -target /

, ,

Leave a comment

Disk usage in command line for Linux & Mac

Quick way to get disk usage for current folder in command line for Linux:

du * -h –max-depth=0 | sort -h

For Mac:

du -hm -d 1 | sort -n

Free disk space can be checked in both systems the same way:

df -h

 

, , , ,

Leave a comment