Translation


by Transposh

Posts Tagged ‘computing’

Understanding REST – For Beginners

Tuesday, September 20th, 2011

REST stands for Representational State Transfer. (It is sometimes spelled “ReST”.) It relies on a stateless, client-server, cacheable communications protocol — and in virtually all cases, the HTTP protocol is used.

REST is an architecture style for designing networked applications. The idea is that, rather than using complex mechanisms such as CORBA, RPC or SOAP to connect between machines, simple HTTP is used to make calls between machines.

  • In many ways, the World Wide Web itself, based on HTTP, can be viewed as a REST-based architecture.

RESTful applications use HTTP requests to post data (create and/or update), read data (e.g., make queries), and delete data. Thus, REST uses HTTP for all four CRUD (Create/Read/Update/Delete) operations.

REST is a lightweight alternative to mechanisms like RPC (Remote Procedure Calls) and Web Services (SOAP, WSDL, et al.). Later, we will see how much more simple REST is.

  • Despite being simple, REST is fully-featured; there’s basically nothing you can do in Web Services that can’t be done with a RESTful architecture.

REST is not a “standard”. There will never be a W3C recommendataion for REST, for example. And while there are REST programming frameworks, working with REST is so simple that you can often “roll your own” with standard library features in languages like Perl, Java, or C#.

Set Up Your Own Ubuntu Repository using apt-mirror

Sunday, February 6th, 2011

What is Ubuntu Repository?

It is the place where all software’s builds are stored for ubuntu. And when you make any install it downloads the package and install it.


Who should create a Repository?

If  you have a lots of ubuntu machines and you want to update and install a lot of packages in all the machines,else you have a slow internet connections then this is for you.


How can you create a Repository?

There are many ways how you can create a Repository.

  1. apt-proxy
  2. apt-cacher
  3. apt-mirror

Here I am going to show you how to create using apt-mirror. And if the machine is connected to internet,with web configuration it can also be used as a mirror in internet to download from.


Process of Creating The Repository

First of all you need a fast internet connection(this is required only once) with about 80 GB space to get all the downloaded packages.
I am setting up a repository for maverick-meerkat and have also included third party softwares.If you want you can add to the repositories with new source link and also remove some if you don’t want some.It almost is about 63.9 GB but i have added another 20 GB for fail safe options.

So here we go.

Step1: First install apt-mirror

1
sudo apt-get install apt-mirror

now you have the apt-mirror installed,Lets configure it

Step2:

1
 gksudo gedit /etc/apt/mirror.list

Here’s where you can enter the repositories that your local mirror will get all of it’s sources and debs from

Here’s what my mirror.list file looks like. Feel free to modify it to include or exclude what you will. Also, you may be able to find a closer and thus faster repository site i.e. in if you are in india you should look for an indian repository.



1
############# config ##################
#
# set base_path    /var/spool/apt-mirror
#
# set mirror_path  $base_path/mirror
# set skel_path    $base_path/skel
# set var_path     $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch  
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads     20
set _tilde 0
#
############# end config ##############
deb http://archive.ubuntu.com/ubuntu maverick main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu maverick-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu maverick-updates main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu maverick-proposed main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu maverick-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu maverick main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu maverick-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu maverick-updates main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu maverick-proposed main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu maverick-backports main restricted universe multiverse
clean http://archive.ubuntu.com/ubuntu


i have added all the repositories for maverick you can add according to your requirement.


step 3: Now we run it for the first time.Now its going to take a lot of time so you should devote a few hours for it.But in case you want to stop it and restart it from there the is no problem as it continues from there.so you can just run it when no one is using the connection.

1
sudo apt-mirror /etc/apt/mirror.list

step4: Phew once that’s done you’ll get some instructions on how to clean up unwanted files. Follow those.They’ll probably ask you to run below
command,but double check with your output.

1
sudo /var/spool/apt-mirror/var/clean.sh


step 5: Now once done with the download we can add it in the cron file so that it get updated  every day.Run the command to edit the file

1
gksudo gedit /etc/cron.d/apt-mirror

just uncomment the # from the last line and it will be updated every day at 4:00 AM you can edit and also change the timing and interval.


step 6: Now lets see how to use this repository.The easiest way would be using a web server like apache.so install apache

1
sudo apt-get install apache


step 7:point the mirror to apache web directory

1
ln -s /var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu /var/www/ubuntu

step 8: then add this repository in the machines you want to update.
for ex: if the machine can be  accessed by ajatus.in then just add

1
deb http://ajatus.in/ubuntu maverick main restricted universe multiverse.


This is how you can set up your own repository for ubuntu.


How to catch invisible friends on GTalk

Saturday, December 18th, 2010

I always wondered that there must be a way to catch friends off guard when they are invisible. Luckily I came across Python’s XMPP library which helped me. On ubuntu Linux you can install this module using apt.

1
$ sudo aptitude install python-xmpp python-dnspython

The complete script is as below . Open gedit or Vim and copy pate the below code. Save it as “track_invisible_users.py” Don’t forget to replace the username and password fields

?View Code PYTHON
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import xmpp
 
#constants
USER_ID = "youruserid@gmail.com"
PASSWORD = "yourpassowrd"
SERVER = "gmail.com"
 
jid=xmpp.protocol.JID(USER_ID)
C=xmpp.Client(jid.getDomain(),debug=[])
 
if not C.connect((SERVER,5222)):
    raise IOError('Can not connect to server.')
if not C.auth(jid.getNode(),PASSWORD):
    raise IOError('Can not auth with server.')
 
C.sendInitPresence(requestRoster=1)
 
def myPresenceHandler(con, event):
   if event.getType() == 'unavailable':
     print event.getFrom().getStripped()
 
C.RegisterHandler('presence', myPresenceHandler)
while C.Process(1):
  pass

After this run

python track_invisible_users.py 

Google music launches in India

Sunday, October 24th, 2010

Google has launched its online music service in India that enables users to search for legal music streams and downloads.

 

For its Indian music search service (http://www.google.co.in/music) Google has partnered with In.com, Saregama and Saavn. The three digital music providers, hold rights to hundreds of thousands of Indian tracks – ranging from old and new Bollywood hits to Indian classical music. The music search service currently indexes only Hindi songs.

 

Users can search for a particular song, an album or even for artists. On clicking the search results the songs play on a pop-up window.

Google’s priority mail service

Tuesday, August 31st, 2010


Don’t get surprised when you wake up tomorrow & you log on to your Gmail inbox to check your mails, you find sonething new on the left hand side taskbar. Google has this uncanny knack of surprising people & here comes a new funda called the priority mail. The Priority Inbox allows important emails to surface and stay up top, pushing the less relevant stuff into the background. When the Priority Inbox fails, well, you can train it by using the +/- buttons that are part of the new menu.
Google’s official homepage has lots many things to say. It says, Priority Inbox can help save you time if you’re overwhelmed with the amount of email you get. It attempts to automatically identify your important incoming messages and separates them out from everything else. Gmail uses a variety of signals to prioritize your incoming messages, including who you emailed most frequently and which messages you’ve recently opened as opposed to which messages
you’ve deleted.When you click the Priority Inbox navigation link on the left-hand side of your mail, you’ll see messages grouped in three sections: Important and unread, Starred, and Everything else.If Priority Inbox mistakes an email as important or doesn’t flag one that’s important to you, you can teach it to make better selections. Just select the message in question, and click the “mark as important” or “mark as not important” button; they’re the buttons with plus and minus icons just to the left of the Move to and Labels drop-down menus.
When you mark a message as not important, it will move out of the Important section. Over time Priority Inbox will learn what’s important to you and incorporate the feedback you give via these buttons.The signals that Gmail uses to prioritize your email are never surfaced to other users — they’re only used to prioritize your mail for you. So if you always ignore email from Bob and those messages are marked as “not important” in your inbox, it won’t affect how Bob sees the conversation in his inbox. Exciting stuff. I am pretty excited about the new feature.

Don’t get surprised when you wake up tomorrow & you log on to your Gmail inbox to check your mails, you find sonething new on the left hand side taskbar. Google has this uncanny knack of surprising people & here comes a new funda called the priority mail. The Priority Inbox allows important emails to surface and stay up top, pushing the less relevant stuff into the background. When the Priority Inbox fails, well, you can train it by using the +/- buttons that are part of the new menu.
Google’s official homepage has lots many things to say. It says, Priority Inbox can help save you time if you’re overwhelmed with the amount of email you get. It attempts to automatically identify your important incoming messages and separates them out from everything else. Gmail uses a variety of signals to prioritize your incoming messages, including who you emailed most frequently and which messages you’ve recently opened as opposed to which messages you’ve deleted.When you click the Priority Inbox navigation link on the left-hand side of your mail, you’ll see messages grouped in three sections: Important and unread, Starred, and Everything else.If Priority Inbox mistakes an email as important or doesn’t flag one that’s important to you, you can teach it to make better selections. Just select the message in question, and click the “mark as important” or “mark as not important” button; they’re the buttons with plus and minus icons just to the left of the Move to and Labels drop-down menus.
When you mark a message as not important, it will move out of the Important section. Over time Priority Inbox will learn what’s important to you and incorporate the feedback you give via these buttons.The signals that Gmail uses to prioritize your email are never surfaced to other users — they’re only used to prioritize your mail for you. So if you always ignore email from Bob and those messages are marked as “not important” in your inbox, it won’t affect how Bob sees the conversation in his inbox. Exciting stuff. I am pretty excited about the new feature.


Leave Your Key Board Behind

Monday, March 8th, 2010


Google gesture searchTyping is sooo yesterday. Google Gesture Search, a freshman out of Google Labs, lets you find stuff on your Android phone by drawing letters on the touchscreen as if you were jotting on a notepad. In addition to Android’s existing search by voice, image, and barcode, Gesture Search is yet another keyboardless input method for your touchscreen phone. At the very least, Gesture Search is a fun proof-of-concept; at most, it will hook a few dedicated touch keyboard haters. Here’s how it works.
With Gesture Search running, you write letters by swiping your fingertip on your touchscreen as if it were a whiteboard. With each character you input, Gesture Search live-searches your phone’s contacts, bookmarks, and music and displays the results on-screen. Tap an app, contact, bookmark, or song to launch it or view the contact. (For contacts, tap the green phone icon to start a call.)
When you start Gesture Search you get a plain black screen with a cursor-like pointer on the footer. You draw your first letter, and Gestures puts it at the bottom of the screen and displays matches in your phone’s application list, contacts, bookmarks, and if enabled, your music library. Then you draw the next letter to narrow your results further.
As you can see, a letter that can pass as either an H or an A will match both. You can’t be a slowpoke while you swipe, either: Gesture Search can recognize letters that involve more than one stroke–like a T–if they’re timed correctly. That is, don’t wait too long to cross your T, or Gesture Search will think it’s an I. (Hint: If you’re consistently not fast enough, in the app’s settings set “Writing Speed” to “Slow.”)
If you want to delete a letter, you can: to backspace, in the footer, just draw a line from right to left as if you were pushing the delete key back. Then you can re-enter the character.

Typing is sooo yesterday. Google Gesture Search, a freshman out of Google Labs, lets you find stuff on your Android phone by drawing letters on the touchscreen as if you were jotting on a notepad. In addition to Android’s existing search by voice, image, and barcode, Gesture Search is yet another keyboardless input method for your touchscreen phone. At the very least, Gesture Search is a fun proof-of-concept; at most, it will hook a few dedicated touch keyboard haters. Here’s how it works.With Gesture Search running, you write letters by swiping your fingertip on your touchscreen as if it were a whiteboard. With each character you input, Gesture Search live-searches your phone’s contacts, bookmarks, and music and displays the results on-screen. Tap an app, contact, bookmark, or song to launch it or view the contact. (For contacts, tap the green phone icon to start a call.)When you start

Gesture Search you get a plain black screen with a cursor-like pointer on the footer. You draw your first letter, and Gestures puts it at the bottom of the screen and displays matches in your phone’s application list, contacts, bookmarks, and if enabled, your music library. Then you draw the next letter to narrow your results further, as shown above.As you can see, a letter that can pass as either an H or an A will match both. You can’t be a slowpoke while you swipe, either: Gesture Search can recognize letters that involve more than one stroke–like a T–if they’re timed correctly. That is, don’t wait too long to cross your T, or Gesture Search will think it’s an I. (Hint: If you’re consistently not fast enough, in the app’s settings set “Writing Speed” to “Slow.”)If you want to delete a letter, you can: to backspace, in the footer, just draw a line from right to left as if you were pushing the delete key back. Then you can re-enter the character.



Gesture Search is available for Android 2.0+ only. Search for it in the Market, or scan the QR Code below with your Android device to install it.

Goodbye Shared Hosting, Welcome to the Cloud

Thursday, October 15th, 2009
Cloud Computing

Back in 2007 I got a shared hosting account from Hostmonster which claimed to offer me “300GB of space” which was later upgraded to “Unlimited“, “3000GB monthly bandwidth” which was later upgraded to “Unlimited“, “Unlimited MySQL databases“,  “Unlimited mails“, etc. all for a meager amount of 5.95 USD/month. I felt as if I had all the power in the web but soon realized all the “Unlimiteds” were awfully limited. Although I had a shell access for the account, the best I could do with it was copy or move files. I couldn’t install anything onto it or modify anything I needed. What good was all the unlimited for when you had small limits on processor timings and memory usage. Especially when hundreds of shared hosted sites are hosted on the same server its only a matter of time when your site becomes listed as a malware website with Google and co just because some unscrupulous user setup a malware website on the same server as yours. Then I felt the need of having a dedicated server. Now we run Ajatus on a dedicated server which we got for a steal of a deal from Serverminds.

But, now times have changed, for a blogger of today what is the best option to host his websites along with the freedom of trying out his hands on the various components of his server? It can’t be shared hosting, and dedicated web servers are a tad bit too expensive for him. VPS (Virtual Private Servers) is another option where the hosting provider gives the user slices on servers shared over a visualization layer like that of XEN or VMWare. But, VPS are also not very recommended if you have a hunch that your site might need scaling because of a rise in traffic, as it limits the users scope for scaling without moving entire data and setup and their price are also not as reasonable. So what other option are we left with, Cloud Servers, for most of us it might sound something which would be extremely expensive and an enterprise solution. But the fact is its not at all expensive when it comes for a starting user with minimalistic requirements, provided that you choose the right hosting provider. I will provide a small price comparison of the most popular Cloud Server hosts later in this post. So, what is Cloud computing all about? Cloud Computing can be considered as an extended VPS which can be seamlessly scaled dynamically over the Internet. Amazon is one of the largest providers of Cloud computing infrastructures. But except for Amazon’s Simple Storage Service (S3) all others seemed pretty much expensive to me especially the Elastic Compute Cloud (EC2). So, what can you do with a cloud server? Well on a cloud server you can do everything that you can do on a dedicated server with an added option of dynamic scalability. You can host your blogs, experiment with all sorts of fancy technologies and once you feel you are going out of resources ask your service provider to expand your Cloud Server in-terms of memory, storage or processor cycle limits. Having told all this lets have  look at the pricing for a minimalistic Cloud Server configuration provided by some of the Industry leaders:

Amazon EC2: For the smallest Cloud Server they charge 0.10 USD/hour that makes it 0.1 x 24 x 30 = 72 USD/month. For the same price you could easily rent a dual Opteron Dedicated Server with 2GB memory for your self.

Aptana Cloud: Their pricing for 256 MB memory and 5 GB storage is  20 USD/month. This seems a bit more reasonable. Actually this would also be the price of an equivalent VPS.

RackspaceCloud or Mosso CloudFS: Their pricing seemed the best to me. For 256 MB memory and 10 GB storage they charge on 1.5 cents/hour or 10.95USD/month. Now that is extremely low. This is just a little bit more than what most of the shared hosting provider charge for their pseudo “Unlimited” hosting. What more whenever your site seems to soar up in traffic just dynamically add another Cloud Server and share your load.

GoGrid Cloud Hosting: Their minimum offering is half a Gig of Memory and 30 GB of storage at a price of 0.095 USD/hour = 68.4 USD/month. This also seems high for a beginer.

There are other Cloud Computing service providers also, but most of their offerings target the enterprise more than to the  personal usage. One such example is RightScale, although they provide Developer free trials their pricing is simply too expensive for a beginner.