| Usage | Effect |
|---|---|
| inside a function | remains even after the function call is long gone |
| modify a global variable | private to a certain file |
| modify a function | making those functions visible only to the file itself |
Software, web, and programming tips: C++, Java, C, Linux, Windows, Cygwin, Firefox, Vim, WWW, RSS
Wednesday, May 9, 2007
C - Static Keyword
KDE - Enable mouse gestures
Run kcontrol
Regional & Accessibility → Input Actions
Gestures tab
Unclick Disable mouse gestues global
Change Mouse button to secondary button (right mouse button)
Open up Konqueror
Hold on to right-mouse button, move left, release
It should have navigated back a page
Regional & Accessibility → Input Actions
Gestures tab
Unclick Disable mouse gestues global
Change Mouse button to secondary button (right mouse button)
Open up Konqueror
Hold on to right-mouse button, move left, release
It should have navigated back a page
Cygwin/X - Install 100 dpi fonts
If your fonts look too small, try installing the 100dpi fonts in Cygwin's setup. Under X11, select
xorg-x11-f100: Cygwin/X 100 dpi fontsIn your C:\cygwin\usr\X11R6\bin\startxwin.bat, near the bottom of the file, append "-dpi 100" to this line:
%RUN% XWin -multiwindow -clipboard -silent-dup-error
UNIX/Linux - xhost access
To make your X server available to everyone:
xhost +You can add this to your .bashrc
Cygwin/X - Startup with Windows
Place a shortcut to
To not have xterm pop up everytime you start up, open startxwin.bat and prepend REM in to this line:
C:\cygwin\usr\X11R6\bin\startxwin.batin your startup folder (e.g. Start->All Programs->Startup)
To not have xterm pop up everytime you start up, open startxwin.bat and prepend REM in to this line:
%RUN% xterm -e /usr/bin/bash -l
Wednesday, May 2, 2007
UNIX/Linux - Recursive, forceful remove
For you n00bs, to recursively delete a directory with prompts for each file:
rm -rf dir_name
VIM - Using cscope
Install cscope.
At your project directory, to recursively build the database
Place cscope_maps.vim into ~/.vim/plugin.
CTRL+] to search for the word under the cursor.
See the cscope vim tutorial for more details.
At your project directory, to recursively build the database
cscope -RbPlace cscope_maps.vim into ~/.vim/plugin.
CTRL+] to search for the word under the cursor.
See the cscope vim tutorial for more details.
VIM - Recursively set the path of the project
Put this in your
.vimrc to" Recursively set the path of the project
set path=$PWD/**
Monday, April 30, 2007
UNIX/Linux - Build essentials
In order to build stuff in Ubuntu, I needed to install the build-essentials:
Who knew?
sudo apt-get install build-essentialWho knew?
Wednesday, April 18, 2007
VIM - Shifting and code formatting
You can shift (indent) code right or left by typing >> or <<, respectively, with your cursor on the line you want to shift.
You can use VIM automatic formating by typing == on the line you want to format.
You can also set the amount of spaces to shift.
You can also shift and format in visual mode (To get into visual mode: SHIFT+V, then j and k to select rows) by selecting the lines you want, then typing >, <, or =.
You can use VIM automatic formating by typing == on the line you want to format.
You can also set the amount of spaces to shift.
You can also shift and format in visual mode (To get into visual mode: SHIFT+V, then j and k to select rows) by selecting the lines you want, then typing >, <, or =.
VIM - Inserting spaces instead of tabs
Insert spaces instead of tabs
set expandtaborset et
Set the width of shifts to 4 for autoindenting and shifting: >> and <<
set shiftwidth=4orset sw=4
Set where to stop tabs to 4
set tabstop=4orset ts=4
This is what I have in my
~/.vimrc:Set expanded tabs with shiftwidth=4 and tabstop=4 for Java, Perl, C, and C++ files
autocmd BufNewFile,BufRead *.java,*.pl,*.c,*.h,*.cc,*.cpp,*.hpp set sw=4 ts=4 et
Tuesday, April 17, 2007
UNIX/Linux - Find command
To look for files in the current directory tree then run a command on them:
Put this in a shell script to recursively grep .cpp and .hpp files for the first argument:
find . -name <file-pattern> -exec <command> {} \;Examples
To grep for "hello" inside all .txt files:find . -name *.txt -exec grep -Hn hello {} \;Put this in a shell script to recursively grep .cpp and .hpp files for the first argument:
#!/bin/bash
find . -name *.[ch]pp -exec grep -Hn "$1" {} \;
Wednesday, April 11, 2007
RSS - Web comics
Subscribing to web comics is a great way to use RSS.
Here are some comics I subscribe to:
Here are some comics I subscribe to:
- Bug Bash
- Unofficial Dilbert Feed by TapestryComics.com
- Working Daze comic stips powered by phpGrabComics
Wednesday, March 21, 2007
Cygwin tips
All tips assume you installed Cygwin at C:\cygwin
Then add this to
Use rxvt instead of dos command prompt
Change your cygwin.bat to@echo off
C:
chdir C:\cygwin\bin
rxvt -e bash --login -i
Customize rxvt
Create a file in your home directory named.Xdefaults rxvt*foreground:whiteOther rxvt options can be found here.
rxvt*background:black
rxvt*font: Lucida Console-14
rxvt*scrollBar_right: true
Fix Home, End, Delete, and Insert keys
Put this into~/.inputrc# Home Key
"\e[7~":beginning-of-line
# End Key
"\e[8~":end-of-line
# Delete Key
"\e[3~":delete-char
# Insert Key
"\e[2~":paste-from-clipboard
Then add this to
~/.bashrcexport INPUTRC=$HOME/.inputrc
Friday, March 16, 2007
Web - Firefox Search Engines
You can add your own search engines to the Firefox search bar. Here are some I found:
- Some popular ones: https://addons.mozilla.org/search-engines.php
- Search for your favorite ones here: http://mycroft.mozdev.org
Tips
- With the cursor in the search bar, CTRL+UP or CTRL+DOWN arrow changes the current search engine.
- Some tips on how to customize it even more:
http://labnol.blogspot.com/2006/03/firefox-search-bar-hacks.html
Thursday, March 8, 2007
VIM - Doxygen Syntax Highlighting
To have vim highlight Doxygen comments, add this to your
For more help, try
vimrc:let g:load_doxygen_syntax=1For more help, try
:help doxygen
Labels:
Comments,
Doxygen,
Highlighting,
programming,
software,
Syntax,
vim
Thursday, March 1, 2007
UNIX/Linux - Command Line Tips
| Command | Description |
|---|---|
du -hs dir | Displays disk usage of dir. -h gives human readable format (e.g. 12M) and -s suppresses every recursive directory's output |
| echo $? | Displays the return code of the previously exited program |
pgrep -lf process_name | Displays pid of all running processes named process_name. -l lists the process name and -f matches in the full command line |
Web - RSS
You've noticed websites with orange icons that say "RSS" on them, but you don't know what that means or what to do with those icons.
Some browsers, such as Firefox, display buttons when you browse to a site with RSS feeds.
What is RSS?
Rich Site Summary, or Really Simple Syndication.For real, what is RSS?
A website containing an RSS feed has the capability to send you a summary of updates whenever it has updates. In other words, you're able to subscribe to that website's updates.Why should you care?
When you subscribe to an RSS feed, it sends notifications when updates are available on the site. Some feeds even give a brief description of the update. This way, you don't have to open the whole website to know that it's been updated; thus, saving you time.What can you subscribe to?
Any site with orange icons labelled RSS or XML. This includes sites such as blogs, news sites, forums, and download lists.Some browsers, such as Firefox, display buttons when you browse to a site with RSS feeds.
Ok, cool. So how do you use RSS?
Let's walk through an example:- At the bottom of CNN, you'll see a link for RSS.
- Click on that RSS link. It should bring you to CNN's page of RSS feeds, which contains various RSS links to potential topics to subscribe to, such as CNN's Top Stories.
- Click on any one of those RSS links. A page or dialog box should prompt you for which RSS aggregator (such as GreatNews) to use to subscribe to that feed.
- Now you open your RSS aggregator, update your feed, and look at the page updates. Simple as that!
Subscribe to my blogs using RSS
- heykevinle (software/programming)
- writingwithkevinle (writing)
Subscribe to:
Posts (Atom)