ManyCodes.com – codes & scripts Get free programming codes and tutorials!

11Jan/120

Source Insight Tips and Tricks and Tweaks

1. Specify file types to add in a project
Option -> Document Options -> Document Type -> Include when adding to projects
2. Add new language support
Option -> Preferences -> Languages -> Import/Add3. Associate new file type to some language
Options -> Document Options -> Document Type -> Add Type

4. Add new files to project automatically
Project -> Synchronize Files -> Add new files automatically

5. Show full path of source code file
Preference -> Display -> Trim Long Path Names With ellipses

6. Project dependency
Option -> Preference -> Symbol Lookups -> Add Project to Path

7. Create common projects
Option -> Preference -> Symbol Lookups -> Create Common Projects

8. Colors
Background Color: Option -> Preference -> Windows background -> Color
Foreground Color: Option -> Preference -> Default Text -> Color

9. Fonts
Options -> Document Options -> Document Type -> Screen/Print Font

NOTE: Options -> Style Properties has more control on each element's font and color. You can save all your settings as disk file and share it with others in this dialog box.

10. Fixed width view
View -> Draft View, actually, ignore all style settings

11. Shortcut Keys
Use can set using: Options -> Key Assignment

The common default settings are:
Ctr l+ = : Jump to definition
Alt + / : Look up reference
F3 : search backward
F4 : search forward
F5: go to Line
F7 : Look up symbols
F8 : Look up local symbols
F9 : Ident left
F10 : Ident right
F12 : incremental search
Alt+, : Jump backword
Alt+. : Jump forward
Shift+F3 : search the word under cusor backward
Shift+F4 : search the word under cusor forward
Shift+F8 : hilight word
Shift+Ctrl+F: search in project

12. Custom Command
Options -> Custom command

There are many substitution chars you can use when invoking the command, for example:
%f - full path of current file
%l - line number of current file
%d - full dir path of current file

Full list can be found in SI's help doc: Command Reference -> Custom Commands -> Command Line Substitutions

13. Macros
Source Insight provides a C-like macro language, which is useful for scripting commands, inserting specially formatted text, and automating editing operations. Macros are saved in a text file with a .EM extension. Once a macro file is part of the project, the macro functions in the file become available as user-level commands in the Key Assignments or Menu Assignments dialog boxes.

For language reference, see "Macro Language Guide" section in SI help doc.

SI's web site also contains some sample macro files: http://www.sourceinsight.com/public/macros

14. Special Features

Conditional Parsing:
- This is similar to conditional compiling for C/C++, chose what statements to parse
- You can change the settings using: Project -> Project Settings -> Conditions

10Aug/091

Apache performance tips

If you run the command top on your box and the CPU is mostly idle and there is plenty of memory available, and yet Apache seemed sluggish. Here are a couple of things I would recommend to speed things up.

1. Increase MaxClients and ServerLimit

This is a well-known Apache performance optimization tip. Its effect is to increase the number of httpd processes available to service the HTTP requests.

However, when I tried to increase MaxClients over 256 in the prefork.c directives and I restarted Apache, I got a message such as:

WARNING: MaxClients of 1000 exceeds ServerLimit value of 256 servers, lowering MaxClients to 256. To increase, please see the ServerLimit directive.

There is no ServerLimit entry by default in httpd.conf, so I proceeded to add one just below the MaxClients entry. I restarted httpd, and I still got the message above. The 2 entries I had in httpd.conf in the IfModule prefork.c section were:
ServerLimit 1000
MaxClients 1000
(make sure that serverlimit comes before maxclients)

At this point I resorted to all kinds of Google searches in order to find out how to get past this issue, only to notice after a few minutes that the number of httpd processes HAD been increased to well over the default of 256!

Note: It turns out that the new MaxClient and ServerLimit values take effect only if you stop httpd then start it back again. Just doing a restart doesn't do the trick...

So, lesson learned? Always double-check your work and, most importantly, know when to ignore warnings 🙂

Now I have a procedure for tuning the number of httpd processes on a given box:

1. Start small, with the default MaxClients (150).
2. If Apache seems sluggish, start increasing both MaxClients and ServerLimit; restart httpd every time you do this.
3. Monitor the number of httpd processes; you can use something like:

ps -def | grep httpd | grep -v grep | wc -l

If the number of httpd processes becomes equal to the MaxClients limit you specified in httpd.conf, check your CPU and memory (via top or vmstat). If the system is not yet overloaded, go to step 2. If the system is overloaded, it's time to put another server in the server farm behind the load balancer.

That's it for now. There are many other Apache performance tuning tips that you can read from the official Apache documentation here.