不辜负自己,不将就生活。

Category: Tools

GitViewer for Better Git History Viewing

As a SCM admin I need to browse the Git repository history. There are some tips for a prettier history view such as this, and Git includes gitk in the distribution as well. However I think both do not present the history clearer enough.

Crc8 wrote a very good tool GitVersionTree. I think it shows the git log more clearly, by placing master branch a more important way. It uses Graphviz to render the version tree.

However sometimes the tool fails due to some syntax errors in the dot file, which is used by Graphviz to generate the final picture. I find it is sometimes due to the git directory name. Besides, I prefer CLI to GUI because it simply integrates with other tools better. So inspired by GitVersionTree, I rewrite in Python and provides the tool in CLI. I call it GitViewer.

Use GitViewer is quite simple. Just type:

python GitViewer.py -o [output filenamea] -d [path to dot executable] -g [path to git executable] -r [path to git repository root]

and GitViewer shall generate a pdf of the version tree for you.

GitViewer is currently v0.1, so the feature is just limited to what GitVersionTree implemented. In v0.2, I plan to add comments to the picture which will make the history more clearer.

GitViewer requires Python, Git, and Graphviz to work properly. Both Windows and Linux shall be supported.

Awesome Plugins for Vimers – 3

Vim plugins continued …

Nerd Commenter

Always we need to add comment, toggle comment in our codes, and there are different comment syntax for different programming languages. With nerdcommenter, forget about the difference, simply achieve these needs with a hotkey, and the right comment style will be applied depending on the file type. It is a very focused plugin that does the one thing very well. I like it. It is also a plugin from Martin Grenfell 🙂

DoxygenToolkit

A good coding practice is using doxygen style to comment functions, modules and files, later using the Doxygen tool to auto generate documentation. With DoxygenToolkit, you can forget about doxgen formats but focusing on the real important part: like function illustraion, parameter explaination, etc.

I often use DoxygenToolkit to comment my functions and modules, nerdcommenter to do general purpose comment, and vim-licenses to generate correct license headers. Altogether they work great.

ctrlp

ctrlp is a very famous and useful plugin. Basically with ctrlp, we can do fuzzy finding by file, mru, buffer, tag, etc. As the plugin name shows, just use Ctrl+p and see!

ag.vim

ag.vim is a vim front end for calling the silver searcher ag. In my post “Useful Development Tools – 3”, I recommend using ag for searching in source codes as ag works smart and fast.

However recently ag.vim indicates in the github that it is deprecated and suggests the use of ack.vim. Well I have not tried the latter but you can git a try. But ag.vim still works now.

Awesome Plugins for Vimers – 2

Vim plugins continued …

YouCompleteMe

YouCompleteMe is the best auto-completion plugin for Vim. It contains support for a variety of programming languages, such as c, c++, python, javascript, etc. YCM also supports the powerful snippet plugin Ultisnips. One thing I think YCM is great is the way it supports semantic completion. By semanic completion, YCM understands your code at realtime, not by simply guessing patterns from buffer which is implemented by other auto-completion plugins such as neocomplete. However, due to YCM uses clang, it is a bit hard to install YCM on Windows, in such conditions, you can choose install a precompiled YCM, such as this one.

Ultisnips

Ultisnips provides the best snippet for Vim. YouCompleteMe integrates support of Ultisnips as well, which means when you type, the system will give you smart hints for snippets if available in addition to buffer or semantic completion. The experience is perfect.

Syntastic

Syntastic is used for static checking of source codes. It comes from Martin Grenfell, author of nerdtree and nerdcommenter. Syntastic runs well with a variety of programming languages and checkers, such as cppcheck, jshint, pylint, tidy, prettyccs, etc. I recommend you to install Syntastic along with YCM, as it enhances YCM with a decent syntax checking. Type :SyntasticInfo to see the available checkers you have, and install your preferred tool.

vim-licenses

Vim-licenses is a plugin that eases adding license to the top of the buffer. I think it is good practice to confirm your license for the source codes you write. It not only shows your professionalism, but also indicates your respect for the open source movement. But first, understand different open source licenses such as GPL, LGPL, MIT, BSD, Apache, etc. When you uses source codes from others, either non-commercial or commercial, always read its license and behave correspondly.

To be continued…

Awesome Plugins for Vimers – 1

Vim is a flexible and powerful editor. There is always a saying about 3 kinds of editors in the world (Vim, Emacs and the others), and there is always a war between Vim and Emacs.

I am not interested in the battle of world’s best editor, but I can convince you that although Vim comes with a bit steep learning curve, when you are used to it, you will always understand why lots of programmers choose it.

One important feature of Vim is its support for plugins. It is those plugins that enhance Vim for different uses. Here I will recommend several awesome plugins which I believe essential for Vimers.

Vundle

Vundle is a great plugin manager for Vim. It is the first ever plugin a Vimer should install. After that, Vundle takes charge of all the other plugin maintenance taaks, including downloading, installing, loading, updating, cleaning, etc. With Vundle, you only need the vimrc file when swithing computers, Vundle ensures you always getting the same configuations and plugins.

The NERD Tree

Nerdtree is a plugin for file system exploration in Vim. You can navigate through the filesystem tree with keyboard or mouse easily with the plugin. You can also bookmark certain folders or files in Nerdtree for quick access.

tagbar

Tagbar is the famous taglist alternative. Like taglist, tagbar internally uses ctags to generate at realime tags for the file, but tagbar has more support for OO languages such as c++.

a.vim

a.vim is used for quick switch between source and header. For example, when you are editing foo.c, simply type :A and you will be editing foo.h, or :AS makes a split window for editing foo.h.

To be continued…

Useful Development Tools – 3

This article continues my last blog.

Source Navigation

cscope and ctags

Cscope and ctags can assist you in when browsing source codes. You can use ctags with Vim plugins like tagbar or taglist, and Vim also supports cscope jumping. Both cscope and ctags are good alternative to commercial software like Source Insight, Scitools Understand and Crystal Flow, and they are always available in Linux and Windows.

Searcher

grep and grepWin

Grep is an essential tool in Linux system. And if you are working on Windows, you can consider using the alternative grepWin, it has a decent UI as well.

Ag

Ag is called the silver searcher, and can be integrated with Vim using ag.vim. I find ag very fast when searching codes, because perhaps it is smart in its searching, like ignoring files flagged in .gitignore. I will recommend you to use it instead of grep tools for source codes. For general regex search, using grep instead.

everything

Everything works only on Windows. Well, if you read my posts, you will find that I prefer cross-platform tools, that is because sometimes I have to work on both platforms (Linux and Windows), and I enjoy having the same experience. However, everything is so great tool that I cannot ignore it here. It is super-fast when searching NTFS files, in a blink of eyes, but it only searches by file name. You will find it very useful when you try to find a file that buried in SOME direcoty that you have forgot.

Offline Documentation Browser

Zeal

Zeal is a quite new tool, featuring offline documentation browsing. Mac programmers always find Dash indispensable, now zeal is an open source alternative to Dash and works on both Linux and Windows. Actually, zeal uses api docsets from Dash I suppose, and it now supports 198 docsets. Zeal can be integrated with Vim with zeavim, and you can cross-reference from your source code to its api documentation easily with your defined hot keys.

Useful Development Tools – 2

This article continues my last blog.

Console Multiplexer

GNU screen – Effectively uses your console!

GNU screen is a magic. It allows you simply create multiple “tabs” inside a session, and switch between them without using a mouse (WHY bothering to use mouse if you can use your keyboard more efficiently?). This suits console well. Besides, the detach and restore helps remote users especially with link failure!

cmder

GNU screen is for Linux. If you are working on Windows, you should replace cmd with Cmder! It enhances the Windows console with a lot of features, and it has tabs and if configured properly, a closer experience to GNU screen. Besides, since cmder has git embedded (I mean cmder not cmder_mini), you have those basic Linux commands available, as well as Git.

SSH Client and Tool

PuTTY

Putty is my favorite SSH client and serial terminal (I mention it in serial terminal too as you will see). No installations, free, cross-platform, putty has all the features you need as a SSH client. Putty is a very good alternative to commercial software SecureCRT. But if you want SSH file transfer, see below.

FileZilla

Putty also provides file transfer with PSFTP, but I find it more convenient with some GUI clients like FileZilla. FileZilla support FTP as well as SFTP, and it is cross-platform too.

Serial Terminal

PuTTY

Hey Putty again! The serial terminal provided with Putty will meet your needs most of the time, but it lacks hex support. If you want hex support, you should consider following tools.

CoolTerm and AccessPort

Both of the tools support displaying hex for received serial data, but CoolTerm seems not able to send hex string. If you want to send hex as well, use AccessPort. AccessPort has not been updated for a some time, but per my test, it works well with even Windows 10. AccessPort only works on Windows, while CoolTerm is cross-platform, supporting Windows, Mac and Linux.

Packet Sniffer

Wireshark – Powerful Sniffer for Ethernet, ZigBee, etc.

Wireshark is cross-platform and on Linux, it enhances tcpdump with clear UI (Wireshark can open tcpdump files). Wireshark supports ethernet sniffering well, features powerful filtering, and lots of protocol decoding built in.

With a compatible ZigBee dongle, Wireshark also supports ZigBee packet sniffer to ZCL level. Actually, any 802.15.4 packets, thus even 6LowPan, or any protocols built upon that, like Thread, should be supoorted by Wireshark as well. With an active community behind, Wireshark is continuouslly being add more protocols to expand parsing capability. Think about Ubiqua, the commercial ZigBee protocol analyzer software, it costs $999 per license!

Case Sensitive Files in Git Windows

There are cases which cannot happen with Linux, but could happen when you use Git in windows:

e.g.

In remote Git repo contains 2 files:

Log.c and log.c

When you clone the repo using Git windows, you will only have log.c in your working copy, but when you issue git status,

it will always tell you a modified, unstaged, Log.c

So it is a BAD PRACTICE to have 2 files with the same(only case-different) name. This is NOT cross platform.

To delete either one from the remote repo, you can use a Linux machine, or, use following steps on Windows: (In this example, rm Log.c)

Steps

  1. git mv Log.c CASESENSITIVE.c
  2. git commit -m “xxx”
  3. git reset –hard HEAD
  4. git rm CASESENSITIVE.c
  5. git commit -m “xxx”

Useful Development Tools – 1

Open source has changed a lot of things, notably, abundant tools that are of quality, usability and activeness. Here I will list a number of them which change my life doing development.

Editor

Vim – the ultimate editor

I have tried many editors, which includes, sublime text, ultraedit, notepad++, and those heavy ones like Eclipse, Visual Studio, etc., and I have to admit that the one fits me best is the vim, of course, vim with suitable plugins.

Vim is availble in all platforms including Linux, Windows, with both x86 and x64 versions, thus I can always have the same experience, the hotkeys, and without the mouse.

Eric S. Raymond in his book “The Art of UNIX Programming”, however, insists that emacs be better. Everyone is free to choose, but I believe the word that Andrew Hunt and David Thomas once said in their book “The Pragmatic Programmer”:

Use a Single Editor Well

Diff Tool

Meld – A decent choice

I have tried Beyond Compare, which I think is the best in the field, yes the best. WinMerge, P4Merge, tortoise Diff, vimdiff, they are good but for some reasons I do not like them. But Beyond Compare is not free or open source, and meld, in my point of view, works as a decent alternative to Beyond Compare. I like its visual interface, and its easy integration with SCM like git.

Besides, meld is also cross-platform, which I will always have it, no matter which platform I am working on.

SCM

Git – Believe Linus

When I started development, I used CVS to track my codes, then Subversion, which is way better than that. But it was until Git that I thought a modern version control had come. Thanks to Linus Torvalds, the creator of Linux, contributed to the community the simple yet powerful toolsets. Every developer should start using Git in their daily work, even without a remote repository.

Git also enables never-so-easy collaboration between developers. The pull request, branch, rebase, merge, all act as interesting but socialized things, much much better than the days developers sending patches.

Use it!

© 2025 A Life Climber

Theme by Anders NorenUp ↑

error: Content is protected !!