Adding Mongo DB driver to XAMPP
Posted: January 26, 2012 Filed under: Linux, Techno irrelevency ., Ubuntu, Web 2.0 | Tags: database, drivers, internet, linux, mongo, mongodb, open, opensource, php, php extensions, source, tutorial, ubuntu, web, xampp 8 CommentsLike many developers I use XAMPP for PHP development. But adding PHP extensions in xampp to does not seem to have a direct procedure . So when I wanted mongodb drivers I was on my own to figure out how to get it working . Here is the knowledge I gained .
I am using Ubuntu oneiric ocelot machine so this procedure is similar for all *NIX machines (Sorry windows users but the procedure must similar).
- First download and install Mongo db from mongodb.org/downloads
- Secondly download the PHP MongoDB driver source from github.com/mongodb/mongo-php-driver
- Now to compile the code
- You need phpize to compile the source code, so install php5-devpackage by running `sudo apt-get install php5-dev`
- Navigate into the mongo-php-driver directory and run `phpize` on the terminal
- Then run `./configure` to check for dependencies
- Run `make` to build the package
- You need phpize to compile the source code, so install php5-devpackage by running `sudo apt-get install php5-dev`
- Assuming XAMPP is installed at `/opt/lampp/` copy `mongo.so` and `mongo.la` from `modules` directory inside mongo-php-driver directory to `/opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/` directory
- Add the line `extension=mongo.so` to `/opt/lampp/etc/php.ini`
- Start mongodb and xampp servers and run the program test program from php.net/manual/en/mongo.tutorial.php to check if it is working
C some Speed !!
Posted: December 26, 2011 Filed under: Original Article | Tags: c++, comparison, factorization, java, JVM, open, open-source, opensource, python, source, speed 1 CommentMost programmers know that c programs are the next best thing to assembly language programs in terms of Speed , and here is yet another example .
When solving one of the problems at projecteuler.net.I Suddenly came upon the idea to compare the speed of execution of the same algorithm in different languages.
So here is the program in Three Programming languages , C , Java and Python
First in C
#include<stdio.h> long long LargestPrimeFactor(long long number) { long long n = number , i , Largestfactor = 1; for (i = 2; i <= (n / i); i++) { while (n % i == 0) { Largestfactor = i > Largestfactor? i : Largestfactor; n /= i; } } Largestfactor = n > Largestfactor ? n : Largestfactor; return Largestfactor; } int main (){ printf(" %d \n",LargestPrimeFactor(600851475143)); }
Then in Java
class ex3{ public static long LargestPrimeFactor(long number) { long n = number, factor = 1 , i; for (i = 2; i <= n / i; i++) { while (n % i == 0) { factor = i>factor?i:factor; n /= i; } } factor = n>factor?n:factor; return factor; } public static void main(String [] args){ System.out.println(LargestPrimeFactor(600851475143L)); } }
and now in Python
def LargestPrimeFactor(num): n=num factor = 1 i=2 while( i<= (n/i) ): while( n%i == 0 ): if i>factor : factor = i n /= i i += 1 if n > factor: factor = n return factor print LargestPrimeFactor(600851475143)
I computed the times using the time utility in linux .
I expected the c program to win there was no doubt about that , and java was expected to come in second with python last .
$ time ./a.out 6857 real 0m0.003s user 0m0.004s sys 0m0.000s
$ time java ex3 6857 real 0m0.114s user 0m0.084s sys 0m0.028s
$ time python ex3.py 6857 real 0m0.035s user 0m0.028s sys 0m0.004s
From the results its quite visible that c had won over python and python had won over java ,even though java was supposed to be faster than python.
The reason for python winning is that the cost of starting up the JVM is quite high, when compared with the cost of starting the python interpreter.
So lesson learnt If your program is short run it in python when given a choice , but still C is the king of Speed
Ps: This Question on stackoveflow goes over some more details .
Screencasting from Ubuntu
Posted: October 17, 2011 Filed under: Techno irrelevency . | Tags: 10, 11, gnome, gnome-shell, ocelot, oneiric, oneiric ocelot, open, screencast, shell, source, ubuntu, ubuntu-11.10, webm Leave a commentScreencasting (Recording a video of your desktop) just got easier since if you have Gnome Shell .
Gnome shell comes with an inbuilt screencasting feature which is activated by pressing
ctrl+alt+shift+rTo deactivate it just press the same combination . The video is by default saved in webm format in the current user’s home directory.
Here is a sample video.
Limit the CPU usage of a process (Linux).
Posted: August 8, 2011 Filed under: How-To, Linux, Ubuntu | Tags: cpu, heat, limit, linux, open, processor, source, ubuntu Leave a commentThere have been times when I wished that I could limit the cpu usage of a process even though it might run slower , There is a simple way to do it on Linux .
Just type the following in terminal.
cd /tmp wget 'http://downloads.sourceforge.net/cpulimit/cpulimit-1.1.tar.gz' tar -zxvf cpulimit-1.1.tar.gz cd cpulimit-1.1 make cp cpulimit /usr/local/sbin/ rm -rf cpulimit*
If you are a debain/Ubuntu user you can also do the following in terminal.
$ sudo apt-get install cpulimit
After installation to limit the cpu usage of a process :
cpulimit -p -l
Happy cpu reduction !!
Professionally git
Posted: August 6, 2011 Filed under: post | Tags: amazon, book, control, git, github, linux, open, open-source, paperback, pro, pro-git, professional, progit, programming, revision, source, System, vcs, version Leave a commentGit (not to be mistaken for the English-slang word) , is a version control system from the maker of the Linux Kernel , who seems to name everything after himself (to be mistaken for the English-slang word ).
git is more than just a version control system , Its light weight , lightning fast Distributed Revision Control System .
I learnt on how to use git the hard way , (i.e) on my own without a book .
But for those of you wanting to gain in-depth knowledge or just start-up with git you can try this free E-book http://progit.org/ebook/progit.pdf and http://progit.org/book/ .
Image Courtesy : Amazon
Serving Servlets !
Posted: May 26, 2011 Filed under: How-To, Linux, Techno irrelevency ., Tutorial | Tags: apache, dynamic, eclipse, foss, how, how-to, internet, java, jsp, linux, open, opensource, pages, servlet, source, to, tomcat, tutorial, ubuntu, web, Windows Leave a commentWhen staring web developement now a days many people start with PHP , Ruby on Rails , or something like that , but there was a Time when Servlets were King .
Servlets are still very Prominent and are also very powerful, and sometimes better than any other web development platform.
To get started with servlets using just Tomcat is very easy , but using Eclipse along with it Required a small bit of effort .
I spent 20 minutes on learning how to configure Eclipse to work with Tomcat 7
So here is a Tutorial for the same .
The Downloads
2 Things have to be downloaded
The Process
I am writing this tutorial for Linux but the concept is the same for Windows and Mac .
After Downloading
Extract Eclipse and tomcat into a folder
Run Eclipse
open Window->Preferences
Choose Server->Runtime Environments
Click Add
Choose Apache Tomcat v7.0
Choose the location where Tomcat was extracted
Click Finish
Now the Server has been successfully added .
The Project
Create a new Dynamic Web Project
Right click on the project select New->Servlet
Now you can create your Servlet and run it in eclipse with Tomcat , so what are you waiting for get coding!!
Firing up Ubuntu with the 4th Fox
Posted: March 23, 2011 Filed under: browser, Internet, Linux, Techno irrelevency ., Ubuntu | Tags: 10, 4, apps, browser, downloading, firefox, firefox4, free, installing, linux, maverick, meerkat, open, source, ubuntu, updating, upgrading, web Leave a commentFirefox 4 (stable) was released yesterday (March 22 , 2011), So I decided to write an article on how to install firefox 4 on Ubuntu the easy way.
Now if you goto mozilla.com to download the latest version on linux you prompted to download a file called firefox-4.0.tar.bz2
but many people don’t know how install this file , well the easier method is to download the latest version from Firefox stable PPA
but before you do this make sure to uninstall any beta versions.
Open terminal and type the following commands
First thing to do is add the Firefox stable PPA
sudo add-apt-repository ppa:mozillateam/firefox-stable
then before we can install firefox we need to update the PPA
sudo apt-get update
Finally we can install Firefox
sudo apt-get install firefox
And thats it , firefox will now download and install itself , Simple and Easy !
FLEX ible Builder !
Posted: March 20, 2011 Filed under: browser, Flash, Techno irrelevency . | Tags: 4.0, action, actionscript, builder, c++, calculator, designing, flash, flex, java, javascript, jquery, MxML, open, opensource, resume, script, sdk, source, Symposium, web Leave a commentI recently attended a 2 Symposiums at some colleges whose name I don’t want to mention, I was a participant in Web Designing Competition in both . In the first one , I really did not plan , I just made a mash up with jQuery , but in the Second one, I put some effort into planning and I designed a really cool website with jQuery UI , I deserved at least a 2nd prize , but my tough luck would have it , I didn’t win anything !
I noticed then winners of both the competitions were students who created something very basic with Flash , My creating was comparatively complex and had more features , but Students who did Flash got real preference.
I set out to Solve this , I Applied to the program that adobe was offering Flex Builder 4 for free to students ,and I got a reply with a free serial Key .
Then I set out to Learn Flash under flex SDK 4.1.
This was a bit more difficult than I Thought , but I Finally managed to Understand MxML and Action Script .
Armed with this Knowledge I made a Simple Calculator (http://j.mp/ewBMmM )
Being a guy who Likes Open Source stuff , I have made the source code available for free.
Just Right Click –> View Source
In view source mode you get to see the source code and also to download a Zip version .
A nice Feature that is easily built with Flex Builder .
I was surprised to Learn How simple Action Script really is .
Action Script ,JavaScript ,Java , C++ … all these languages are like cousins , You Know one , the other is really similar .
MxML on the other hand is pure XML , but its very easy with Autocomplete Enabled.
So the First Step of My Flash Learning Process is officially complete.
Now I can officially add this to my Resume` .
Natty Narwhal
Posted: March 14, 2011 Filed under: Linux, Ubuntu | Tags: 04, 11, 11.04, beings, counter, foss, free, gnome, gtk, human, linux, maverick, meerkat, narwhal, natty, open, qt, source, ubuntu, unity Leave a commentThe Latest Upcoming Distro of Ubuntu is 11.04 (Natty Narwhal) , and here is a nice counter from a German blog .
The Latest release comes with the totally redesigned Unity interface .
Lets wait and see how it turns out !!
Ubuntu Customization
Posted: March 13, 2011 Filed under: post | Tags: compiz, custom, customization, emerald, gnome, gtk, human, linux, open, source, ubuntu Leave a commentFor those looking to customize their ubuntu destktop here is a nice guide http://ubuntuone.com/p/fuo/