Thursday, June 30, 2011

Office LAN design using Common Sense and expenses

In the past I always wonder how lan is designed.

but recently got chance to put lan setup in office.

We moved to quite big place with around 25 people sitting capacity.

I first thought to put 24 connectors

2 * 8 port switch- Rs.1900 (950*2)
1 24 port switch - Rs. 3800
--------------
wall jacks - 250* 24

labour - 300 per jack

we used Cat 6 cable instead of Cat-5 cable (still need to figure out difference)
Cat 6 100mtr cable - Rs. 2800
Cat 5 100mtr cable - Rs. 1900

Our electrician was not available so We called some electrician to do wiring work but he asked 3500. We tried to negotiate with him to take 2700 for work but he didnt want to negotiate. so we fell back to our trusted guy. He did whole work in just Rs. 1700

so It was going out of budget as we are only 8 people team so I reduced total jacks to 10 and cost got reduced accordingly.

Total cost was Rs. 11000 (including labour and material cost to setup lan with 10 pcs)

here comes interesting part lan designing, please refer to lan diagram attached.

Office has 2 floors, Basement and ground floor. Challenge was to keep everyone on single LAN also provide additional lan for ground floor.

Wednesday, June 29, 2011

Installing MySQLdb with Python 2.6 on Mac OSX10.5

It seemed easy but took quite time for me to install MySQLdb library on Python on Mac Osx 10.5

here are 2 links which saved day for me..

http://stackoverflow.com/questions/3061277/python-mysql-wrong-architecture-error

I have a fresh MacBook Air, and I managed to get MySQLdb working by doing the following: (Snow Leopard 10.6.6, preinstalled Python)

uname -a
Darwin Braindamage.local 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386

Download the MySQL 32-bit dmg file from mysql pages, Install it.

Add the following lines to your ~/.profile (or ~/.bash_profile):

PATH="/usr/local/mysql/bin:${PATH}"
export PATH
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
export VERSIONER_PYTHON_PREFER_64_BIT=no
export VERSIONER_PYTHON_PREFER_32_BIT=yes


http://stackoverflow.com/questions/1448429/how-to-install-mysqldb-python-data-access-library-to-mysql-on-mac-os-x

here are numerous step-by-steps on how to build and install the MySQLdb libraries. They often have subtle differences. This seemed the most popular to me, and provided the working solution. I've reproduced it with a couple of edits below

Step 0: Before I start, I assumed that you have MySQL(32 bit version) and Python installed on the mac.

Step 1: Download the latest MySQL for Python adapter from SourceForge.

Step 2: Extract your downloaded package:

tar xzvf MySQL-python-1.2.2.tar.gz

Step 3: Inside the folder, clean the package:

sudo python setup.py clean

COUPLE OF EXTRA STEPS, (from this comment)

Step 3b: Remove everything under your MySQL-python-1.2.2/build/* directory -- don't trust the "python setup.py clean" to do it for you

Step 3c: Remove the egg under Users/$USER/.python-eggs

Step 4: Originally required editing _mysql.c, but is now NO LONGER NECESSARY. MySQLdb community seem to have fixed this bug now.

Step 5: Create a symbolic link under lib to point to a sub-directory called mysql. This is where it looks for during compilation.

sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql

Step 6: Edit the setup_posix.py and change the following

mysql_config.path = "mysql_config"

to

mysql_config.path = "/usr/local/mysql/bin/mysql_config"

Step 7: In the same directory, rebuild your package (ignore the warnings that comes with it)

sudo python setup.py build

Step 8: Install the package and you are done.

sudo python setup.py install

Step 9: Test if it's working. It works if you can import MySQLdb.

python

>>> import MySQLdb

One final hiccup though is that if you start Python from the build directory you will get this error:

/Library/Python/2.5/site-packages/MySQL_python-1.2.3c1-py2.5-macosx-10.5-i386.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Python/2.5/site-packages/MySQL_python-1.2.3c1-py2.5-macosx-10.5-i386.egg/_mysql.pyc, but XXXX/MySQL-python-1.2.3c1 is being added to sys.path

This is pretty easy to Google, but to save you the trouble you will end up here (or maybe not... not a particularly future-proof URL) and figure out that you need to cd .. out of build directory and the error should disappear.

As I wrote at the top, I'd love to see this answer generalised, as there are numerous other specific experiences of this horrible problem out there. Edit away, or provide your own, better answer.

Friday, June 24, 2011

Ubuntu - set Server time to UTC

Create a symlink to file localtime:
# ln -sf /usr/share/zoneinfo/UTC /etc/localtime

OR some distro use /usr/share/zoneinfo/dirname/zonefile format (Red hat and friends)
# ln -sf /usr/share/zoneinfo/UTC /etc/localtime

OR if you want to set up it to IST (Asia/Calcutta):
# ln -sf /usr/share/zoneinfo/Asia/Calcutta localtime

You can use TZ environment variable to display date and time according to your timezone:
$ export TZ=America/Los_Angeles
$ date

Wednesday, June 08, 2011

mod_rewrite to another server

We have hosted our company blog at blogspot.

We wanted to have blog hosted on org website. as people should not leave our website.

First solution was to host blog with some blog engine like wordpress.

Second solution I thought it might be possible to use apache mod-rewrite to internally redirect http://screen-magic.com/blog to
our screen-magic.blogspot.com

I never did it. but I started by websearching. Apache mod rewrite it bit tricky. You never know whats happening.

after several unsuccessful attempts and pemutation and combinations finally got it work.

here is the solution



Options -Indexes FollowSymLinks MultiViews
AllowOverride all
Options +FollowSymLinks
RewriteEngine on
RewriteRule blog http://screen-magic.blogspot.com/ [P]
Order allow,deny
allow from all


Here is working demo
Click to see ScreenMagic Blogs

Friday, May 06, 2011

Salesforce : Non-selective query against large object type (more than 100,000 rows) - Solved

We are customizing SMS Magic package to enable feature for customer where he wants SMS's received
in inbox to be autolooked up in Contacts and should get attached to particular contact.

This is very easy in normal case.
You add lookup field on Incoming SMS object and lookup mobilenumber in Contacts using SOQL. and
assigns lookup field with matching Contacts's Id. I wrote the code and written test cases and everything was good
contactList = [select Id, OwnerId, Name from Contact where MobilePhone = :senderMobileNumber];

till I tried sending actual SMS to his org though SMS went thru to his inbox
but Contact lookup failed.

Now I was stuck. I enabled debug logs and tried to see whats happening and got this.

System.QueryException: Non-selective query against large object type (more than 100,000 rows) . Consider an index filter.

And I was clueless. I tried to search across salesforce forum but every one was stuck on it. I even told my colleague, this seems impossible lets refund client if we have charged him.
Someone suggested on discussion forum, that you need to add index using external_field but Contact is standard object so it was not possible.
then I tried adding another filter
contactList = [select Id, OwnerId, Name from Contact where MobilePhone != null and MobilePhone = :senderMobileNumber];

but thing didnt work.



but sometime later, I thought lets give a try with SOSL.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_sosl_examples.htm

I tried following :-

List<List<SObject >>searchList = [FIND :senderMobileNumber RETURNING Contact ];
contactList = ((List<Contact>)searchList[0]);
object.Contact__c = contactList[0].Id;
it worked beautifully without any issue.

Another solution for this as per Salesforce documentation is as follows:
http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_VLSQ.htm
I didnt try this solution. It should also work.

Thursday, March 10, 2011

Apple Gyan: How to tell if your Intel-based Mac has a 32-bit or 64-bit processor

# Choose About This Mac from the Apple () menu in the upper-left menu bar, then click More Info.
# Open the Hardware section.
# Locate the Processor Name.

4. Compare your Processor Name to information below to determine whether your Mac has a 32-bit or 64-bit processor.

Processor Name 32- or 64-bit
Intel Core Solo 32 bit
Intel Core Duo 32 bit
Intel Core 2 Duo 64 bit
Intel Quad-Core Xeon 64 bit
Dual-Core Intel Xeon 64 bit
Quad-Core Intel Xeon 64 bit


for much beautiful page :
http://support.apple.com/kb/ht3696

Thursday, February 24, 2011

MySQL setup

When you install mysql server, on your system, you need to some basic things so
taht you can seamlessly access it from any other machine.

1) By default, root user is created without password for Mysql server.

2) From Server , you can connect to MySQL Server using commandline mysql client.
using user root

$ mysql -u root -p

do not enter any password.

3) by default, MySQL Server is binded locally because of this you can not access it from other machines.
You need to comment out following in /etc/mysql/my.cnf

#bind-address = 127.0.0.1


4) Still with root, you can not access mysql server from remote machine, solution to this is to create a user with sufficient permissions.

mysql> CREATE USER 'magic'@'localhost' IDENTIFIED BY 'magic123'
-> ;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'magic'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE USER 'magic'@'%' IDENTIFIED BY 'magic123';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'magic'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)


I did this mysql setup for number of times but still everytime I go to following link http://dev.mysql.com/doc/refman/5.1/en/adding-users.html


Disclaimer:
This post is for my own reference.

HOWTO - Apache2 + Subversion + SSL

We wanted to install Subversion which can be accessed using HTTP protocol while searching on google, we got to nice article at

http://www.debuntu.org/2006/05/20/54-how-to-subversion-svn-with-apache2-and-dav

Here are details...


I needed install Apache2 + Subversion and i have searching for info, etc. and now i'm decide to create this tutorial, i hope you like!

Here we go:

INSTALL APACHE2

To install apache2 run that command:
Code:

sudo apt-get install apache2

(if you want also install php and mysql just follow this Link)

After you will install subversion:
Code:

sudo apt-get install subversion

(in that moment doens't exist the pre-buil binary of the last version (1.2.1), but when it's out you can simple upgrade )

To use svn with apache you need install libapache2-svn:
Code:

sudo apt-get install libapache2-svn

Now is better restart apache :
Code:

sudo /etc/init.d/apache2 restart

If you don't want SSL go to the last instructions (dav_svn.conf configurations, and users accounts).

Run:
Code:

a2enmod ssl

Add "Listen 443" to /etc/apache2/ports.conf:
Code:

sudo gedit /etc/apache2/ports.conf

Run:
Code:

apache2-ssl-certificate

Create a new SSL configuration file:
Code:

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/myown-ssl

Edit myown-ssl file:
Code:

sudo gedit /etc/apache2/sites-available/myown-ssl

Change:
Code:

NameVirtualHost *

to
Code:

NameVirtualHost *:443

and
Code:



to
Code:



Add before
:
Code:

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLProtocol all
SSLCipherSuite HIGH:MEDIUM

Run:
Code:

a2ensite myown-ssl

Restart Apache:
Code:

sudo /etc/init.d/apache2 restart

Last instruction:

Edit dav_svn configuration file and follow the instructions:
Code:

sudo gedit /etc/apache2/mods-available/dav_svn.conf

Restart apache:
Code:

sudo /etc/init.d/apache2 restart

Create SVN folder:
Code:

sudo svnadmin create /srv/svn
sudo chown -R www-data:www-data /srv/svn
sudo chmod -R g+ws /srv/svn

Create the users account file:
Code:

sudo htpasswd2 -c /etc/apache2/dav_svn.passwd svnuser

(after asks for a password)

Test SVN:
Code:

svn import .bashrc https://localhost/svn/testfile -mlogentry

That is all!!!


For the SSL instructions i have follow this Tutorial.
About how using SVN see the official SVN book here or visit the official website (Link).

Any error, please report! (and not only in the istructions but also in the english...)

Tuesday, February 08, 2011

Product FAQ

• Is my product compelling to our target customer?
• Have we made this product as easy to use as humanly possible?
• Will this product succeed against the competition? Not today’s competition, but the competition that will be in the market when we ship?
• Do I know customers that will really buy this product? Not the product I wish we were going to build, but what we’re really going to build?
• Is my product truly differentiated? Can I explain the differentiation to a company executive in two minutes? To a smart customer in one minute? To an industry analyst in 30 seconds?
• Will the product actually work?
• Is the product a whole product? How will customers actually think about and buy the product? Is it consistent with how we plan to sell it?
• Are the product’s strengths consistent with what’s important to our customers? Are we positioning these strengths as aggressively as possible?
• Is the product worth money? How much money? Why? Can customers get it cheaper elsewhere?
• Do I understand what the rest of the product team thinks is good about the product? Is it consistent with my own view?


From SVPG guide

Tuesday, January 25, 2011

MySQL - Restart - AutoInc resets to zero

I noticed fact recently that MySQL Table autoincrement Id value resets to zero, if table is empty.

solution to this is, you can reset the counter to

mysql> ALTER TABLE tbl AUTO_INCREMENT = 1000;

Wednesday, January 19, 2011

Crontab/Cron analyzed - not working issues

It has now become routine job to write shell scripts to schedule jobs on server. (Ubuntu)

Although its routine, still sometime we got stuck with same issues. so I thought lets write a small article
to type out common errors I made.

1) Path -
By default, in cron environment, no Path is defined, so you can not even run simplest of shell file with simple
command like 'date'

you need to define
PATH=/home/sandip/bin:/bin:/sbin:/usr/bin:/usr/sbin/$PATH

your script testCronFile.sh can reside in /home/user/bin. it should have 755 perms.
chmod 755 testCronFile.sh


additionally to make sure that Script is executing.

you can do it using following 2 ways..
1) sudo tail -f /var/log/syslog
You would see something like following..

Jan 19 10:08:01 localhost CRON[11593]: (root) CMD (testCronFile.sh)


2) In testCronFile.sh, You can include line like

echo "Testing Shell file" >> /home/sandip/cron.log

so after execution of script, cron.log file would get created with "Testing Shell file" written in it.

for accessing files under root permission from cron, use sudo
$ sudo crontab -e


You can add comments, if you have something else regarding cron files.

Tuesday, January 04, 2011

MySQL export large data from command promt to CSV file

If you can cope with table-at-a-time, and your data is not binary, use the -B option to the mysql command. With this option it'll generate TSV (tab separated) files which can import into Excel, etc, quite easily:

% echo 'SELECT * FROM table' | mysql -B -uxxx -pyyy database
Alternatively, if you've got direct access to the server's file system, use SELECT INTO OUTFILE which can generate real CSV files:

SELECT * INTO OUTFILE 'table.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM table


Courtesy:
Stack Overflow

http://stackoverflow.com/questions/467452/dump-a-mysql-database-to-a-plaintext-csv-backup-from-the-command-line

Tuesday, September 28, 2010

Story of Elephant

A king had 17 elephants. Then the king died. He had three sons. According to his will, the first son was entitled to one-half of the number of elephants, the second to one-third, and the third to one-ninth. The size of the share couldn't be changed. As 17 is an odd number, and difficult to share among the three, they were unable to find a solution to the challenge. Fortunately for them, a wise man was passing through their country. He was an old friend of their father's as well. The young men described their predicament and asked for his help. The wise man asked them not to worry and set about solving the problem immediately.

He added his elephant to the 17 elephants; they were now 18. He separated 9 elephants or one-half of 18, and gave them to the first son. The second son was given six elephants or one-third of 18. Lastly, the third son was given two elephants, two being one ninth of 18. The total number of elephants given away was 17 (9+6+2). The eighteenth elephant left was that of the wise man who took his elephant back and left, with everybody happy and satisfied. The last elephant is like maya: it came to solve a problem, and having solved it, it removes itself from the scene, leaving no trace of its previous presence.



flicked this story from :
http://timesofindia.indiatimes.com/life-style/spirituality/speaking-tree/Indefinable-nature-of-maya/articleshow/6636437.cms



I see this wise man as Entrepreneur and last elephant as his Efforts to make things better and no emotions attached.

Monday, August 09, 2010

30 Books Everyone Should Read Before They’re Thirty

30 Books Everyone Should Read Before They’re Thirty

I read 6 out of these... 24 to go and 2 years remaining..need lot to catch.


1. Siddhartha by Hermann Hesse
2. 1984 by George Orwell
3. To Kill a Mockingbird by Harper Lee
4. A Clockwork Orange by Anthony Burgess
5. For Whom the Bell Tolls by Ernest Hemingway
6. War and Peace by Leo Tolstoy
7. The Rights of Man by Tom Paine
8. The Social Contract by Jean-Jacques Rousseau
9. One Hundred Years of Solitude by Gabriel García Márquez
10. The Origin of Species by Charles Darwin
11. The Wisdom of the Desert by Thomas MertonThe Wisdom of the Desert by Thomas Merto
12. The Tipping Point by Malcolm Gladwel
13. The Wind in the Willows by Kenneth Graham
14. The Art of War by Sun Tzu
15. The Lord of the Rings by J.R.R. Tolkien
16. David Copperfield by Charles Dickens
17. Four Quartets by T.S. Eliot
18. Catch-22 by Joseph Heller
19.The Great Gatsby by F. Scott Fitzgerald
20 The Catcher in the Rye by J.D. Salinger
21. Crime and Punishment by Fyodor Dostoyevsky
22. The Prince by Niccolo Machiavelli
23. Walden by Henry David Thoreau
24. The Republic by Plato
25. Lolita by Vladimir Nabokov
26. Getting Things Done by David Allen
27, How To Win Friends and Influence People by Dale Carnegie
28 Lord of the Flies by William Golding
29, The Grapes of Wrath by John Steinbeck
30. The Master and Margarita by Mikhail Bulgak

30 Books Everyone Should Read Before They’re Thirty

30 Books Everyone Should Read Before They’re Thirty

Saturday, May 01, 2010

Pollard ko itna late kyun bheja?

Today Gangadhar kids were playing against relatively stronger uncle's team. Uncles are all in mid twenties so do not exactly fit to be called uncles but kids are actual kids between 5-14 age group so no option. Even I am an uncle for these kids.

So this uncles team blasted 50 runs of 5 overs. with New rules and DLF maximums, allowed in the ground. they were completely overshadowed. so big score to chase and uncles team being stronger on bowling side too, cut through their batting line up
to take all wickets for some 10 runs. then somehow I shifted my self from fielding team to batting team as I fielded for them for 2-3 balls. as I know how these kids are sensitive to winning the games, I have no option to start aggressive,
so I started wiith 2 sixes of 2 balls, suddenly baccha camp was all excited and started shouting Pollard,
Pollard,
so I got in more enthu and hit one more boundry next ball... and the comment came on..
"Arre lekin hamne pollard ko itna late kyun bheja?", (originally in marathi, अरे पण, पोल्लार्डला एवढे लेट का पाठविले? ) With perfect timing and context and with such a innocence that kid spoke,
I just cant stop blushing :) as this is the sentence was on everyones mouth a week back when MI lost to Chennai in IPL,
and at End everyone has this question..."Why do they sent pollard so late?" as pollard blasted 22 in 5 balls still mumbai lost, so Gangadhar kids..:)

Monday, April 05, 2010

Salesforce: Timezone, CreatedOn - trivial fix

I was showing list of records with createdDateTime. Created date was being shown in GMT at one place for same record
and it was shown in IST format at other place. I thought both places I am doing same thing but result was different.
It was all Salesforce's magic Apex languange rendering.

following code was showing date in GMT despite global setting being IST.
< apex:pageBlockTable value="{!recentList}" var="item" >
< apex:column >
< apex:facet name="header" >Created On< / apex:facet >
< apex:outputText value="{!item.CreatedDate}" />
< / apex:column >

< / apex:pageBlockTable>

Slight change in the code fixed this issue. removed facet and outputText.

< apex:pageBlockTable value="{!recentList}" var="item" >
< apex:column value="{!sms.CreatedDate}" headerValue="CreatedOn" / >

< / apex:pageBlockTable>

Saturday, March 06, 2010

Authentication for CodeIgniter done right

Got good piece of information from stack overflow, by Jens Roland

http://stackoverflow.com/questions/346980/what-code-igniter-authentication-library-is-best

Just republishing it...
Disclaimer: none of the golden words below are written by me.


Authentication for CodeIgniter done right

Here's my MINIMAL required list of features from an authentication library. It also happens to be a subset of my own library's feature list ;)

1. Tiny footprint with optional test implementation
2. Full documentation
3. No autoloading required. Just-in-time loading of libraries for performance
4. Language file support; no hard-coded strings
5. reCAPTCHA supported but optional
6. Recommended TRUE random salt generation (e.g. using random.org or random.irb.hr)
7. Optional add-ons to support 3rd party login (OpenID, Facebook Connect, Google Account, etc.)
8. Login using either username or email
9. Separation of user and profile data
10. Emails for activation and lost passwords
11. Automatic cookie login feature
12. Configurable phpass for hashing (properly salted of course!)
13. Hashing of passwords
14. Hashing of autologin codes
15. Hashing of lost password codes
16. Hooks into CI's validation system
17. NO security questions!
18. Enforced strong password policy server-side, with optional client-side (Javascript) validator
19. Enforced maximum number of failed login attempts with BEST PRACTICES countermeasures against both dictionary and DoS attacks!
20. All database access done through prepared (bound) statements!

Note: those last few points are not super-high-security overkill that you don't need for your web application. If an authentication library doesn't meet these security standards 100%, DO NOT USE IT!

Recent high-profile examples of irresponsible coders who left them out of their software: #17 is how Sarah Palin's AOL email was hacked during the Presidential campaign; a nasty combination of #18 and #19 were the culprit recently when the Twitter accounts of Britney Spears, Barack Obama, Fox News and others were hacked; and #20 alone is how Chinese hackers managed to steal 9 million items of personal information from more than 70.000 Korean web sites in one automated hack in 2008.

These attacks are not brain surgery. If you leave your back doors wide open, you shouldn't delude yourself into a false sense of security by bolting the front. Moreover, if you're serious enough about coding to choose a best-practices framework like CodeIgniter, you owe it to yourself to at least get the most basic security measures done right.

Friday, March 05, 2010

Find the hidden Atlas :)

Can you see him?



Now ?




Atlas shrugged... tired so flew and hidden behind tree...

MySQL timezone setting for IST

Normally on US based servers, default US timezone is used, when creating DateTime in mysql. If your application is served to only India based customers then better to set mysql timezone to show Indian time.

check time_zone* tables in mysql db. if they are empty fill them using following command

shell> mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

Zone Info database on system.
Such systems are Linux, FreeBSD, Solaris, and Mac OS X. One likely location for these files is the /usr/share/zoneinfo directory.

mysql>SET GLOBAL time_zone = "Asia/Calcutta";


This blog is writter based on info from mysql website .