Wednesday, January 13, 2010
Saturday, December 19, 2009
PHP string concatation
$str1 = 'This '; $str2 = 'is a '; $str3 = 'test string'; $full = $str1.$str2.$str3; echo $full; ?>
PHP string compare
$str1 = "Test"; $str2 = "Test"; ?>
Tuesday, December 15, 2009
Shortcut command to Restart / Shutdown windows
Vista, 7 : Click start -> Write : cmd
Then :
For a shortcut to RESTART Windows :
SHUTDOWN -r -t 01
For a shortcut to SHUT DOWN Windows :
SHUTDOWN -s -t 01
Monday, December 14, 2009
enable content search in windows
Content-searching can allow you to search files by what is contained within the file rather than the file-name. By default, Windows only search file names for locations that are unindexed, which can often bring frustration upon users who have Search Indexing disabled. By enabling content-searching, those who often forget filenames but remember the contents within a file can make their searching much more efficient.
Re-enabling content-searching is very simple. First, you want to access your folder options from the Tools menu. If you don’t have the top navigation bar enabled by default, just press Alt.
Click on the Search tab above to access your Search Functions. Below is a picture of the default search settings. Simply check the second button, “Always search file names and contents” to re-enable content searching. If you’re working with system files, you might also want to check the Include System Directories box below.
source : http://www.vistarewired.com/2007/03/17/how-to-search-files-by-content-data
Split screen, Notepad++
To split the screen in Notepad++ you have to right-click on the tab
with the current document and select "Clone to another view". The
screenshot at the following page explains how to switch between
horizontally and vertically split screens.
http://notepad-plus.sourceforge.net/commun/screenshots/scrsh_rotate.gif
This page explains how Notepad++ can be integrated with Stata similar
to the built-in Do-File Editor:
http://huebler.info/2008/20080427-stata.html
thanks to Friedrich
Tricks to make old Addons work on Firefox 3.5 or higher
The trick is to add some configurations in Firefox settings. All the changes you make from here on are done at your own risk. Do revert the settings if something goes wrong.
- Type
about:config
address bar of Firefox browser and hit enter. It will give you a warning. Just click the button “I’ll be careful, I promise!” and proceed… - It will show a huge list of values. Now, right click any where in the free white-space on the screen and click on New –> Boolean, then name the Boolean as checkCompatibility – make it false in the next step.
- again right click and click on New -> Boolean and name as checkUpdateSecurity and choose false.
- After doing this changes to get the changes applied, Restart the Firefox browser. Now install the addon that was not supported or compatible by Firefox 3.5 and install it.
- Restart the Firefox browser once again. Now, the not compatible addon will work with Firefox 3.4
Hope you liked this trick.
Thanks to Blogote
Thursday, November 19, 2009
Funny !!!
Killed by fatal signal
==4660== at 0x3802088D: vgPlain_arena_malloc (m_mallocfree.c:190)
==4660== by 0x38035516: vgPlain_cli_malloc (replacemalloc_core.c:101)
==4660== by 0x380022F5: vgMemCheck_malloc (mc_malloc_wrappers.c:182)
==4660== by 0x38035BA7: do_client_request (scheduler.c:1158)
==4660== by 0x380372B1: vgPlain_scheduler (scheduler.c:869)
==4660== by 0x38051B59: run_a_thread_NORETURN (syswrap-linux.c:87)
sched status:
running_tid=1
Thread 1: status = VgTs_Runnable
==4660== at 0x4A05809: malloc (vg_replace_malloc.c:149)
==4660== by 0x4030B0: _readTime (commands.c:676)
==4660== by 0x402124: _processReceivedData (commands.c:361)
==4660== by 0x401EEC: _performReceive (commands.c:322)
==4660== by 0x401809: _performCommand (commands.c:225)
==4660== by 0x401340: commandCenter (commands.c:163)
==4660== by 0x400D39: main (Hj1.c:63)
Wednesday, November 18, 2009
strlen @ C
DESCRIPTION
The strlen() function calculates the length of the string
s, not including the terminating '\0' character.
Sunday, November 15, 2009
Jump to line number n
Saturday, November 14, 2009
Controlling Ctrl^C for quiting program, C programing
#include
#include
#include
void exit_program(int sig) {
printf("Wake up call ... !!! - Catched signal: %d ... !!\n", sig);
/* DO YOUR STUFFS BEFOR QUITING, if you dont want to wait for the 2nd
Ctrl^C from user you can just have the next commented line :*/
//exit(0);
(void) signal(SIGINT, SIG_DFL);//You need 2nd Ctrl^C to quit
}
int main(void) {
(void) signal(SIGINT, exit_program);
/* waits to read your signal(first Ctrl^C) while running rest of your code, on
Ctrl^C pressed will jump to exit_program method*/
while(1)
printf("I wanna catch Ctrl + C\n"), sleep(1);
return 0;
}
Giving your screen session a name
Wednesday, November 11, 2009
Vim/Vi command sheet
Cursor movement
- h - move left
- j - move down
- k - move up
- l - move right
- w - jump by start of words (punctuation considered words)
- W - jump by words (spaces separate words)
- e - jump to end of words (punctuation considered words)
- E - jump to end of words (no punctuation)
- b - jump backward by words (punctuation considered words)
- B - jump backward by words (no punctuation)
- 0 - (zero) start of line
- ^ - first non-blank character of line
- $ - end of line
- G - Go To command (prefix with number - 5G goes to line 5)
Note: Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines.
Insert Mode - Inserting/Appending text
- i - start insert mode at cursor
- I - insert at the beginning of the line
- a - append after the cursor
- A - append at the end of the line
- o - open (append) blank line below current line (no need to press return)
- O - open blank line above current line
- ea - append at end of word
- Esc - exit insert mode
Editing
- r - replace a single character (does not use insert mode)
- J - join line below to the current one
- cc - change (replace) an entire line
- cw - change (replace) to the end of word
- c$ - change (replace) to the end of line
- s - delete character at cursor and subsitute text
- S - delete line at cursor and substitute text (same as cc)
- xp - transpose two letters (delete and paste, technically)
- u - undo
- . - repeat last command
Marking text (visual mode)
- v - start visual mode, mark lines, then do command (such as y-yank)
- V - start Linewise visual mode
- o - move to other end of marked area
- Ctrl+v - start visual block mode
- O - move to Other corner of block
- aw - mark a word
- ab - a () block (with braces)
- aB - a {} block (with brackets)
- ib - inner () block
- iB - inner {} block
- Esc - exit visual mode
Visual commands
- > - shift right
- < - shift left
- y - yank (copy) marked text
- d - delete marked text
- ~ - switch case
Cut and Paste
- yy - yank (copy) a line
- 2yy - yank 2 lines
- yw - yank word
- y$ - yank to end of line
- p - put (paste) the clipboard after cursor
- P - put (paste) before cursor
- dd - delete (cut) a line
- dw - delete (cut) the current word
- x - delete (cut) current character
Exiting
- :w - write (save) the file, but don't exit
- :wq - write (save) and quit
- :q - quit (fails if anything has changed)
- :q! - quit and throw away changes
Search/Replace
- /pattern - search for pattern
- ?pattern - search backward for pattern
- n - repeat search in same direction
- N - repeat search in opposite direction
- :%s/old/new/g - replace all old with new throughout file
- :%s/old/new/gc - replace all old with new throughout file with confirmations
Working with multiple files
- :e filename - Edit a file in a new buffer
- :bnext (or :bn) - go to next buffer
- :bprev (of :bp) - go to previous buffer
- :bd - delete a buffer (close a file)
- :sp filename - Open a file in a new buffer and split window
- ctrl+ws - Split windows
- ctrl+ww - switch between windows
- ctrl+wq - Quit a window
- ctrl+wv - Split windows vertically
Tuesday, November 10, 2009
Write an array to file in C
FILE * hFile;
//************************
char *_fileName;
_fileName = getenv("USER");
char buffer[200];
struct timeval tv;
time_t curtime;
gettimeofday(&tv, NULL);
curtime=tv.tv_sec;
strftime(buffer,30,"%Y%m%d_%H%M",localtime(&curtime));
//"%m-%d-%Y %T"
strcat(_fileName,"_");
strcat(_fileName,buffer);
strcat(_fileName,".bak");
//*******************************
hFile = fopen( _fileName, "w");
if (hFile == NULL){
// Error, file not found
printf("*** Failed to open the file ***\n");
return FAILED;
}//end of if
else{
// Process & close file
int nWritten = fwrite(message, sizeof(SmsDBase), 200, hFile);
printf("*** Taking backup ***\n");
fclose(hFile);
}//end of else
return SUCCESS;
}//end of backItUp()
int readItUp(){
FILE * hFile;
hFile = fopen( ___fileName, "r");
if (hFile == NULL){
// Error, file not found
printf("*** Failed to open the file ***\n");
return FAILED;
}//end of if
else{
// Process & close file
int nRead = fread(message, sizeof(SmsDBase), 200, hFile);
fclose(hFile);
}//end of else
return SUCCESS;
}//end of _readItUp()
Sunday, November 08, 2009
copying folder in Linux / Unix terminal
cp -r /original/dir /copied/dir
Saving and quiting at Vim
After finishing, you are supposed to save what you have written. So you press Esc button and then write :w. Then you can simply write :q to quit.
Pay attention that you can write commands(:w, :q, ...) in the command line and you can go to command line by pressing Esc button in Vim.
Good luck, it is a powerful editor, but as me, you got a long way a head to learn how to work with it.
Saturday, November 07, 2009
Showing Line Number while editing a file in Vi or Vim
:set number
to have line numbers beside your editor. If you are tired of line numbers, enter the following to turn them off:
:set nonumber
Wednesday, November 04, 2009
Crazy about old games ? Try DosBox
Monday, November 02, 2009
instanceof example in Java
public static void main(String[] a) {
String s = "Hello";
if (s instanceof java.lang.String) {
System.out.println("is a String");
}
}
}