Tuesday, July 30, 2019

IntelliJ IDEA settings

Go to File/SettingsEditor, click on General. Scroll down, then ✔ Show quick documentation on mouse move.

File size exceeds configured limit (2560000), code insight features not available
This is built from Álvaro González's answer and How to increase IDE memory limit in IntelliJ IDEA on Mac?
Go to Help > Edit Custom Properties
Restart the IDE.

# Maximum file size (kilobytes) IDE should provide code assistance for.
# The larger file is the slower its editor works and higher overall system memory requirements are
# if code assistance is enabled. Remove this property or set to very large number if you need
# code assistance for any files available regardless their size.

# This option controls console cyclic buffer: keeps the console output size not higher than the specified buffer size (Kb)
# Older lines are deleted. In order to disable cycle buffer use idea.cycle.buffer.size=disabled

You should go to your keymap settings (ide settings | keymap) and do the following:
  1. Remove 'Button2' mouse shortcut from 'Paste from X clipboard' action;
  2. Add 'Button2' mouse shortcut for 'main menu | navigate | declaration' action;
Sometimes you don’t even need to open the settings dialog. Press Ctrl + Shift + Aand type the setting name. If it’s a checkbox option, you can press Return to toggle the setting - effective immediately!

Finally, some settings are only applied to the current project, e.g. the JavaScript language level. To customize default project settings, go to File → Other Settings → Default settings....
Zoom with the mouse wheel
☑ Editor → General → Change font size (zoom) with Ctrl+Mouse Wheel

That’s a feature known from most other text editors and browsers, but it’s disabled by default. Enable this option to zoom using Ctrl + Mouse Wheel.

Show line numbers on the editor gutter
☑ Editor → General → Appearance → Show line numbers

That’s self explanatory. Additionally, press Ctrl + G to navigate to a line number.

Wrap long lines
☑ Editor > General > Use soft wraps in editor
☑ Editor > General > (Console >) Use soft wraps in console
Editor > General > Use custom soft wraps indent/additional shift: 1

mprove tab appearance
☑ Editor → General → Editor Tabs → Hide file extension in editor tabs
☐ Editor → General → Editor Tabs → Show “close” button on editor tabs

By hiding both file extensions and close icons you will gain a lot of free space in the editor tab panel. File icons are enough to infer the file types, and you are still able to close tabs by pressing the middle mouse key or Ctrl + F4.

use Ctrl + E to switch between recent files and Ctrl + Shift + E to switch between recently edited files. I’m currently trying out this idea (no pun intended), but it’s quite hard to quit the habit of using tabs.

Sort debugger fields alphabetically
☑ Build, Execution, Deployment → Debugger → Data Views → Sort alphabetically

By default, debugger variables are listed in the order in which they were defined. I find this makes it harder to find the right values.

Bonus tip: you can focus any list/tree panel (like debugger variables or the project view) and search for a value by simply starting to type. If multiple values match the search string, use ↓ and ↑ keys to step through them.
In this example I typed mo, so I can toggle the selection between module and mongoose:

Remove unused sidebar panels
That’s a new feature in IntelliJ IDEA 15. Finally we are able to remove unwanted tool window buttons. Just right click a sidebar button and select Remove from sidebar. You can restore a hidden tool window with View → Tool Windows.

Remove sidebar panel
Remove sidebar panel
Use a custom terminal shell
☑ Tools → Terminal → Shell path

IDEA comes with a handy terminal panel (Alt + F12). However, using the default Windows command prompt can sometimes be quite annoying. Fortunatelly, you can use a more useful shell within IntelliJ IDEA, like the Git Bash (by default under C:\Program Files\Git in ash.exe).

You can customize the terminal font and colors here:

☑ Editor → Colors & Fonts → Console Font/Colors

Saturday, July 27, 2019


To check the name of the Desktop Environment from the command line, you can use the following command:
  • env | grep DESKTOP_SESSION= (so-so)

  • Built in "Open as root" context menu item
  • Detachable tabs
  • New Extensions: nemo-image-converter, nemo-filename-repairer, nemo-emblems, and old extension got new updates and features.
  • Unified, configurable toolbar: you can add/remove the following: up icon, refresh icon, toggle button for the location bar / path bar, home icon, computer icon and search icon.
  • Option to show the full path in the titlebar and tab bars (Preferences > Display)
  • Displays an "elevated privileges" banner when running as root
  • Built in "Open in terminal" context menu item


Split View

In Nemo, you can split main are into two. Press F3. This is very helpful when you are comparing two different folders at once.

New Tab

Nemo has multitab. Press Ctrl+T to open a new tab. In a new tab, you can browse different place. More tabs more places

New Folder

To create new folder, right click on main area > Create > New Folder. Or, click new folder icon on top toolbar. Or, press Ctrl+Shift+N. 

Delete Folder

To delete a folder, click/select a folder and press Shift+Delete. This will delete folder and its content permanently. If you want to delete it temporarily (move it to “Recycle Bin”), right-click and select Delete. Or, just press Delete without Shift key. 

Address Bar

Nemo has default Breadcrumb address bar. It's similar with Finder after all. It is an address bar with clickable button for every folder history. If you want normal address bar, press Ctrl+L. To revert it into Breadcrumb, press Ctrl+L again. 


If you are using Folder View, you can bookmark your favorite folder there. Just drag and drop your folder into Left Panel on Devices section. 

Tree View

This is something similar with your Left Panel appearances on Windows. You browse folders by parent and child view. To enable this, click Tree View icon on bottom toolbar. 

Hide and Show Hidden Files

Nemo hides hidden files by default. To show hidden files, press Ctrl+H. To hide them again, press Ctrl+H too. 


To search files, press Ctrl+F and type what do you want. In newer version of Nemo, it has incremental search. So, the results come directly. Doesn't wait to be finished first to show the result.

Safari Tips and Tricks

2. Simplify your view of the internet
The Safari web browser can hide ads and other distractions to let you focus on the a given page's text. To permanently enable this minimal-view Reader Mode, start by opening the browser. Next, click the Safari menu (in the bar at the top of the screen) and choose Preferences. From this window, open the Reader tab, find the When visiting other websites drop-down list, and select On.

14. Stop autoplaying content
Autoplaying ads and videos can make the internet a noisy place. To stop them, open Apple's web browser, click Safari from the bar at the top of the page, click Preferences, and head to the Websites tab. Here, you can stop audio and videos from playing automatically in the future, or block videos that have sound attached.

#12. Show website Favicons in Safari
To enable this, open Safari → Select Safari Preferences → then select Tabs → and check the box beside “Show website icon in tabs.”

Tweak Mac Settings


  1. Go to the  Apple menu and open “System Preferences”
  2. Choose “Trackpad” and go to the “Point & Click” tab
  3. Check the box next to ‘Tap to click’
6. Flip the scroll direction
By default, if you move two fingers down the trackpad of an Apple laptop, your view travels down the open document or website. However, you can flip these directions so that moving your fingers down makes the view move up. Open System Preferences and go to the Trackpad menu. Under the Scroll & Zoom heading, tick the box marked Scroll direction: Natural.

24. Prevent others from installing apps
Even if you share a computer with others, you might not want them installing software on it. With the App Store open, go to the bar at the top of the screen and choose App Store followed by Preferences. Under the Password Settings heading, set the two drop-down menus to Always Require and Require Password, respectively. Now nobody will be able to install new apps without entering your password.

4) Turn off iCloud Drive. If your new user has an iCloud account, you might consider heading over to System Preferences > iCloud and toggling off the “iCloud Drive” option if it’s unnecessary

Show battery percentage

System Preferences > Energy Saver and check the box for Show battery status in menu bar

Set up Siri

Customize the Touch Bar

If you have a new MacBook Pro ($1,500 at Best Buy) model with the Touch Bar, then head to System Preferences > Keyboard and click the Customize Touch Bar button and then simply drag the buttons you want to show up on the default view of the Touch Bar to the Touch Bar below the display.

Choose default browser

go to System Preferences > General and make a selection other than Safari for Default web browser

Set scrolling direction

System Preferences > Trackpad and click on the Scroll & Zoomtab. Next, uncheck the box for Scroll direction: Natural

Add and remove items from Dock

To remove an app from the Dock, simple click on its icon in the Dock and drag it to the desktop until you see Remove appear above the icon and then let go. Poof, it's gone! To add an app to the Dock, open it and then right-click on its icon in the Dock and mouse over the Option line in the menu and click Keep in Dock

Move the Dock
To move the Dock, go to System Preferences > Dock and choose either Left or Right for Position on Screen. While you're there, you can also drag a slider to adjust the size of the Dock. You can also make it disappear from view when you aren't using it by checking the box for Automatically hide and show the Dock

Stop auto-play videos for safari

Open Safari's Preferences and click on the Websites tab. Choose Auto-Play from the left panel and for When visiting other websites at the bottom of the window, select Never Auto-Play or Stop Media with Sound (if you are okay with muted videos playing) and sit back and rejoice in the silence

Enable Safari favicons

To enable favicons for Safari, open Preferences and click the Tabs tab at the top. Next, check the box for Show website icons in tabs

Head to System Preferences > Displays and click the Night Shift tab

Try out dark mode

 MacOS Mojave also delivered an honest-to-goodness dark mode for Macs. Go to System Preferences > General and you'll see the Light and Dark options at the top for Appearance

Set app download tolerance level

If you want to download apps from the web at large and not just from the Mac App Store, you'll need to tell MacOS to loosen up on the reins a bit. Go to System Preferences > Security & Privacy, click the General tab and then click lock in the lower-left corner and enter your password to make changes. Next, for Allow apps downloaded from choose App Store and identified developers

Friday, July 26, 2019

Google Flogger

  • Logging at disabled levels is effectively free. Finally, you can add as many fine-grained log statements to your code as you want, without worry.
  • Flogger also has very high performance for enabled log statements.
  • A fluent API accommodates a variety of present and future features without combinatorial explosion, and without requiring separate logging façades.
  • Less reliance on long parameter lists makes it harder to misuse and yields more self-documenting code.

When possible, log objects, not strings {#structured}
It's good to remember that a logging backend might not necessarily be outputting only plain text files. For a statement such as

logger.atInfo().log("Received message is: %s", proto)
the backend has the opportunity to do more interesting things with the data in its original, structured form.

On the other hand, with either of these calls:

logger.atInfo().log("Received message is: %s", proto.toString())
logger.atInfo().log("Received message is: " + proto);

Don't create a Throwable just to log it {#stack-trace}

There is no need to do this:
logger.atInfo().withCause(new Exception()).log("Message");
You should do this instead:
where <SIZE> is one of the StackSize enum constants, SMALLMEDIUMLARGE or FULL.

Make the logger the first static field in a class

Fortunately we know whether or not logging is disabled at the point that the level selector was called (and this is always the first thing we do). So if logging is disabled we can chose to return a different implementation of the logging context which simply discards all its arguments for every subsequent method call (a “No-Op” instance). Conveniently this instance is naturally immutable and thread safe, so we can return the same singleton instance every time, which avoids an allocation when logging is disabled.
This means that as well as being a more functional API, using a fluent API means that in the vast majority of cases a disabled log statement can avoid needing to allocate anything.

These improvements include reducing the cost of disabled log statements, increasing overall readability, and allowing extensibility

More specifically, logging frameworks typically utilize varargs to accommodate the unknown number of parameters in a logging method call rather than having hundreds or even thousands of different and unpredictable method signatures. This use of varargs results in additional bytecode, particularly to allocate an Object[] for storing the varargs. While additional bytecode doesn’t typically warrant concern, it becomes particularly important in applications with very fine-grained logging statements or logging statements that occur in loops.
Flogger avoids this cost through the design of its API. The fluent call chain always begins with a selector for a particular log level, for instance atInfo(). This selector returns an implementation to log at that level and in the case of disabled log statements, a singleton, no-op implementation, can be returned.

private static final FluentLogger logger = FluentLogger.forEnclosingClass();


                .atMostEvery(50, TimeUnit.SECONDS)
                .log("SEVERE", LazyArgs.lazy(() -> doSomeCostly()));

logger.atInfo().every(100).log("Info logs %s", arg);

4. It also supports Extensibility
If you wanted to create separate logs per user or per session id. It is super easy to do that with the flogger
long sessionId;
logger.at(INFO).forUserId(sessionId).log("My message: %s", param);
5. Better runtime checking for disabled logging
if (logger.atFine().isEnabled()) {
  Foo foo = doComplexThing();
  logger.atFine().log("stats=%s", foo.toString());

Thursday, July 25, 2019

Linux Cinnamon Tips and Tricks

Desktop Capture

In the system settings window, go to [Preferences] - [Windows]:
Choose [Alt-Tab] tab and set up [Alt-Tab switcher style]:
Icons and thumbnails



Press Ctrl+Alt+Down to list the open applications on the current workspace.
Press Ctrl+Alt+Up to list all of the open applications on all workspaces.

Close a window by pressing Alt+F4.
To see the desktop, press Super+D. To return to the window you were looking at previously, press Super+D again.

Reveal the window menu for an application by pressing Alt+Space.

Tile a Window to the Left, Right, Top, or Bottom
To push the current window to the left side of the screen, press Super+Left Arrow. To snap it to the left, press Ctrl+Super+Left Arrow.

To push the current window to the right side of the screen, press Super+Right Arrow. To snap it to the right, press Ctrl+Super+Right Arrow.

Substitute the Up and Down arrow keys to push or snap the windows to the top or bottom of the screen.

If the “Recent Files” option doesn’t appear in your menu, that’s because there is an option to turn it off in order to protect your computing activities from prying eyes. If you can’t find it on your menu, go to “System Settings” and click “Privacy”. 
Simply toggle it to “on” and adjust further as suits your needs. (But remember, if you select “Never forget old files” your menu will take longer and longer to open as time passes and entries multiply.)
Turn on NumLock on login
gsettings set org.gnome.settings-daemon.peripherals.keyboard numlock-state on
Log out delay To eliminate the default 60 second delay when logging out:
gsettings set org.gnome.SessionManager logout-prompt false
There are two tools you can use to view and edit GSettings values:
  • The dconf-editor GUI tool.
  • The gsettings command-line utility.
# yum install dconf-editor

Auto-Hide The Panel
To set the Panel to Auto Hide, right-click on a blank spot on the Panel. From the menu that appears, click on the Panel Settings item. This will take you to the System Settings application and the Panel category. Once you are in the Panel category, look for the Auto Hide Options. Put a check mark in the “Auto-Hide Panel” check box

super key
screen shots
then click the 'select area to grab'

Take a screenshotPrint
Take a screenshot of a windowAlt + Print
Take a screenshot of an areaShift + Print
Control + Shift + Alt + R will start recording your desktop, and the same combo will end the recording session. No sound is recorded. Recordings are saved as WebM files in your home directory. WebM support is widespread, although some browsers require codecs to be installed.
For more advanced screen recording functionality, recordMyDesktop looks like a good bet.


Applets are items that are added to your panel(s),

Extensions are the spice that changes things the most, in my eyes. They can do anything from change entire features of the environment, to adding transparency to things.

To delete Desklets, right-click on the desktop and select “Add desklets.” Then, under the “manage” tab, select the desklet(s) you’d like to remove, and click the “X” icon at the bottom to remove it from the Cinnamon desktop.

To delete running Cinnamon extensions, press the Windows key and write “Extensions” in the search box. Then, launch the “Extension” app that appears in the search results.

Below are a handful of our favourite themes.
  • Android Holo — Android 4.x style theme
  • Zukitwo — Sleek, stylish and light
  • Minty — Dark theme with bold green accents
  • Metro — Based on the visual style of Windows 8.x
Open Settings > Panel > Layout Options > Panel Layout and select from one of the following:
  • Traditional – this is the default layout, with a panel at the bottom of the screen
  • Flipped – like traditional, but with panel on top of the screen
  • Classic – two panels, one at the top, one at the bottom


Review (572) System Design (334) System Design - Review (198) Java (189) Coding (75) Interview-System Design (65) Interview (63) Book Notes (59) Coding - Review (59) to-do (45) Linux (43) Knowledge (39) Interview-Java (35) Knowledge - Review (32) Database (31) Design Patterns (31) Big Data (29) Product Architecture (28) MultiThread (27) Soft Skills (27) Concurrency (26) Cracking Code Interview (26) Miscs (25) Distributed (24) OOD Design (24) Google (23) Career (22) Interview - Review (21) Java - Code (21) Operating System (21) Interview Q&A (20) System Design - Practice (20) Tips (19) Algorithm (17) Company - Facebook (17) Security (17) How to Ace Interview (16) Brain Teaser (14) Linux - Shell (14) Redis (14) Testing (14) Tools (14) Code Quality (13) Search (13) Spark (13) Spring (13) Company - LinkedIn (12) How to (12) Interview-Database (12) Interview-Operating System (12) Solr (12) Architecture Principles (11) Resource (10) Amazon (9) Cache (9) Git (9) Interview - MultiThread (9) Scalability (9) Trouble Shooting (9) Web Dev (9) Architecture Model (8) Better Programmer (8) Cassandra (8) Company - Uber (8) Java67 (8) Math (8) OO Design principles (8) SOLID (8) Design (7) Interview Corner (7) JVM (7) Java Basics (7) Kafka (7) Mac (7) Machine Learning (7) NoSQL (7) C++ (6) Chrome (6) File System (6) Highscalability (6) How to Better (6) Network (6) Restful (6) CareerCup (5) Code Review (5) Hash (5) How to Interview (5) JDK Source Code (5) JavaScript (5) Leetcode (5) Must Known (5) Python (5)

Popular Posts