Monday, December 25, 2023

Cloud Computing: Confusion As A Service

All these fancy names in cloud computing—like IaaS, PaaS, CaaS, FaaS and more—can make your head spin. It seems like in tech, if you give something a name, you’re instantly seen as an expert. But do we really need to name every little thing?

Think about RESTful APIs for example — basically a method for apps/services to communicate with each other. But it's become this big thing with its own special name. Same goes for these cloud models. I’ve been using Google Cloud for years, deploying containers using GKE, creating Compute Engine instances, deploying GCP functions and never bothered by this jargon. To me, it’s just Google’s tools. Whether it’s machines or apps, I use what works without needing a glossary. This overload of cloud "models" feels like a barrier, like I’m supposed to be fluent in this secret language to belong.

Communication matters, sure but all these XaaS terms just create more confusion, especially when the lines between them blur in practice. I think the only practical approach is to understand what a cloud provider offers and use the cloud services that suit your needs without delving deep into the specific terminology. Let’s balance clarity and this unnecessary naming chaos.

The need for clear communication and the overwhelming proliferation of terms is contradictory and highlights a challenge in the tech industry. Finding a balance between naming things for clarity and avoiding unnecessary jargon is an ongoing struggle and is not helped by the competing companies making these terms into buzzwords and marketing tools, overshadowing their original purpose of facilitating understanding.

Isn't it strange? We say naming is hard and yet we name everything.

Thursday, December 21, 2023

The Missing Piece in Online Learning: The Power of Conversations

In the past, our educational journey revolved around classrooms, textbooks, and more importantly study groups. Remember those study groups where we'd stay back after class, discussing lessons, and learning from each other's perspectives? Those conversations were excellent—they made understanding complex ideas easier. Collaborative learning, bouncing ideas off each other, and discussing concepts were integral parts of truly grasping the depth of what we were taught. However, with the rise of online education and Massive Open Online Courses (MOOCs), the dynamics of learning have shifted.

Many have heralded online courses as a replacement for traditional education, boasting convenience and accessibility. Yet, amidst the wealth of information available at our fingertips, a crucial element seemed absent: the art of discussion, the back-and-forth exchange that fleshes out understanding. This is the reason why I find so many incomplete courses on my Coursera account.

Recently I tried another online course and felt that gap again. I wanted to chat with someone about the subject matter, but since it was online, I didn't have a study buddy. That's when I had a crazy idea: what if I used a chatbot like ChatGPT as my study partner?

Surprisingly, this experiment yielded remarkable results. Interacting with an AI, bouncing ideas, posing questions, and articulating thoughts seemed to fill the void of a missing study group. The experience wasn't just about finding answers; it was about fostering a deeper comprehension through conversation.

This unconventional approach raised intriguing questions about the evolving landscape of learning. Could AI companions supplement traditional study groups or serve as a bridge when physical collaboration isn't feasible? Does this mark the inception of a new paradigm in education?

While it's undeniable that the essence of in-person study groups and the camaraderie they foster shouldn't be replaced, the concept of utilizing AI as a study companion presents an intriguing opportunity. It offers a unique way to bridge gaps in learning, fostering deeper understanding, and enhancing the overall educational experience.

Integrating traditional study groups with AI companions might be the next step in learning. It's combining the charm of discussions with friends and using tech to deepen our understanding.

What's your take on this? Have you ever considered learning with an AI companion?

Sunday, January 22, 2023

Peopleware: Part Three - The Right People

Its important to hire right people. Managers often like to think that they can turn coal into a diamond but the reality is that they neither have enough leverage nor enough time to make people to change in any meaningful way. People will remain almost the same as they were on the first day of the job so it is important to hire and even more important to retain the right people.

You don't want to hire a juggler without actually looking at him/her juggle. Similarly when hiring developers, its important to see an example of their work. Asking them to bring a portfolio of their work on an interview shouldn't be a problem. When given opportunity people like to show their work.

Diversity in hiring has its benefits but they are not free. We should value the different ways of working, thinking and communicating diverse colleagues bring to the team but more diverse a team is, more effort will be required on the manager's part to get the team to jell together. If the team keeps chaning, adding or removing contractors, then it will never jell. 

The young workers today are built different. There are generational differences that need to be understood and accomodated. These young workers were born and raised in a world with phones, apps and other things that are continously trying to steal their attention. They have gotten used to splitting their attention and will tell you that they work best in such an environment but such continous partial attention doesn't work well in a creative thinking environment. It is opposite of the flow which is essential to getting meaningful work done. It stops them and others from getting into flow. It is important for their carreers for the manager to clearly articulate the contract to them. Such periods of continous partial attentions must be thought as personal time and should be reasonably limited during the work day. 

Retaining good people is even harder. The total immediate cost of replacing an employee is almost 6 months of wages but there is a hidden cost. In companies with very high turnover, people develop destructively short term view points. They are willing to sacrifice future for smaller immediate benefits. Employees are not willing to invest in long terms goals as they don't believe they will be around to see the benefits and the company is not willing to invest in its people as it doesn't believe they will be sticking around. In such companies no body, neither company nor the employee, is willing to take the long term view. In such companies the only way to retain good people is to promote them quickly. This results in a very top heavy organization chart where most of the people are "managers" and people actually doing the work are may be 20%. It is very disconcerting that in such organizations the people actually creating the producsts have very little experience as more experienced people are sitting in management. Young people may find the idea of a quick promotion to 1st level mangement good but from a corporate perspective, late promotion is a sign of health, it means people stick around. Such organizations create higher quality products as people actually working on the products have a lot of experience.

People leave a company for various reasons but three reasons account for most: 

  1. 1. Just passing through mentality.
  2. A feeling of disposability.
  3. Loyalty would be ludicrous (not sure about this one, not a reason in it self)

The insidious affect is that turnover engenders turnover. People leave quickly because company doesn't invest in its people and the company doesn't invest in its people because nobody sticks around. More important than why people leave is to understand why people stay. People stay because of the feeling of community. Because leaving a company doesn't just mean leaving your job, it means leaving some friends, leaving a community you enjoy being part of and with whom you have developed a bond. The best organization consciously try to be best. This gives people a common goal to achieve together and to bond around. It creates a sense of community. Some companies try to explicitly engender the sense of community. A common feature of companies with lowest turnover is retraining. Retraining helps build the mentality of permanence and strong sense of community. These companies are different. There is an energy and sense of belonging that is practically palpable.

The money spent in training or retraining people is not an expense, its an investment. An investment is when you trade one asset for another betting that the new asset will provide more value in the long run. Thinking of the human capital as a sunk expense causes managers to make decision that don't preserve the value of the organization's investment. Companies of knowledge workers need to understand that this human capital is their most valuable investment and matters the most.

Tuesday, December 27, 2022

Peopleware: Part Two - The office environment

Summary of part II of Peopleware: Productive Projects And Teams

So if the managers job is to enable people to work, how does he/she do that?

The first step is acknowledging that the resource that you are managing i.e the peopleware does not come from a factory. They are unique and every individual has their own way of working and choice of keyboard/mouse/screen/desk arrangement etc. You can't have all the desks look the same and all the walls have the same paintings and all the floors look exactly alike. Give the people freedom to mold their environment according to their needs and wants. Once that gets out of the way, people can focus on the work and not fuss about how the silly mouse on their table annoys them. So get out of their way.

The thinking worker also needs to, surprise surprise, think. That requires quiet and focused time. In an office environment with a lot of distractions, this becomes impossible. If people come early or stay late just to get some work done, you should be worried.

Saving money on space is not the smartest move. The company may save a penny on space but will pay a dollar because of the reduced productivity. People are not chickens that can be crammed in tight cages and still lay eggs. You need to provide ppl space and reasonable privacy to do their best work. Office quality is directly proportional to product quality. More noisy offices produces more buggy software. Also quality workers tend to gravitate towards quality offices. So even if everything else was same, if you loose out on quality workers you loose out on quality products. They companies producing quality products all provide their workers quality offices.

You should enable people to have that focused time. People should expect that and no body should be offended if a colleague didn't reply immediately because they were focused on a problem. Asking people to report the number of productive hours each day builds this awareness in the people that this is something that they can expect to have and builds a culture of people letting other people work without distractions. Start measuring the environment factor (e-factor) on regular basis.

e-factor = Uninterrupted hours/Hours in office

If the e-factor is less than 40%, the office environment is not letting the people to get in to flow and get the job done.

Management should make sure that their is enough space, enough quiet and enough privacy so the people can get the work done and then get out of their way.

Peopleware: Part One - The human resource

From now on I am going to use this blog to record learning from the books that I read. To summarize what I have read so I can get back to it when I want/need to. The first book that I am going with is Peopleware: Productive Projects And Teams and here I summarize the first part of this book.

The first part of the book is about understanding the resource that we are managing. Different resources require different style of management. In programming terms memory and processor are two distinct resources and require different management. The resource that is being managed is creative thinking workers and they need to be managed accordingly. Almost all the time when a project fails, the reasons are not technological  but sociological. Understanding this is key. Thinking workers are not created from the same mold and hence can't all be treated the same way. They require freedom to do what they do. They will make mistakes and should be allowed to do so. They are not part of an assembly line where one can be easily replaced with another. Assembly line management of optimizing the pipeline for more throughput will not work. People should be allowed to spend time thinking and not just doing.

The Spanish theory managers try to optimize value produced per hour of paid labor by using unpaid overtime. This will not get your far. Most of us have limited "productive" hours per day and overtime will not increase that number and overtime on one day results in some "undisclosed" or "unreported" downtime the other day. So the net remains the same. But in the long run this kind of management will result in resentment and in good people stopping caring as they realize they sacrificed more important things like their personal lives, their kids birthdays and etc for work. This will harm the company badly. Let the people have normal lives and work life balance. This will do more good and does not result in less actual work.

Creative people take pride in what they create. Pushing them to deliver something faster at the cost of quality hurts that pride and harms the companies bottom line in the long run. The company may deliver the product on time but if the people stopped caring about the product they are creating, the company will hurt. Japanese companies allow the staff to have veto over product delivery if the people creating the product are not satisfied with it.

Parkinson's law says that work expands to fill the time available. This may be true in some cases but not in case of people who like doing what they are doing. People under stress don't work better, just faster. The quality degrades, more bugs are left and they require time to get fixed. So it may feel like the work is happening faster but the productivity actually goes down. The data actually suggests not having any deadlines at all as it results in the most productivity but some people may feel lost in such an environment and in such cases estimates/deadlines by system analysts result in best productivity. One observation though is that the organization busy work does expand to fulfill all the time available i.e meetings and all. We do need to keep that in check.

The manager's role in such an environment is not to make people work. These people care about their craft and want to work. The manager's role is to remove hurdles from peoples way and make it possible for them to work.

Monday, May 8, 2017

Simple Ways to Improve Battery Life on Linux Laptops

  • Set Ubuntu's Built-In Power Settings. 
  • Turn off Bluetooth. 
  • Turn off Wi-Fi. 
  • Lower Screen Brightness. 
  • Quit Apps You're Not Using. 
  • Avoid Adobe Flash (Where Possible) 
  • Install TLP.

Tuesday, March 3, 2015

How to CORRECTLY take a screenshot using Android MediaProjection API

With the MediaProjection API in Android 5.0 it is possible to: 
capture the contents of the main screen (the default display) into a Surface object, which your app can then send across the network
The process to capture the screen contents is described in MediaProjection API Demo. This demo uses a SurfaceView to show a miniature version of the device's screen creating a Droste effect. But the surface view is not very helpful to actually use the captured screen i.e you can not get the screen capture as an image or a video. If you need to capture the screen as an image you can use and ImageReader object and pass its surface to createVirtualDisplay() method.

The problem is that it is not very straight forward to get the captured screen from ImageReader object either. The image that you get from ImageReader is raw i.e it has stride pixels in the image buffer and you need to take care of them your self. There are many people out there having difficulties getting the image from an ImageReader e.g here, here and here. The solution described in some of these Stackoverflow posts does work but it reduces the image quality significantly and also it is a lot more work and therefore it is slow. 

Below I describe a simpler method to get the image from ImageReader once you have created a virtual display using the ImageReader's surface. For completeness sake I describe the steps for creating a virtual display as well but if you are familiar with them just skip to step 3.

Step 1
To capture the screen contents you need a MediaProjection object. But first you need the user's permission to capture the screen using following code:
MediaProjectionManager projectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);startActivityForResult(projectionManager.createScreenCaptureIntent(), PERMISSION_CODE);
This will start a dialog activity to ask user for permission to capture the display contents. 

Step 2
Once user allows screen capture, we can get a MediaProjection object in the onActivityResult() method using the following code.
MediaProjectionManager projectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);
mProjection = projectionManager.getMediaProjection(resultCode, data);
The "data" passed to getMediaProjection() call is the intent data passed to onActivityResult() method. 

Step 3
The call to create a virtual display takes width and height of the virtual display and a surface object which will be used to save the device's screen. To the capture the screen as an image or a series of images we use surface of an ImageReader object. Create an ImageReader object as follows:
mImageReader = ImageReader.newInstance(mWidth, mHeight, ImageFormat.RGB_565, 2);
Step 4
Once we have the MediaProjection and ImageReader objects, we can start capturing screen by creating a virtual display using following code:
mProjection.createVirtualDisplay("screen-mirror", mWidth, mHeight, mDensity, flags, mImageReader.getSurface(), null, null);
Step 5
Now we can get the screen capture as image using the following code.
final Image.Plane[] planes = image.getPlanes();
final ByteBuffer buffer = planes[0].getBuffer();
int offset = 0;
int pixelStride = planes[0].getPixelStride();
int rowStride = planes[0].getRowStride();
int rowPadding = rowStride - pixelStride * mWidth;
// create bitmap
Bitmap bmp = Bitmap.createBitmap(mWidth+rowPadding/pixelStride, mHeight, Bitmap.Config.RGB_565);
bmp.copyPixelsFromBuffer(buffer);
image.close();
now the bitmap object bmp has the your screen capture in correct format and you can simply use Bitmap.compress() method to convert it to JPEG, PNG or WEBP format. 
The error that most people make here is that they create bitmap of the wrong size, they create bitmap of same width and height as the virtual display but the problem is that the image you get from ImageReader has some extra pixels in there on each line. So you need to account for those as well when creating the bitmap to copy the pixel data. Therefore when creating bitmap I am passing "mWidth+rowPadding/pixelStride" as width. This is for sake of clarity so it is easy to understand otherwise you can instead pass "rowStride/pixelStride".

Thursday, November 6, 2014

Three parts of a web page

As far as I see there are three components of a web page:

1. HTML
2. CSS
3. Javascript

There are different libraries, frameworks and gems dealing with these three aspects. So far, in each of these three areas, I have identified following things that I need to learn, step by step:

HTML: HTML5
CSS: Sass, bootstrap
Javascript: jquery, coffee script

I will keep adding other stuff to this list as I realize or as I come across them.

Tuesday, November 4, 2014

Re learning RoR

I did web development using RubyOnRails for a year after I graduated in 2006. Back then there was not a lot of documentation about it and we had to learn lot of stuff using trial and error. I havent lot of development in RoR since then but now I want to do some serious web development and RoR seems an obvious choice since it is very popular and because I know it a little. So I have started re-learning it. I am going through Ruby On Rails Tutorial book and I intend to finish it. Many things are new and at times it feels too much to even remember all the different frameworks/libraries that keep poping (Saas, bootstrap, coffee script, jquery and etc) not to mention all these gems being used but hopefully I will get the hang of it soon. 

Monday, September 8, 2014

Common RVM commands


  • Installing RVM

$>​ curl -L https://get.rvm.io | bash -s stable
$> rvm autolibs packages
          If you dont have curl you can install it using
$> sudo apt-get update
$> sudo apt-get install curl

  • Install specific ruby version:

          Installing version 2.0.0
$> rvm install 2.0.0
          Installing version 1.9.2
$> rvm isntall 1.9.2

  • Use a specific ruby version

$> rvm use 2.0.0

  • Use a specific ruby version and make it the default

$> rvm use --default 1.9.2

Thursday, June 12, 2014

Android: Open Facebook official app from your own app with different intents

Opening Facebook's official android app from your own app is really easy. You just need to create an intent with correct uri and start and activity with that intent. The app will open with the right page, group, picture, video or etc.

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);

where uri could be any of the following:

fb://root
fb://feed
fb://feed/{userID}
fb://profile
fb://profile/{userID}
fb://page/{id}
fb://group/{id}
fb://place/fw?pid={id}
fb://profile/{#user_id}/wall
fb://profile/{#user_id}/info
fb://profile/{#user_id}/photos
fb://profile/{#user_id}/mutualfriends
fb://profile/{#user_id}/friends
fb://profile/{#user_id}/fans
fb://search
fb://friends
fb://pages
fb://messaging
fb://messaging/{#user_id}
fb://online
fb://requests
fb://events
fb://places
fb://birthdays
fb://notes
fb://places
fb://groups
fb://notifications
fb://albums
fb://album/{%s}?owner={#%s}
fb://video/?href={href}

Thursday, June 5, 2014

Android game engines

I want to try my hand at game development for smart phones. I am familiar with Android and own 4-5 Android devices so the platform choice is straight forward. But I cant seem to decide which game engine to start with. I have tried googling a lot and there is no clear winner. The most popular game engines seem to be Unity, Corona and Cocos2D. Cocos2D is the only one of these which is totally free. So I think I will start with Cocos2D. If someone has other suggestions please let me know.

Friday, January 10, 2014

Email from Google+ circles - No thanks.

Just received an email from Google touting the new FEATURE of GMail:
Starting this week, when you're composing a new email, Gmail will suggest your Google+ connections as recipients, even if you haven't exchanged email addresses yet.
Until today I have never been worried about random people adding me to their circles on Google+. I mean who cares if some random guy from some country you never heard of added you to their circles. Doesn't matter. Right? They couldn't see my status, posts, pictures or anything that I share with my circles except  for what is shared publicly. But not now. Now (s)he can send me an email. Sure they can send me just one email and can't start another conversation with me unless I respond to their first email but my inbox is already too littered as it is and I don't want even a single unwanted email coming in my direction. And even if you limit the number of unwanted email from one account to just one, what is stopping spammers from creating new accounts for just one email per person?And if I want someone to be able to talk/email to me, I will share my email address with them, so stop forcing Google+ on me. Microsoft is already making a good case for their email service with really nice interface and no spam (so far).

Those of you who share this sentiment, nip it in the bud. Turn it off. For doing this just go to your gmail account, then go to Settings. Under general tab you will find a setting for Email Via Google+. Turn it off.


And for fan of memes, here is something that pretty accurately describes my feelings at the moment.


Friday, January 3, 2014

I am so tired of Unity: Part 2 AKA I like Kubuntu/KDE

I have been trying Kubuntu for last week or so and so far I am really liking it. I must say that I am impressed. KDE looks a lot more polished and stable than Unity or even GNOME 3 for that matter. The UI is really sleek and stylish. The effects are good looking and so are fonts and icons. The text in title bars, buttons, menus and everywhere else is thinner and a lot more smoother than it is in Ubuntu. And most importantly I really like Kate. I am used to Notepad++ and Gedit always felt so ancient in comparison. But Kate seems like a good replacement. I think I will stick around for a while.

Friday, December 27, 2013

I am so tired of Unity

I am an avid Ubuntu user. It has been my primary OS since 2008 i.e for almost six years now. But I am now getting tired of Unity, not Ubuntu, just Unity. For those not familiar with the term, Unity is the desktop environment of Ubuntu. Ubuntu switched to Unity from GNOME a while ago when GNOME 3 was about to be released. I have read that Canonical did not agree with the direction GNOME was heading in and when they were not able to sort their differences with GNOME they decided to create their own desktop environment for Ubuntu and so Unity was created. But this is what I have read on internet and considering how reliable internet is, I am not sure what really happened but the fact remains that Ubuntu switched to Unity.

Unity has its own merits but it has made it difficult for me to perform day to day operations. For example whenever I have to run an app for which I don't have a launcher icon I have to click the home button and then type the app name for it to appear in the app list and then click on it. I don't like that. I also do not like that there is not button to minimize all windows. I also do not like the fact that every program has its menu in the top panel. When I have two windows open side by side and I need to use their menu, I have to first select the window and then move my pointer miles away to top panel to get to the menu. Similarly I like the close button for a window to be in the top left or top right corner of the screen when they are maximized. This makes closing them easy. But with Unity this is no longer possible. There are a lot of other similar issues which are not a big deal them self but together they make it really difficult for me to perform everyday operations.

But this does not mean I am giving up on Ubuntu, I am not ready to go back to Windows, but I have decided to give Kubuntu a try as well and see how I feel about KDE. No matter whom I end up with, KDE or Unity, I will still be using Ubuntu.

Wednesday, September 18, 2013

WebOS and Nokia - I wish

A mobile phone's hardware specifications are important but in today's world its the software (the Operating System) that dictates the user experience. Most high end phones today, from HTC, Motorolla, Samsung, Apple, Nokia and others, have almost the same hardware specs, with little or no differences. What distinguishes them from each other is the software on top of the hardware. And because of that Motorola, Samsung and HTC are no different for me. They try to give an illusion of uniqueness by making their own UI on top of Android but it does not effect most parts of my user experience.

Because of this, I have always been against Nokia making an Android handset. I have always thought that Nokia would be better off maintaining their unique identity. If they started making Android handsets they would be just another handset manufacturer in a long list of companies including Samsung, HTC, Motorolla, Huawei and many other Chinese and Korean and other handset manufacturers. But that would be a disgrace, I mean its Nokia which was once synonymous with mobile phone.

WebOS was the operating system on Palm Pre hand sets. I never got a chance to use WebOS but I have seen a lot of screen shots and read a lot of reviews when it came out and I was very excited about Palm Pre but unfortunately it never came to my country. The reviews for Palm Pre were good but what all the reviewers really liked and were talking about was its operating system i.e WebOS. So when HP bought Palm and later closed it altogether, I wished that Nokia would buy all the rights to WebOS and use it as the main operating system for their handsets. This way they would get a really great mobile operating system which would complement their existing handsets like Lumia nicely and could easily compete with the likes of Android and iOS.


I still wish Nokia would do this but I do not think this is going to happen now, with Nokia now being part of Microsoft and all, but the heart wants what the heart wants :)

Friday, August 30, 2013

Endianity conversion for a 24bit Integer

Recently while working on SSL protocol I came across 24-bit (3 byte) integers. I never thought any one would ever use a 24-bit integer. There are no default types or any type in stdint.h to create such a variable. So the best one could do is use 3 byte arrays and keep typecasting them to int - ignoring most significant byte on read and not writing the most significant byte on write.
The problem I faced was that I had to change the endianity of these 24-bit integers as the data is written to and read from network. I did not want to use a function call so I came up with following macros. They dont seem right to me i.e they are more weird looking and complicated than I wanted to so if someone has a simple solution, please share.

The following macro takes a pointer to 3 bytes containing 24 bit unsigned integer, converts the endianity of the integer value and returns it as int with most significant byte always 0
#define GET_NO_UINT24(src)  ((((*(uint32_t*)src)<<16)|((*(uint32_t*)src) & 0xFF00)|(((*(uint32_t*)src)>>16) & 0xFF)) & 0xFFFFFF)
The next macro takes 2 arguments. The first one is a pointer to 3 byte array for storing 24-bit integer and the second argument is the value to be stored.
#define PUT_NO_UINT24(dst,src) ((((unsigned char*)dst)[2]=(unsigned char)((src))), (((unsigned char*)dst)[1]=(unsigned char)((src)>>8)), (((unsigned char*)dst)[0]=(unsigned char)((src)>>16)))

Tuesday, January 1, 2013

Deploying a Spree application on Heroku

Heroku is a no-hassle hosting solution for Ruby, Node.js, Clojure, Java, Python, and Scala. It helps the developers to focus on the most important thing i.e creating the most amazing web app ever and forget about servers. Your application can be up and running in minutes. All you need to do is create an app on their servers and then push your code to it using git. They provide a handy utility to create and manage applications from command line and it can be installed from www.toolbelt.heroku.com.

Spree is an open source e-commerce platform that is available as a ruby gem for Ruby on Rails framework. It is intended as a foundation over which developers can build their own e-commerce sites.

Running a Spree application on Heroku is easy and can be done using the steps below.

Prerequisites

  1. A working spree application. If you want to know how to create one, read my previous post about creating a spree application.
  2. Working Heroku Account. If you don't already have one, sign up here.
  3. git client. On Ubuntu this can be easily installed using aptitude.

Steps

  1. Install Heroku Toolbelt.
    The toolbelt is a very handy utility for working with Heroku. The most important part of this toolbelt is a command line interface for creating and managing applications on Heroku server. For details and installation instructions please visit the Heroku Toolbelt website.
  2. Add your application to git version control.
    If not already done, add your app to git as this is required for pushing to Herokus servers. This is easily done using following commands:
    $ git init
    $ git add .
    $ git commit -m “initial commit”
  3. Next login to heroku from command line, add your SSH security keys to Heroku and create a new application
    $ heroku login
    $ heroku keys:add
    $ heroku apps:create myapp
  4. Push your changes to heroku
    $ git push heroku master
  5. Initialize your database
    $ heroku run bundle exec rake db:migrate
    $ heroku run bundle exec rake db:seed
And that is it. Your app should now be live at myapp.herokuapps.com. Head over to Heroku developer center for more details about this amazing platform or you can read this amazing book.

Sunday, December 30, 2012

Creating a Spree application


Spree is an open source e-commerce platform that is available as a ruby gem for Ruby on Rails framework. It is intended as a foundation over which developers can build their own e-commerce sites.

Prerequisites

To use Spree you will need to install following:
  1. ruby
  2. imagemagick
  3. nodejs
  4. libxml2
  5. libxml2-dev
  6. libssl-dev
  7. libxslt-dev
  8. postgresql
  9. postgresql-server-dev-9.1
If you are using Ubuntu, you can easily install all of these from repos using aptitude. Imagemagick is required for resizing uploaded images. PostgreSql is selected because it is common in the hosting platforms but if you are not concerned about it, you can simply replace it with sqlite or anything else that you like.

Steps

After installing the above listed softwares, install bundler, rails, rake and spree gem using following command:
gem install bundler rake rails spree
Now create a new rails application. The default database is Sqlite, so we need to specify that we want postgres:
rails new myspreeapp -d postgresql
Edit config/database.yml and add host: localhost to all configurations and also correct database name, username and password. Next, add spree to your app. To do this run following command from withing your applications root directory:
spree install
This will run a wizard which will ask your choices for running migrations, loading seed data and others and perform the required actions. When the wizard ends your spree application is ready and you can now run it on local host using:
rails s
Your basic spree applications is now available at http://0.0.0.0:3000. You will most probably want to customize this application according to your needs. Head over to spree customization guides for a detailed look at customizing spree.