Configure Dropbox in RHEL/Centos/Fedora and File Upload From Linux To Dropbox

Dropbox is a free file hosting service operated by Dropbox, Inc. that lets you bring your photos, docs, and videos

dropbox2from anywhere and share them easily. Dropbox allows users to create a special folder on their computers, which Dropbox then synchronizes so that it appears to be the same folder (with the same contents) regardless of which computer is used to view it. Files placed in this folder also are accessible through a website and mobile phone applications.

Follow the below steps to configure Dropbox:

Step:1 Create an account on www.dropbox.com

Step:2 Login your Linux System

Step:3 we need to install dependency packages

# yum install curl bash

Step:4 Now go to /tmp directory and download dropbox up loader script and give appropriate permission to run script

test@localhost:~$ cd /tmp
test@localhost:~$ wget https://raw.github.com/andreafabrizi/DropboxUploader/master/dropbox_uploader.sh
test@localhost:~$ sudo cp dropbox_uploader.sh /usr/local/bin/droptobox
test@localhost:~$ sudo chmod +x /usr/local/bin/droptobox

Step:5 Now you can run the program anywhere from the terminal by running droptobox command

1
test:~$ droptobox

Here will ask you for the “App Key and App secret”,
Then create it from the Dropbox web and copy below url and paste in browser
# https://www.dropbox.com/developers/apps
Here we click “app” button and create an app. Give “Full Access” while filling the App details.
It will display an “App Key” and “App Secret” after successful creation.
Copy both App key and App Secret key and go to terminal and paste and give “f” in the access option.
# App key: xxxxxxxxxxxxxx
# App secret: xxxxxxxxxxxxxxx
# Access level you have chosen, App folder or Full Dropbox [a/f]: f
Then it will display a Link, Copy and paste it on the web browser and Allow the API access.

How to upload file from Linux terminal to dropbox:

Here we can use ” /usr/local/bin/droptobox ” or ” droptobox ”
## List Directory
# /usr/local/bin/droptobox list
## Upload a file to drop box
# droptobox upload file1
## Upload the files to your drop box /Test directory
# droptobox file1 Test/file1
## Delete a file “file1″ in “Test” directory in dropbox
# droptobox delete Test/file1
## Download a file “file1″ in “Test” directory in dropbox
# droptobox download Test/file1

See also : Andolasoft launches “Patia” – Free App to Find your file in Dropbox & Google Drive

Hope you liked the blog. It would be great if you can share your valuable comments with us.

How To Enhance Image Processing With Core Image In IOS Apps

Core Image is a powerful framework for image processing and analysis technology designed to provide real-time processing for still and video images. This helps you easily apply filters to images, such as modifying the hue, exposure or vibrant. It uses the GPU or CPU rendering path to process the image data very fast.

Core Image can be chained with multiple filters to an Image or video frame at once by creating custom effects. Core Image provides us more than 90 built-in filters on iOS and over 120 on OS X. You can set up filters by supplying key-value pairs for a filter’s input parameters. You can use the output of one filter as the input of another filter, to create amazing effects.

Here is how the Core Image is related to the iOS operating system

core-image-1024x415

Before going into Core Image, let’s know about the classes used in the Core Image framework:

CIContext:

The CIContext is a class which provides an evaluation context for rendering a CIImage object. CIContext class is used to take advantage of the built-in Core Image filters while processing an image.

CIImage:

The CIImage is a class which represent an image or holds an image data which may be created from a UIImage, from an image file, or from pixel data.

CIFilter:

The CIFilter class produces a CIImage object as output. A filter takes one or more images as input. The filter class has a dictionary that defines the attributes,so the parameters of a CIFilter object are set and retrieved through the use of key-value pairs. This helps us to add some beautiful effect on the input image.

Sample example:

In this example local image path is used in resource file to apply effects.

// 1 Retrieving the localimage.png path from resource bundle

NSString *filePath =
  [[NSBundle mainBundle] pathForResource:@"localimage" ofType:@"png"];
NSURL *fileNameAndPath = [NSURL fileURLWithPath:filePath];

// 2 Converting the normal image to CIImage object by passing the URL of original localimage.png

CIImage *beginImage =
  [CIImage imageWithContentsOfURL:fileNameAndPath];

// 3 Adding the filter SepiaTone effect to the localimage.png

CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"
                              keysAndValues: kCIInputImageKey, beginImage,
                    @"inputIntensity", @0.8, nil];
CIImage *outputImage = [filter outputImage];

// 4 showing the output image in the UIImageView

IImage *newImage = [UIImage imageWithCIImage:outputImage];
self.imageView.image = newImage;

Note : Here we can change the value of the CIFilter value which is given 0.8 by using a slider which min value is 0 and max value is 1.

Here we have not used the CIContext to perform an CIFilter as said earlier. It helps us to make it easier.

Lets change the above code to include the CIContex:

CIImage *beginImage =
[CIImage imageWithContentsOfURL:fileNameAndPath];
 
// 1
CIContext *context = [CIContext contextWithOptions:nil];
 
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"
keysAndValues: kCIInputImageKey, beginImage,
@"inputIntensity", @0.8, nil];
CIImage *outputImage = [filter outputImage];
 
// 2
CGImageRef cgimg =
[context createCGImage:outputImage fromRect:[outputImage extent]];
 
// 3
UIImage *newImage = [UIImage imageWithCGImage:cgimg];
self.imageView.image = newImage;
 
// 4
CGImageRelease(cgimg);

Let’s see what happened here:

Here we set up the CIContext object. The CIContext takes an NSDictionary that specifies options including the color format and whether the context should run on the CPU/GPU. Here the default values are fine and so you passed as nil for that argument.

Here we used an method on the context object to draw a CGImage. Calling this method createCGImage:fromRect: on the context with the supplied CIImage will give us an output as CGImageRef.

Next, we converted the CGImage to UIImage using “imageWithCGImage”.

At last we release the CGImageRef as CGImage. CGImage is a C API which need to free memory even it runs with ARC.

Note: To know about all available filters write the following code and call the method in viewDidLoad / onLaunch. The filters are written on the console log.

-(void)logAllFilters {
NSArray *properties = [CIFilter filterNamesInCategory:
kCICategoryBuiltIn];
NSLog(@"%@", properties);
for (NSString *filterName in properties) {
CIFilter *fltr = [CIFilter filterWithName:filterName];
NSLog(@"%@", [fltr attributes]);
}
}

Like this blog? I’d love to hear about your thoughts on this. Thanks for sharing your comments.

Advantages and Disadvantages of Hiring Remote Team

In recent time, it has been seen that more and more business owners are open to remote teams; whereas, some entrepreneur are still in dilemma whether to hire remote team because they don’t have any clue how to adapt to remote group. So today, here I will pinpoint some points that will help entrepreneur to make decision easily.

Advantages to hiring remote or virtual team:

1. Get better talent at much low cost:

You can hire people who are either in your city or eager to move and you know great talent doesn’t live next door. Sometime, even if you get that talent near to, but may be out of your budget. However remote team is providing a feasible option to hire best talent from anywhere in the world and that will be within your budget.

2. Low office cost:
Office Rent, electricity, computer, and other equipment added significant ongoing cost. So again by hiring remote team you can easily cut out this unnecessary costs.

3. Increased productivity:
If you think employees working in an office are more productive than remote team, then the report released on Staples Advantage is definitely an eye opening for you.

  • 48% of remote workers say they are less stressed
  • 53% of employers with remote workers report more productive employees
  • 75% of business decision makers notice happier employees

Generally remote team get much longer and uninterrupted period of time to get more productive work.

4. Saving time from unproductive meetings:
Generally unnecessary meeting and distraction from co-worker waste productive time a lots. These are some common problem in office which can be easily rid out by hiring a remote team.

5. Provide flexible time option:
Remote team helps you to work 24*7 basis which again speedup your productivity.

6. If your job is temporary in nature:
If you are a business owner and want a team who can work for you for fixed time period on contract basis then again remote team is nice option for you. You can easily scale up or reduce or team as per your requirements.

7. Professional Approach :
It has been seen that remote teams follow more professional approach than in-house team to their job rather because they are looking for long run business association with the entrepreneur.

Problem of working with distributed or remote team:

1. Lack of communication between remote team and you :
It is very much obvious that, if you work with in-house team, then you can easily go to someone desk at any time and do the casual discussion; where in case of virtual team you have to schedule a meeting to discuss about your project. Definitely this is a major issue but in the flip side it will spare bunches of time which will devoured by ineffective talk and diversion from companions. Likewise that, the virtual team made extra, deliberate  effort to ensure that they communicate with smoothly.

Some of the tools that help you to communicate with you virtual team: Skype , OrangeScrum(Project Management tool), Basecamp, Google Dropbox and Hangouts etc. Also see our previous post: Top 10 simple tools you should know for working with remote team

2. Hard to work with remote time :
More often that remote teams belongs to different timezone, so it gets hard to work at the same time with remote team that you can generally do with your office employees, and it becomes one of major issue people find remote team is not viable option for them. However, it learns you to work asynchronously.

Really the hindrances of working a virtual group are blessings in disguise.

If you opt for remote developers who work on your project dedicatedly, then Andolasoft is an ideal and savvy option for you.

Like this blog? I’d love to hear about your thoughts on this. Thanks for sharing your comments.

How to monetize your Android application through In-App Billing?

In-App-Billing1What is In-app Billing ?

In-app products are the digital goods that you offer for sale from inside your Android application to your app users. You cannot use In-app Billing to sell personal services, physical goods, or anything that requires physical delivery.

Product types

The Version 3 API supports managed in-app products and subscriptions to give you flexibility in how you monetize your application. You can specify these types of products by using the Google Play Developer Console.

  • Managed in-app products:
    When a managed in-app item is purchased by an user, Google Play stores the purchase information for each item on a per-user basis.
  • Subscriptions :
    In In-app Billing, subscription plan offered you to sell content, services, or features to users from inside your app with recurring monthly or annual billing.

I will demonstrate a small example with In-app Billing,

To implement in app billing in your android project follow the below steps:

Step# 1: Installing the Google Play Billing Library
Before proceeding, verify you have installed the library by launching the Android SDK Manager by selecting the Eclipse Window -> Android SDK Manager option. Once loaded SDK Manager, scroll down to the Extras section and the Status column next to the Google Play Billing Library
Step# 2: Adding Billing Permission to the Manifest File
Add the following line in your AndroidManifest.xml file in order to make your app eligible to use in-App billing.

<uses-permission android:name=”com.android.vending.BILLING” />
Step# 3: Adding the Utility Classes to the Project
Find out the “TrivialDrive” sample project that was installed into the android SDK as part of the Google Play Billing library, includes a set of classes intended specifically for in-app billing implementation.

Locate the IInAppBillingService.aidl file in “TrivialDrive” sample project and add it to the package named “com.android.vending.billing”.

Then Select all nine Java files within “com.example.android.trivialdrivesample.util” package and copy and paste them into the <domainname>.inappbilling.util package of your InAppBilling project.

Step# 4: Designing the User Interface
Design your UI according to your need. This is a sample design developed to demonstrate the In-App Billing.

In-App-Billing-181x300

 

 

 

 

 

 

 

 

 

Step# 5: Obtaining the Public License Key for the App
Google Play billing must be identified by a unique public license key. The only way to get a public license key is to register an application within the Google Play.
Go to http://play.google.com/apps/publish Once you are logged in, In home page of the Google Play Developer Console, click the Add new application button, which specifying the default language and a title of InAppBilling. Once the above information has been entered, click the Upload APK button:
This APK file upload is not necessary at this point, so once the application has been registered, click on the Services & APIs option to display the Base64-encoded RSA public key for the application.

Step# 6: Creating a New In-app Product
Select the In-app Products menu item from the left hand panel of the developer console.To add a new product, click on Add new product button and, in the result panel, set the product type to Managed product and enter a Product ID (in this case com.andolasoft.testInApp). Click on Continue and in the second screen By entering a title, description and price for the item. Change on the menu at the top of the page to Activate.

Step# 7: Implementing “Purchase” Button click

public class MainActivity extends Activity {
 
    private static final String TAG = "<your domain>.inappbilling";
    IabHelper mHelper;
     
    private Button clickButton;
    private Button buyButton;
    private static final String TAG = "com.andolasoft.testInApp";
    IabHelper mHelper;
    static final String ITEM_SKU = "android.test.purchased";
.    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
 
        buyButton = (Button)findViewById(R.id.buyButton);
         
        String base64EncodedPublicKey =
                                       "<your license key here>";
         
            mHelper = new IabHelper(this, base64EncodedPublicKey);
         
            mHelper.startSetup(new
            IabHelper.OnIabSetupFinishedListener() {
                    public void onIabSetupFinished(IabResult result)
             {
                       if (!result.isSuccess()) {
                         Log.d(TAG, "In-app Billing setup failed: " +
                    result);
                       } else {             
                           Log.d(TAG, "In-app Billing is set up OK");
                              }
                      }
            });
    }
public void buyClick(View view) {
             mHelper.launchPurchaseFlow(this, ITEM_SKU, 10001,   
                    mPurchaseFinishedListener, "mypurchasetoken");
/*The developer payload token string. This can be any string value and is used to identify the purchase. For the purposes of this example, this is set to “mypurchasetoken”.*/
 
    }
@Override
protected void onActivityResult(int requestCode, int resultCode,
     Intent data)
{
      if (!mHelper.handleActivityResult(requestCode,
              resultCode, data)) {     
        super.onActivityResult(requestCode, resultCode, data);
      }
}
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
    = new IabHelper.OnIabPurchaseFinishedListener() {
    public void onIabPurchaseFinished(IabResult result,
                    Purchase purchase)
    {
       if (result.isFailure()) {
          // Handle error
          return;
     }      
     else if (purchase.getSku().equals(ITEM_SKU)) {
         consumeItem();
        buyButton.setEnabled(false);
    }
           
   }
};
public void consumeItem() {
    mHelper.queryInventoryAsync(mReceivedInventoryListener);
}
     
IabHelper.QueryInventoryFinishedListener mReceivedInventoryListener
   = new IabHelper.QueryInventoryFinishedListener() {
       public void onQueryInventoryFinished(IabResult result,
          Inventory inventory) {
 
                       
          if (result.isFailure()) {
          // Handle failure
          } else {
                 mHelper.consumeAsync(inventory.getPurchase(ITEM_SKU),
            mConsumeFinishedListener);
          }
    }
};
IabHelper.OnConsumeFinishedListener mConsumeFinishedListener =
      new IabHelper.OnConsumeFinishedListener() {
       public void onConsumeFinished(Purchase purchase,
             IabResult result) {
 
     if (result.isSuccess()) {                
            //Here user paid for the app so write your logic to show the content to user
     } else {
             // handle error
     }
  }
};
 
@Override
public void onDestroy() {
    super.onDestroy();
    if (mHelper != null) mHelper.dispose();
    mHelper = null;
}
 
}

Step#8 : Upload the “APK”
Create the signed APK of your project and upload it in your added Application in Google Play Developer Console

Step# 9: Adding In-app Billing Test Accounts
Unfortunately, Google does not allow developers to make test purchases from their own Google accounts app billing, Other Google accounts used as testing accounts. . From ths ipoint on, in order to test in-app,  the users of these Google accounts must load your application onto their devices and make test purchases. To add a test user account, click Settings icon located on the left hand side of your Google Play Developer Console home screen and on the account details screen scroll down to the License Testing section. In the corresponding text box, give the Gmail accounts for the users who will be performing the in-app testing on your behalf before saving the changes.

Note: This email Id should be the primary account of an android device where this app is to be tested. Check with Google policy before publishing the app to the android market place.

Conclusion: I hope you find this post useful to sell your android in-app products and services, make transaction smoother and easier, and improve your revenue. If you are looking for any assistance regarding android application development or other android integration, then you can contact us.

See Also: How to monetize your iOS app through Apple In-App Purchase integration

Like this blog? I’d love to hear about your thoughts on this. Thanks for sharing your comments.

 

Steps to add ‘Elasticsearch’ to Rails App

ElasticSearch-to-Rail-AppsWhat is Elasticsearch?

Searching on websites is important from a content discovery and user usability perspective. It allows readers to control the way they look for content instead of navigating through menus. Elasticsearch is a distributed open source search server based on Apache Lucene, much like Solr. It allows for real-time searching and the ability to scale easily through replicas. It has a REST API and communicates over JSON. We will use a gem called Tire to communicate with it.

What is the Problem if you don’t use a search engine?

If your application requires a full text search, then it is better to add a search engine like elasticsearch to the application. As normal queries to the database for the full text search might slow down your performance. You will end up with complex queries.

Tire is an elasticsearch ruby client. It can be used in any Ruby project, but it also has some nice model functionality to make it easy to integrate into a Rails application. It is actively maintained, has a large amount of users, and also integrates nicely with Rails and ActiveModel.

Step#1
Install elasticsearch in your server

$curl -L -O -k https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.0.Beta1.zip
$unzip elasticsearch-0.90.0.Beta1.zip
$mv elasticsearch-0.90.0.Beta1 elasticsearch

Install the Elasticsearch Service Wrapper

$curl -L -k http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
$mv *servicewrapper*/service elasticsearch/bin/
$elasticsearch/bin/service/elasticsearch install
$ln -s `readlink -f elasticsearch/bin/service/elasticsearch` /usr/local/bin/rcelasticsearch (optional use )
$rcelasticsearch start or /etc/init.d/elasticsearch start

By default the server on port 9200 ex: http://localhost:9200
We can communicate to the server manually if we want through the JSON REST API.

Step#2
Add the following gem in your gemfile

gem 'tire'

Run the bundle install

Step#3
To make the Article searchable with Tire, just include below lines of code in your model

class Article < ActiveRecord::Base
include Tire::Model::Search
include Tire::Model::Callbacks
end1
 
<strong>Setp#4</strong>
To create index for elasticsearch server run the below command
 
1$ rake environment tire:import:all

You can also force-import the data by deleting the index first

$ rake environment tire:import CLASS=’Article’ FORCE=true

Step#5
Add the following in your model

def self.search(params)
tire.search(load: true) do
query { string params[:query]} if params[:query].present?
end
end

Step#6
Add the following in your controller

def index
if params[:query].present?
@articles = Article.search(params).paginate(:page => params[:page], :per_page => 12)
else
@articles = Article.all
end
end
Step#7 Add the search form>
<%= form_tag articles_path, method: :get do %>
<p>
<%= text_field_tag :query, params[:query] %>
<%= submit_tag "Search", name: nil %>
</p>
<% end %>

To know the which model are indexed you can test by running the followings in your browser

http://localhost:9200/_aliases?prett

To test the elasticsearch run the followings in your browser which will return the data in JSON format

http://192.168.2.100:9200/articles/_search?q=news

Conclusion:

Andolasoft is one stop shop for Ruby on Rails app development. We Design, develop & deploy Rails application in cloud for start-ups & established businesses. If you look for any type of assistance, please contact us.

Like this blog? I’d love to hear about your thoughts on this. Thanks for sharing your comments.