Tuesday, August 28, 2018

Ubuntu. Install VirtualBox from Oracle.

Official manual from Oracle is not clear enough. Quick steps:
  1. Delete old VirtualBox if installed:
    sudo apt-get purge virtualbox virtualbox-dkms
    
    Note! purge command will delete settings as well. To preserve them replace purge with remove.
  2. Add Oracle VirtualBox repository key to the system:
    wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O-| sudo apt-key add -
    
  3. Add Oracle virtualbox repository to the system:
    sudo apt-add-repository "deb https://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib"
    
  4. Install virtualbox-5.2 (or later) with dkms:
    sudo apt-get update && sudo apt-get install virtualbox-5.2 dkms
    
  5. Optionaly. If you had VirtialBox installed before:
    sudo /sbin/vboxconfig
    

Thursday, October 26, 2017

Update Ubuntu expired keys

Update all expired keys from Ubuntu key server in one command
sudo apt-key list | \
 grep "expired: " | \
 sed -ne 's|pub .*/\([^ ]*\) .*|\1|gp' | \
 xargs -n1 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys
Command explanation:
  1. sudo apt-key list - lists all keys installed in the system;
  2. grep "expired: " - leave only lines with expired keys;
  3. sed -ne 's|pub .*/\([^ ]*\) .*|\1|gp' - extracts keys;
  4. xargs -n1 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys - updates keys from Ubuntu key server by found expired ones.

Wednesday, March 25, 2015

Eclipse Luna update problem

On update got next error:

An error occurred while collecting items to be installed
session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
No repository found containing: osgi.bundle,org.springsource.ide.eclipse.commons.quicksearch,3.6.4.201503050855-RELEASE
No repository found containing: org.eclipse.update.feature,org.springsource.ide.eclipse.commons.quicksearch.feature,3.6.4.201503050855-RELEASE

Steps helped me:

  1. Review and delete excess old repositories. Help > Install New Software > Available Software Sites and deselect all Update Sites for older Eclipse versions. I had two Spring repositories for 4.3 and 4.4 version.
  2. Clear <eclipse folder>/p2/org.eclipse.equinox.p2.repository/cache directory.
  3. Check for updates again.

Wednesday, March 11, 2015

Mercurial HG. How to restore corrupted repository: unknown format 114

Working with Eclipse and installed MercurialEclipse faced with error "unknown format 114". My repository contained committed, inactive and not pushed revision in bookmark. Problem occurred in the middle of revision history, don't know how.


C:\U\DL\workspace\broken> hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
 src/com/projectname/rfp/web/helpers/ProjectReplicationSettings.java@2660: broken revlog! (index data/src/com/projectname/rfp/web/helpers/ProjectReplicationSettings.java.i unknown format 114)
warning: orphan revlog 'data/src/com/projectname/rfp/web/helpers/ProjectReplicationSettings.java.i'
5599 files, 3098 changesets, 19303 total revisions
1 warnings encountered!
1 integrity errors encountered!
(first damaged changeset appears to be 2660)

Thursday, March 5, 2015

HackerRank. Contest 101. Marble Cut

Problem Statement

Given a marble of size l * b, your task is to find out if it can be cut into pieces of size 3×1 or not.


Input Format

First line will contain T i.e. number of the test cases.
Next T lines will contain pair of integers l and b separated by a single space.


Constraints

1≤T≤10^5
1≤l,b≤10^9


Output Format

Print "YES" if it is possible to cut the given marble without any area left, else print "NO" followed by remaining area.
Link: https://www.hackerrank.com/contests/101hack22/challenges/marble-cut

Tuesday, February 10, 2015

Mercurial HG. How to delete files with orig extension

While you work with hg and do rebase, merge, hg saves original files. Some day your project will contain lots of rubbish files. Here is some multiplatform solution.
  1. Enable purge extension in mercurial.
    1. Open ~/.hgrc (Linux, Windows) or mercurial.ini  on Windows system.
    2. Add to extensions section purge plugin:
      [extensions] purge =
  2. In terminal select project folder and run next command:
    hg purge -I **/*.orig --all To test command without deleting files, add --print flag.

Eclipse. How to convert upper case text to lower case and vice versa

There are shortcuts to convert selected text to upper or lower case in Eclipse.
  • Upper case: CTRL + SHIFT + X
  • Lower case: CTRL + SHIFT + Y