This is a great resource:
http://www.highprogrammer.com/alan/windev/visualstudio.html
Saturday, March 27, 2010
Cygwin/X gvim font problem
Gvim under cygwin/X was looking weird with tiny font.
I added following line in .gvimrc file and it solved the problem:
set guifont=Lucida\ Sans\ Typewriter\ Semi-Condensed\ 12
Sometimes even that gives ugly text, then try this (which is not that good, but better than others):
set guifont=LucidaTypewriter\ 13
This one looks much better:
set guifont=Bitstream\ Vera\ Sans\ Mono\ 13
I added following line in .gvimrc file and it solved the problem:
set guifont=Lucida\ Sans\ Typewriter\ Semi-Condensed\ 12
Sometimes even that gives ugly text, then try this (which is not that good, but better than others):
set guifont=LucidaTypewriter\ 13
This one looks much better:
set guifont=Bitstream\ Vera\ Sans\ Mono\ 13
Terminals for Cygwin
Following terminals don't need X server:
1. Cmd - the default where bash, or zsh shell runs in the Windows Command Window. The biggest problem with this is you can't stretch it horizontally without going into options. CTRL+Z does not work.
2. mintty - this is so far best for me. good font size, cut-n-paste, color controls, stretchable in all directions. It is based on putty. CTRL+Z works!
3. puttycyg - I haven't tried.
Terminals which need X server:
1. xterm - no scrollbar, no cut-n-paste, font too small.
2. rxvt - no cut-n-paste, font too small.
3. urxvt - no cut-n-paste, font too big.
1. Cmd - the default where bash, or zsh shell runs in the Windows Command Window. The biggest problem with this is you can't stretch it horizontally without going into options. CTRL+Z does not work.
2. mintty - this is so far best for me. good font size, cut-n-paste, color controls, stretchable in all directions. It is based on putty. CTRL+Z works!
3. puttycyg - I haven't tried.
Terminals which need X server:
1. xterm - no scrollbar, no cut-n-paste, font too small.
2. rxvt - no cut-n-paste, font too small.
3. urxvt - no cut-n-paste, font too big.
Zsh: _main_complete: function definition file not found
If you get an error similar to this one:
zsh:5: _main_complete: function definition file not found
then check for the value of FPATH or fpath and make sure the paths in those variables are valid.
zsh:5: _main_complete: function definition file not found
then check for the value of FPATH or fpath and make sure the paths in those variables are valid.
Cygwin: Unable to remap
If you try to launch cygwin processes (for example, zsh) and you get this error:
24295 [main] zsh 3104 C:\cygwin\bin\zsh.exe: *** fatal error - unable to remap C:\cygwin\lib\zsh\4.3.2\zsh\zle.dll to same address as parent(0xAB0000) != 0xC10000 12 [main] zsh 2020 fork: child 3104 - died waiting for dll loading, errno 11
Then follow the following steps:
1. Make sure rebase package is installed (use cygwin setup utitlity)
2. Exit all cygwin processes. Verify in Task Manager that there are no cygwin processes running.
3. Run 'cmd' from the run menu (Windows Key + R). Go to the cygwin bin directory and run ".\ash.exe".
4. Run "./rebaseall". This will take some time.
24295 [main] zsh 3104 C:\cygwin\bin\zsh.exe: *** fatal error - unable to remap C:\cygwin\lib\zsh\4.3.2\zsh\zle.dll to same address as parent(0xAB0000) != 0xC10000 12 [main] zsh 2020 fork: child 3104 - died waiting for dll loading, errno 11
Then follow the following steps:
1. Make sure rebase package is installed (use cygwin setup utitlity)
2. Exit all cygwin processes. Verify in Task Manager that there are no cygwin processes running.
3. Run 'cmd' from the run menu (Windows Key + R). Go to the cygwin bin directory and run ".\ash.exe".
4. Run "./rebaseall". This will take some time.
Friday, March 19, 2010
Change default settings of a Microsoft Word document
Microsoft Word 2007
To change any default settings of a new document, change the default template located here:
%APPDATA%\Microsoft\Templates\Normal.dotm
Open in Microsoft Word and save it back. If it gives error, then save it Normal1.dotm and use Windows Explorer to rename it back to Normal.dotm.
To change any default settings of a new document, change the default template located here:
%APPDATA%\Microsoft\Templates\Normal.dotm
Open in Microsoft Word and save it back. If it gives error, then save it Normal1.dotm and use Windows Explorer to rename it back to Normal.dotm.
Wednesday, March 17, 2010
More date and day functions
#include "stdio.h"
#include "stdlib.h>"
typedef enum DayOfWeek_ {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY} DayOfWeek;
// Returns 1 for a leap year, otherwise 0
int isLeap(int year)
{
int leap = 0;
if(year % 4 == 0) {
leap = 1;
if(year % 100 == 0) {
leap = 0;
if(year % 400 == 0) {
leap = 1;
}
}
}
return leap;
}
int dateToInt(int year, int month, int dayOfMonth)
{
static int cumDaysInMonth[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
int num = (year - 1) * 365 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400;
num += cumDaysInMonth[month-1] + dayOfMonth;
if(isLeap(year) && month >= 3)
num++;
return num;
}
int diffDate(int y1, int m1, int d1, int y2, int m2, int d2)
{
int num1 = dateToInt(y1, m1, d1);
int num2 = dateToInt(y2, m2, d2);
int diff = abs(num2 - num1);
printf("Diff days (%d, %d, %d) - (%d, %d, %d) : %d\n", y1, m1, d1, y2, m2, d2, diff);
return diff;
}
char *getDayOfWeekName(int dayOfWeek)
{
switch(dayOfWeek) {
case 0: return "SUNDAY";
case 1: return "MONDAY";
case 2: return "TUEDAY";
case 3: return "WEDNESDAY";
case 4: return "THURSDAY";
case 5: return "FRIDAY";
case 6: return "SATURDAY";
}
// Error condition
return "ERROR";
}
int getDayOfWeek(int year, int month, int dayOfMonth)
{
int num = dateToInt(year, month, dayOfMonth);
int dow = num % 7;
printf("DayOfWeek (%d, %d, %d) : %s\n", year, month, dayOfMonth, getDayOfWeekName(dow));
return dow;
}
void printMonth(int year, int month)
{
static int daysInMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
static char dayChars[7] = {'N', 'M', 'T', 'W', 'H', 'F', 'S'};
int firstDow = getDayOfWeek(year, month, 1);
int i;
int dm = daysInMonth[month-1];
if(isLeap(year) && month == 2)
dm = 29;
for(i = 0; i < dm; i++)
printf("%3d", i+1);
printf("\n");
for(i = 0; i < dm; i++)
printf("%3c", dayChars[(firstDow + i) % 7]);
printf("\n");
}
int main()
{
printMonth(2010, 3);
printMonth(2000, 5);
printMonth(2203, 5);
getDayOfWeek(2010, 4, 20);
getDayOfWeek(2000, 8, 19);
getDayOfWeek(2203, 10, 5);
diffDate(2203, 11, 13, 1923, 5, 6);
return 0;
}
Tuesday, March 16, 2010
Converting a date to dayOfWeek
Here is the full code in C
Enjoy
#include "stdio.h"
typedef enum DayOfWeek_ {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY} DayOfWeek;
// month is 1 to 12
int getDayOfWeek(int year, int month, int dayOfMonth)
{
int m[12] = {4, 0, 0, 3, 5, 1, 3, 6,2, 4, 0, 2};
int dayOfWeek = ((year-1) * 5 / 4 - 5) + m[month-1] + dayOfMonth;
int leap = 0;
if(year % 4 == 0) {
leap = 1;
if(year % 100 == 0) {
leap = 0;
if(year % 400 == 0) {
leap = 1;
}
}
}
if(leap && month >= 3)
dayOfWeek++;
return (dayOfWeek % 7);
}
char *getDayOfWeekName(int dayOfWeek)
{
switch(dayOfWeek) {
case 0: return "SUNDAY";
case 1: return "MONDAY";
case 2: return "TUEDAY";
case 3: return "WEDNESDAY";
case 4: return "THURSDAY";
case 5: return "FRIDAY";
case 6: return "SATURDAY";
}
//
return "ERROR";
}
int main()
{
printf("dayOfWeek(2000, 3, 17)=%s\n", getDayOfWeekName(getDayOfWeek(2000, 3, 17)));
printf("dayOfWeek(2000, 1, 15)=%s\n", getDayOfWeekName(getDayOfWeek(2000, 1, 15)));
printf("dayOfWeek(2010, 3, 17)=%s\n", getDayOfWeekName(getDayOfWeek(2010, 3, 17)));
return 0;
}
Enjoy
dosbox and qbasic on ubuntu
sudo apt-get install dosbox wget http://download.microsoft.com/download/win95upg/tool_s/1.0/w95/en-us/olddos.exe dosbox mount c /home/username/QBasic/
C:
QBASIC
1) Go into DosBox, type:
2) Exit DosBox, and open the dosbox.conf file that is now in the dos folder you just created.
3) Go to the very end and add:
C:
QBASIC
1) Go into DosBox, type:
Z:\>config -writeconf dosbox.confand hit enter.
2) Exit DosBox, and open the dosbox.conf file that is now in the dos folder you just created.
3) Go to the very end and add:
mount c ~/dos
References:
- http://ubuntuforums.org/showthread.php?t=608535
- http://lovehateubuntu.blogspot.com/2008/04/dosbox-on-ubuntu.html
Thursday, March 4, 2010
Gmail Trick: multiple email addresses for the same account
Did you guys know that your one gmail account has infinite number of equivalent email ids? For example all of the following email addresses represent the same email account:
hundred.........THREADS+second100@gmail.com
hundredthreads@gmail.com
Here are the rules:
1. Dots are ignored.
2. It is case-insensitive.
3. Anything after a + sign is ignored.
Gmail rocks!
hundred.........THREADS+second100@gmail.com
hundredthreads@gmail.com
Here are the rules:
1. Dots are ignored.
2. It is case-insensitive.
3. Anything after a + sign is ignored.
Gmail rocks!
Monday, March 1, 2010
zsh completion system broken for subversion/svn
I get this error:
% svn add
_arguments:comparguments:303: invalid argument: ARG
Here is a fix for this:
https://bugs.launchpad.net/ubuntu/+source/zsh/+bug/279545
The solution from the above link is:
The problem is in the subversion function file which I found in /usr/share/zsh/4.3.4/functions on my system. The minimal fix is to replace every occurrence of "/ arg/:arg:" with "/ (arg|ARG)/:arg:" in /usr/share/zsh/4.3.4/functions/Completion/Unix/_subversion; see attached patch.
Copy this file to ~/.zsh/functions and modify the file.
Also in .zshrc add the following line:
fpath=($HOME/.zsh/functions /usr/share/zsh/site-functions /usr/share/zsh/4.3.4/functions)
% svn add
_arguments:comparguments:303: invalid argument: ARG
Here is a fix for this:
https://bugs.launchpad.net/ubuntu/+source/zsh/+bug/279545
The solution from the above link is:
The problem is in the subversion function file which I found in /usr/share/zsh/4.3.4/functions on my system. The minimal fix is to replace every occurrence of "/ arg/:arg:" with "/ (arg|ARG)/:arg:" in /usr/share/zsh/4.3.4/functions/Completion/Unix/_subversion; see attached patch.
Copy this file to ~/.zsh/functions and modify the file.
Also in .zshrc add the following line:
fpath=($HOME/.zsh/functions /usr/share/zsh/site-functions /usr/share/zsh/4.3.4/functions)
Cracking Programming Interviews
Whether you are applying for internship or part time job or full time job, you need to do some practice before you go for phone interview or on-site interviews.
Here are some of the resources for cracking programming interviews:
Basic
Adavanced
- One Object Language - C++, Java or C# and its design patterns
- Computer Networks (4th Edition) (Hardcover) ~ Andrew S. Tanenbaum
- Computer Architecture:
More Advanced
- Mathematical Prolems - Project Euler - http://projecteuler.net/
References:
I hope this helps you!
Here are some of the resources for cracking programming interviews:
Basic
- Programming Interviews Exposed: Secrets to Landing Your Next Job (Paperback) ~ John Mongan and Noah Suojanen
- Data Strucutres - Linked List (single, double, circular, doubly linked circular etc), Arrays, Trees, Graphs, graph traversals
- Abstract Data Structures - Stack, Heap, BST, Hash Table, Queues
- Algos - Sorting algos(Quicksort, Mergesort, Heapsort, Binary Sort), BFS, DFS
- Programming Pearls ~ Jon Bentley
- Puzzles for Programmers and Pros by Dennis Elliott Shasha
Adavanced
- One Object Language - C++, Java or C# and its design patterns
- For Java: Effective Java 2nd Edition
- Computer Networks (4th Edition) (Hardcover) ~ Andrew S. Tanenbaum
- Distance vector .vs. dijkstra’s algorithm.
- Count to infinity problem.
- TCP internals: congestion detection, control, sliding window, cumulative acks, etc.
- What is IP tunneling?
- When you type "www.google.com" on your browser : what all happens under the hood ? What are the various hops and translations that happen?
- Scheduling algorithms
- Paging algorithms/concepts
- Multi-threaded programming: deadlock detection .vs. avoidance.
- how to implement semaphore using mutex ?
- reader/writer problem
- producer/consumer problem
- Computer Architecture:
- What is pipelining? RISC architecture.
- What are some of the pipelining hazards : data hazard etc. how to get around them?
- Pipeline scheduling algorithms: scoreboarding, tomasulo’s algorithm etc. just a high level understanding and some internals.
- Shared memory architectures : how to maintain a distributed & shared memory cache?
More Advanced
- Mathematical Prolems - Project Euler - http://projecteuler.net/
References:
- http://code.google.com/edu/
- Algorithms - http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=alg_index
- http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-046JFall-2005/VideoLectures/index.htm
I hope this helps you!
Subscribe to:
Posts (Atom)