5/17/2016

Java Servlet Server related info

Tomcat can be run as a standalone server. Tomcat can also be run as an add-on to the Apache HTTP Server (or Microsoft IIS) - as the Java servlet/JSP container. In this combination, Tomcat executes the Java servlets and JSPs, the Apache serves the static HTML pages and performs other server-side functions such as CGI, PHP, SSI, etc. Read "Why should I integrate Apache with Tomcat? (or not)" at Tomcat FAQ (http://wiki.apache.org/tomcat/FAQ/Connectors#Q3).

5/06/2016

Setup Eclipse

(On Windows, cygwin or MinGW gcc must be installed. When creating a new project, Cygwin GCC must be selected.)

How to add an existing GIT project to Eclipse?
Install EGit from Market Place
Open Git Perspective, in Git Repositories | click Add an existing local Git Repository ...

In Project Explorer | Import | Git (Projects From Git) | Existing local repository | select the local Git Repository that was just imported.

Choose "Import using the New Project wizard" | Makefile Project with Existing Code | Fill the name and location of code.

After importing the Git repo, need to use the Exclude Build option to exclude some folders from building.
Right click on the folder | Resource Configurations | Exclude from Build | Select or Deselect | OK

Also need to mark some folders as derived, such as bazel-* folders. Right click on the folder | Resources | Click "Derived"

Also need to remove derived folders from sources. Project Property | C/C++ General | Path and Symbols | Source Location | Edit Filter | Remove bazel-bin,bazel-deepmap,bazel-testlogs etc.

Install Plugins:
Protocol Buffer: Install from Eclipse Marketplace
sudo snap install beautysh: Install Bash editor, then Save Actions: execute command on save beautysh $filename

C++ Formatter:
Install CppStyle from market place and use clang-format.


C++ symbol/function could not be resolved:



NOTE: The project must have the 'includes' folder, which contains the C++ headers, also make sure the static folder has all the necessary header files. If something doesn't resolve, DON'T rebuilt it over and over again. Just make sure the header can be found in the project and click Project | C++ Index | Resolve Un-resolved includes. If it doesn't resolve by doing that, rebuilding the whole thing doesn't help either.

First: Disable build automatically




1. Project Property | Preprocessor Include | Providers | CDT GCC Built-in Compiler Settings | Command to get compiler specs:
Add -std=c++11 to the Command to get compiler specs.

Open Window | Preferences | C/C++ | Build | Settings | Discovery | CDT GCC Build-in Compiler Settings
Append -std=c++11 to the Command to get compiler specs
Press OK

Rebuild the index: Project | C/C++ Index | Rebuild

2. Add third party dependency:
Project Property | C/C++ General | Paths and Symbols | Source Location | Link Folder
Choose the folder that has the third party dependency.

Add protos to the Source Location:
bazel-deepmap/bazel-out/local-fastbuild/genfiles/protos/

Project | Clean then Project | C/C++ Index | Rebuild

3. Enable auto completion
Window | Preferences | C/C++->Editor->Content Assist | Auto-Activation | Advanced
Enable: Help Proposals, Parsing-based Proposals, Template Proposals

Possible issues:
================
1. Column margin (ruler) is at wrong position:
Upgrade to Photon 4.8 version fixed it.

2. Ctrl + Click not working:

To work around the problem, you can disable the Change Log hyperlink by going to Window | Preferences | General | Editors | Text Editors | Hyperlinking, then untick "Changelog Detector"

Change selection color:
General | Editors | Text Editors, change Selection background color to #FF7F00

How to Import existing projects to a new workspace:
===================================================
Import | General | Existing Projects into workspace | Locate the workspace AND CHECK 'Copy projects into workspace'

/bin/cp -rf /mnt/machome/liangzou/workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings ~/workspace/.metadata/.plugins/org.eclipse.core.runtime/

.md file editor
================
Use WikiText editor to open it.
Change settings: Colors and Fonts | WikiText | Monospace Font. Change it to Hack 9 (the same as Text Font).
General | Editors | Text Editors | WikiText | Appearance, change all places that use font-family: monospace to font-family: Hack, monospace; font-size: 9pt;

BUILD file editor
=================
TBD

Disable caret blinking
======================
For Ubuntu cinnamon, System settings | Keyboard turn off text cursor blinking
Then in Eclipse settings, search for caret, click Enable custom caret
 
Setup Javascript
==============
Eclipse 2024.09
The default javascript editor is not supported anymore. To use the previous Javascript syntax coloring:
1. Install the Web development tools
2. Open a *.js file, right click and select Switch to Theme
3. How to edit the theme? In the preference, search for theme under TextMate. Add OneDrive/liang-textmate-Light.css as one of the themes. (Find all the css files used by Eclipse: https://github.com/eclipse-tm4e/tm4e/releases/tag/0.14.0, download the source code and find in the folder of org.eclipse.tm4e.ui/themes/)

Setup Python
============

https://liangzou.blogspot.com/2019/06/how-to-setup-eclipse-pydev-to-run-yapf.html

Enable pydev checking: Preferences | Spelling Add User defined dictionary: /home/liangzou/eclipse-workspace/user-dict.txt
Then click on the word that eclipse doesn't recognize, press ctrl + 1, then use up/down key and enter to select the options.

Setup Go Editor
===========

Need to disable AnyEdit Tools (Format some code on save if that editor doesn't support)






Setup Text Editor
=============
Show white spaces



Change the Transparency level to 255

4/29/2016

How To Port a CMake build project to Bazel

For large project, say OpenCV, the CMake build can be very complicated, which makes it difficult to create a BUILD file directly for Bazel. This article will describe an easy way to add a BUILD file.

1. cmake and make the project to create pre-compiled .a files.


2. Find all the header files in the project packages. Usually they're included in folders named with "include". A command to find all "include" folders.
find . -iname include

3. Create a new git repository on github.com. Check in all the .a and header files to the repository. The repository can be 'projectname'-'version'-precompiled, e.g. opencv-3.1.0-precompiled. Also, a BUILD file should be checked in with them. An example of the BUILD file: https://github.com/zoukyle/opencv-3.1.0-precompiled/blob/master/BUILD

4. Then the project can be depended by your own project. In your Bazel WORKSPACE file, you'll need to add:
git_repository(
    name   = "precompiled_opencv_git",
    commit = "cac2317cde1d4c9b68c6c4425d7171322d52aaed", # The latest commit id
    remote = "https://github.com/zoukyle/opencv-3.1.0-precompiled.git"
)

bind(
    name   = "opencv",
    actual = "@precompiled_opencv_git//:opencv_lib",
)

 
5. Say you want to bazel build a binary. In the BUILD file, you can add the dependency:
deps = [
    "//external:opencv",
], 

4/28/2016

Software Development Tech Stacks

Software Development Tools

Build Tool: Bazel
Source Control: git
Code Review: gerrit
Bug Tracking: Jira
Message: Protocol Buffer
RPC: gRPC
Continuous Build: Jenkins
Machine Learning: TensorFlow
Deployment: Docker
Logging: loggly (Need to research on it)
Code Diff: meld (On Mac: port install meld)

Java:
1. Jetty: HTTP server
2. Jersey: Maps URL to functions
3. gson: Java object to JSON 
4. CometD: Comet is a set of techniques which allows web applications to push data to the browser. It is also known as Ajax Push, Reverse Ajax and HTTP push server among others.

Java Unit Test:
1. JUnit
2. mockito: mock

C++:
1. glog
2. gtest

Python:
1. Django: web framework

4/26/2016

How to use .bashrc file on Mac for the terminal

In /etc/profile add:
if [ -n "$BASH_VERSION" ] && [ -f $HOME/.bashrc ];then
    source $HOME/.bashrc
fi


Under $HOME, create .bashrc file. The content should be: http://liangzou.blogspot.com/2016/06/commonly-used-linux-aliases.html


 

How to install SciTE on Mac

Install MacPorts

sudo port install scite

You also needs to install X11. http://www.xquartz.org/

That's it.

How to set SciTE as the default editor?

Open Script Editor and Save the following script as an Application:

(* This script is destined to be saved as an application droplet. It will process the items dropped onto it. *)

-- This routine processes the dropped item(s)
on open theDroppedItems
repeat with i from 1 to the count of theDroppedItems
set aDroppedItem to item i of theDroppedItems
processItem(aDroppedItem)
end repeat
end open

-- This routine processes an item
on processItem(anItemToProcess)
set pathUnix to POSIX path of anItemToProcess
set pathUnixQuoted to quoted form of pathUnix
-- Here you make your shell command !
set commandToRun to "/opt/local/bin/SciTE " & pathUnixQuoted
do shell script commandToRun & " &> /dev/null &"
end processItem

Best Mac Apps

Video Player: MPlayer(SMPlayer)
Image Viewer: XnViewer
Window Management: Spectacle
Instant Messenger: The System Message App, which support Google Talk and Other Services
Text Editor: Emacs (emacs on Mac OS) or TextWrangler if you don't know how to use emacs
Screen recording: Quicktime
Webcam: CamTwist which can convert your DSLR camera to a webcam. Basically it can pull video stream from a window to serve as a fake camera.
VNCViewer: RealVNC
Hex Binary Viewer: Hex Fiend
Put App to the menu bar: https://github.com/xiaogdgenuine/Doll
Terminal: iTerm2 (Need to install bash, brew install bash)
Setup shortcuts: Keyboard (Shortcut part) and Shortcuts app