Showing posts with label Tools. Show all posts
Showing posts with label Tools. Show all posts

Awesome Tips about Atom Editor


Eclipse vs IntelliJ


Better ways to organize info - Winner: Eclipse
-  Eclipse provides workspace, working set, projects
-  Organizes views into perspectives, provides view like console, problems, errors. 
- We always know where to find info we need.

Editor -Winner: Eclipse
Eclipse shows error/warning in current window in left side bar. 
IntelliJ only shows error/warning for all content in right side bar. (Eclipse also shows things in right side bar)
When you write code, its much easier to check error/warning in Eclipse.

Shortcut keys -Winner: Eclipse
Eclipse's default shortcut is more natural to me: easier to remember and type. Usually Eclipse uses less keys. IntelliJ uses all keys F1-10.

To format code: Cmd+shift+f in eclipse Cmd+alt+l in IntelliJ
- what L means?

Quick fix - Winner: Eclipse
- Eclipse quick fix(ctrl+1) is too powerful, it can fix bugs, generate code based on current context.
- IntelliJ provides too many ways to do similar things - wtf?
Show intention actions - alt+enter
Basic code completion - ctrl+space

Smart type code completion - ctrl+shift+space

Debug
- Drop to frame always works in Eclipse, but doesn't in IntelliJ
- Display view in Eclipse stores history, it's much easier to use

IntelliJ does have its own advantages such as: smart step into for anonymous classes and lambdas.

Search everywhere in IntelliJ
In Eclipse, you have to use different shortcuts/ways to search type, resource, views. 
In IntelliJ, just double press shift keys.

Better Performance/More Stable - Winner: IntelliJ
Sometimes Eclipse is slow or gets stuck, you need take time to customize it, check Improve Eclipse Performance


Same code may work in Eclipse but not in IntelliJ
Eclipse and IntelliJ doesn't works well together, if some team members are using eclipse, you better also use eclipse, as sometimes, the same code works and can be deployed in eclipse's tomcat but doesn't work or can't be deployed in IntelliJ tomcat.

More about Eclipse and IntelliJ:
Mastering Eclipse IDE - Tips, Tricks
IntelliJ IDEA Tips and Tricks

A Guide To Video And Audio Conversion Using FFmpeg


Productivity Tools for Developers



Chrome Tips && Tricks

iTerm2

Slack

Bold: *your text*
Italics: _your text_
Strikethrough: ~your text~
Inline code: 
`Format one word or one line`
// ```Format blocks of text```
Quotes: 
> Quote one sentence
>>> Quote multiple sentences

HipChat App

Quip

Adobe Reader

GitBook

trello.com

Misc

Type Less
  • Alias

Awesome Tips about Markdown


Sharing content using QR codes


IntelliJ IDEA Tips and Tricks


Postfix Code Completion
some.var/if//try/twr/inst/throw/sout/
some.for/fori/forr/field/cast/null/nn

Shortcuts
Search Everywhere - Double-press Shift
Find action by name - command+shift+A
Show intention actions - alt+enter
Basic code completion - ctrl+space
Show type hierarchy    - ctrl+h
Delete lines - Command+Delete
Move caret to text start/end - Command+fn+left/right
Move caret to line start/end - fn+left/right or command+left/right

Navigation - link
Command+E - Recent files
Command+shift+E - Recent edit files
Go to Line              - Command+L
Show Javadoc        - Ctrl+J
Go to last edit location - Command+Shift+Delete
Open Javadoc  - F1
Alt+1 - open project view, Alt+5 - open debugger view

Add javadoc
- Typing /**
- Add shortcuts(Alt+Shift+J) to Fix doc comment

Class structure view (outline)
- Command+F12, Press Command +F12 again to show inherited methods

Format code - ctrl+alt+l
Organize import - ctrl+alt+O
Find in path = command+shift+F

Structure view - Command+7

Project View - Command+1

Increase font size (Zoom text)
Open Settings (Ctrl+Alt+S), search for "zoom", select Editor.
Select "Change font size (Zoom) with Ctrl+Mouse Wheel"

Live template - Command+J
main - generate main method
sout - just print System.out.println()
soutm - added Class name & method name
soutp - added parameter
soutv - added last variable name

soutf 
serr

psf – public static final
psfi – public static final int
psfs – public static final String

ifn – Inserts if null statement
inn – Inserts "if not null" statement

inst – Checks object type with instanceof and down-casts it
geti - create singleton getInstance method

Create new template - sfl4j log
Preferences > Editor > Live Template

Switch between views - Alt+F1
Find class        - Command+O
Find file by name - Command+Shift+O

Find/replace text string in the current file - Command+F/R
Find/replace text in the project or in the specified directory  - Command+Shift+F/R

Expand or collapse a code fragment in the editor - Command(+)+/-

Code completion - Ctrl+Space
Smart completion - Cmd+Shift+Space

Refactor This - Ctrl+T

Coding
Surround with action - alt+command+T
Overwrite methods - ctrl+O
Implement methods - ctrl+I

Refactor
Rename - shift+F6

Code generator - Command+N
Copy reference -> Copy qualified name in eclipse

Debugging
Quick evaluate expression - Command+alt+F8
Smart step into                   - Shift+F7
Step into                             - F7
Step over                            - F8
Step out                              - Shift + F8
Stop program                     - Command+F2

Scala
Type declaration action - ctrl+shift+B
Type info action - ctrl+shift+P
New scala worksheet

Preferences - Command+,
Inspections
Intentions

Keymap
- Add shortcuts
Command+shift+W - Close all files in editors
Hide iml and idea files
Preferences > File > Settings > Editor > File Types and add ;*.iml;*.idea; at the end of the Ignore files and folders text box.

Configuration
Never use wildcard imports 

  • Settings > Code Style > Java > Imports tab
  • Set Class count to use import with '*' to a bigger value
  • Set Names count to use static import with '*' to a bigger value

Link with editor(eclipse)
Project view > gear icon > select Autoscroll from source
File -> Settings -> Editor -> General -> Show quick documentation on mouse move

Web Servers
Add -Xmx6g to vm options in server tab

IntelliJ problems view don't refresh itself when there is new compile error. Switch to other view then switch back.

IntelliJ show compile error at right side bar - unlike Eclipse which shows error/warnings in left side bar.

Configure > Project Defaults > Project Structure
-> Project tab -> Project SDK

When to Use IDEA
- Scala projects or projects that use SBT.

Trouble shooting
File | Invalidate Caches
Delete IDEA system directory
Messed up external libraries
Sometimes external libraries still keeps reference to old libraries that are not used any more, the workaround is to delete .idea/libraries internals and restart IntelliJ and reimport projects.

Resources
Meet IntelliJ IDEA

Tools for Programmers - 2016


Atom
Alternatives - Sublime Text

iTerm2
brew cask install iterm2
Preferences > Profiles > General > Working Directory > Reuse previous seesion's directory

highlight errors and warnings
Preferences > Profiles > Advanced > Triggers > Edit
(?i:.*(conflict|fatal|error|warn).*) // Yellow on Black

Visual Studio Code: VSC
-- Auto complete for javascript
npm install tsd -g
tsd query -r -o -a install angular jquery

Auto Completion
Git Auto Completion
-- auto complete git commands, branche names, remote names etc
Maven Auto Completion
-- -DskipTests

Chrome
chrome://settings/cookies
chrome://about/
document.designMode='on'
- Enable copy & paste functions
Chrome Extensions
Quick Tabs
Sight
CheckChrome
Click to Remove Element
Postman
Grammarly Spell Checker & Grammar Checker
Octotree - Code tree for GitHub and GitLab

chrome flash is blocked on this website
Try setting chrome://flags/#prefer-html-over-flash as disable and restart Chrome.

JD-GUI - Java Decompiler
HomeBrew
brew update
brew upgrade $FORMULA

jq - command line json proccessor
jq ' .response.docs.[0].field | length ' solr-rsp.json
jq '.response.docs' solr-rsp.json
curl 'solr-query' | jq '.' > result.json collections_list = $(curl "http://host:port/solr/admin/collections?action=LIST&wt=json" | jq '.' curl "" | jq '.collections|join(" ")'')

Docker
docker run -d -p 80:80 --name webserver nginx
docker ps
docker exec -it container_id /bin/sh

docker kill/stop $(docker ps -q)
docker build --no-cache .
docker-compose build --no-cache mysql

Delete all containers
docker rm $(docker ps -a -q)
Delete all images
docker rmi $(docker images -q)

Redis
redis-server to start server
redis-cli
redis-cli shutdown
KEYS *
KEYS pattern

TTL key
TYPE key
FLUSHDB - Removes data from your connection's CURRENT database.

FLUSHALL - Removes data from ALL databases.
ZRANGE key start stop [WITHSCORES]

Kafka
Delete a topic in dev:
./bin/kafka-configs.sh --zookeeper localhost:2181 --alter --entity-type topics --entity-name $topic-name --add-config retention.ms=1000
-- wait for several minutes, and verify there is no data:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic $topic-name  --from-beginning


bin/kafka-configs.sh --zookeeper localhost:2181 --alter --entity-type topics --entity-name $topic-name --delete-config retention.ms

Commands
mysql.server stop
mysql.server start
SHOW CREATE TABLE tbl_name
DESCRIBE tbl_name

SourceTree
Postman

Markdown
List: +, *, -
Link:
[link text](link url "hover popup text")
```shell(java etc)
``` Java 
CFR 
- A decompiler that supports Java 8 language features, including lambda expressions and me
thod references.
JD-GUI

cygwi
jcmd: One JDK Command-Line Tool to Rule Them All
sudo -u tomcat jcmd pid Thread.print > thread.print
sudo -u tomcat jcmd pid GC.heap_dump heapdump.hprof

Thread dump Analyzer
http://fastthread.io/
https://spotify.github.io/threaddump-analyzer/

Heap dump Analyzer
Eclipse MAT

GC Log Analyzer
http://gceasy.io/
https://github.com/chewiebug/GCViewer

Misc
Blogspot
Search for multiple labels
search/label/LABEL1+LABEL2
/search/?q=label:LABEL1|label:LABEL2

Using Java Code Quality Tools to Identify Bugs


The Problem
The following code will return NPE, when the instance Integer field - integerFlag is null, but it's difficult to capture the error when review the code.
    public int method() {
        if (integerFlag == 0) { //or BoolanFlag == true
            return;
        }
        //...
    }

The fix is to change the == to: Objects.equals(integerFlag, 0)
-- Use Objects.equals to compare equals as it's null safe.
-- Use common util libraries such as CollectionUtils.isEmpty etc.

But how can we utilize code analysis tool to capture this kind of errors for us? 

In Java, we can integrate findbugs, pmd, Sonar in maven, then run mvn site:site site:stage, the developers have to scan changed code and fix reported problem if needed before send it out for review. 

This will make developers and reviewers life easier.

Tools to help detect bugs
Github link: https://github.com/jefferyyuan/code-quality-mvn

FindBugs
findbugs:gui, findbugs:gui, findbugs:check
Extensions
fb-contrib

PMD
pmd:pmd, pmd:cpd
http://pmd.sourceforge.net/pmd-4.3.0/rules/basic.html

@SuppressWarnings("PMD.AvoidUsingHardCodedIP")

mvn site:site site:stage
Integrate findbugs, pmd into mvn.

Facebook Infer
brew upgrade opam
brew update && brew upgrade opam
./build-infer.sh java
-- If it fails due to missing packages, uses opam install.
Infer on maven project
mvn clean &&  infer --debug -- mvn compile -o

too many open files on osx
sudo sysctl -w kern.maxfiles=20480
sudo sysctl -w kern.maxfilesperproc=22480
sudo ulimit -S -n 2048

Google Error Prone
https://github.com/google/error-prone/issues/376

Sonar
Code Analysis with SonarQube Plugin
Install and run Sonar server
mvn clean verify sonar:sonar
mvn verify -Pcoverage,jenkins -Dsonar.host.url=http://localhost:9000 sonar:sonar

Install plugins
http://localhost:9000/updatecenter/installed
https://wiki.jenkins-ci.org/display/JENKINS/Static+Code+Analysis+Plug-ins

Checker Framework
Run Maven example first.
Install checker eclipse plugin.
Use annotation in comments
/*>>>
import org.checkerframework.checker.nullness.qual.*;
import org.checkerframework.checker.regex.qual.*;
*/

Configure Eclipse Compiler Warnings
Enable null analysis, unbox conversion, missing default in switch etc
Leveraging JSR-305 null annotations to prevent NullPointerExceptions
Use @CheckForNull, @Nonnulls

Misc && Issues
Use -X to print more log and check the log

maven-compiler-plugin Unsupported major.minor version 52.0
Some plugins may only work with jdk8 or jdk7, use export to change JAVA_HOME to JDK8/7 and rerun.


SSH: Practical Guide for Developers


It's common that your server(destination_server) is running in cloud(AWS) which you have to access via another linux server(proxy_server), and you want to enable remote debug in the destination_server.

To do this, run this in the proxy_server:
ssh -f -N -L9999:localhost:9999 username@destination_server

Run this in your local server:
ssh -f -N -L9999:localhost:9999 username@proxy_server

In your destination_server, add this to the command that is used to start your server.
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9999

Then start remote application in eclipse that connects to localhost:9999.

-- If Eclipse is very slow in remote debug mode, try to remove (all) breakpoints and expressions in eclipse.

-- Use ssh tunnel, you can do a lot of other stuff.
-- We can use ssh tunnel to test code locally without really deploy to aws.

ssh -f -N -L18983:remote-host:remote-port $USER@host-in-middle

SOCKS and dynamic port forwarding
1. .ssh/config
host server
  DynamicForward 1080


2. ssh -fND localhost:1080 bastion_server
ssh -fND 1080 bastion_server

curl --socks5 localhost:1080 remote_url

Java code
-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=3000
System.setProperty("socksProxyHost", "127.0.0.1");

System.setProperty("socksProxyPort", "3000");


Install Proxy SwitchySharp in Chrome

-f  send this ssh operation into the background after password prompts
-N do not execute remote command or wait for the user to provide any commands
-L static port forward
-D the local port to listen on
  - for dynamic port forwarding

Related
Create tunnel to remote Cassandra via man-in-the-middle
ssh -f host-in-middle -L 9042:destination-cassandra-server:9042 -N -v

Resources
SSH Tunneling Explained
SSH Tunnel - Local and Remote Port Forwarding Explained With Examples

Notepad++: Best Text Editor in Windows


IMHO, Notepad++ is the best text editor in Windows.
It provides great features like: auto-completion, periodic backup and session snapshot etc.

File Switch
Ctrl+Shift+O to switch between opened files

DSpellCehck

XML Tools
Pretty print XML fines Ctrl+Alt+Shift+B

JSTool
JSFormat Ctrl+Alt+M

MIME Tools
URL Encode/Decode
Base64 Encode/Decode

HEX Editor

TextFX

Update: -- As I am moving to Linux(Mac) based development, it's time for me to learn and use some text editors that works on all platforms. 
-- Now I use atom.

Image Transformer (Resize, Rotate, flip and Enhance)



check a file on the web...
Image URL:

or check a file on your local disk

or drop files here

Transform Image:
Resize: New Width:     New Height: Stretch:
Rotate: Rotate Degree: 90    180    270   
Horizontal Flip
Vertical Flip
Enhance Iamge


This server side is deployed on GAE, it uses GAE's ImagesService to resize, rotate, flip and enhance images.
GAE Images Java API Overview

Exif Viewer: Extract Metadata from Image



check a file on the web...
Image URL:

or check a file on your local disk

or drop files here
List All Meta

This server side is deployed on GAE, and uses java metadata-extractor lib to extract meta data from image files.
https://drewnoakes.com/code/exif/
https://code.google.com/p/metadata-extractor/w/list

Boilerpipe Demo


Boilerpipe Demo
Welcome to the Web API for the boilerpipe Java library.
boilerpipe provides algorithms to detect and remove the surplus "clutter" (boilerplate, templates) around the main textual content of a web page.

Original Demo is at http://boilerpipe-web.appspot.com/, but it's too popular, and we often meet got "Over Quota" error, so I made this simple demo here for anyone who is interested in Boilerpipe.



Result:  

Dict Demo


This is a practical usage of Jsoup to extract content from webpage.



Result:  

JSoup Demo


This is an example to demonstrate how to use JSoup's selector to extract content form a webpage.













Result:  

Simple Web Proxy


Some companies may block some website for unreasonable reason, for example: block Google Cache site: webcache.googleusercontent.com, mark it as Proxy/Anonymizer. This is a pain at sometime when we have to access google cache. So I wrote this simple tool.

Result:  

Example: Using IFrames


maximize








Labels

ANT (6) Algorithm (69) Algorithm Series (35) Android (7) Big Data (7) Blogger (14) Bugs (6) Cache (5) Chrome (19) Code Example (29) Code Quality (7) Coding Skills (5) Database (7) Debug (16) Design (5) Dev Tips (63) Eclipse (32) Git (5) Google (33) Guava (7) How to (9) Http Client (8) IDE (7) Interview (88) J2EE (13) J2SE (49) JSON (7) Java (186) JavaScript (27) Learning code (9) Lesson Learned (6) Linux (26) Lucene-Solr (112) Mac (10) Maven (8) Network (9) Nutch2 (18) Performance (9) PowerShell (11) Problem Solving (11) Programmer Skills (6) Scala (6) Security (9) Soft Skills (38) Spring (22) System Design (11) Testing (7) Text Mining (14) Tips (17) Tools (24) Troubleshooting (29) UIMA (9) Web Development (19) Windows (21) adsense (5) bat (8) regex (5) xml (5)