Vuzix’s Smart Glass will Change the Way We Work with Computers

vuzix-smart-glassesWith the advancing technology, computers have been evolving through the years to become more compact to the users. First, there were desktops then they came to the laps and then to the hands, now the next generation computers will be right in front of our eyes in the form of wearable eyeglasses.

There are a lot of companies, who have been developing wearable computers, but they were shipped only for military purposes and never to the public.

Recently Google stunned the technology industry by announcing its plans to sell Google Glass to the public market.

But it turned out that Google isn’t the only one trying to make smart glasses in order to bring computers to a person’s field of vision.

A New-York based technology industry ‘Vuzix’ has unveiled a hands-free smart device that comes with an integrated “virtual display” eyepiece, Wi-Fi and Bluetooth connectivity, a 720p HD camera, and motion sensors.

The Vuzix smart glasses can sync up a smartphone or tablet. It contains a microphone, an earpiece, a camera, and motion and GPS sensors, and it’s capable enough to run any version of the Android operating system.

Bluetooth and Wi-Fi enable it to be linked to a smartphone to project a small display, positioned in the wearer’s vision, which provides a comfortable viewing area equivalent to having a four-inch smartphone display in hands.

The device is ideal for those who need to be connected to the cloud at all times.

The device is expected to start with relatively few features but eventually, it will become more impressive as the Android app developers develop software for it.

The glasses will get data and information from an app installed on a user’s Android device.

This technology will change the way we experience and work with computers and smartphones. It will also bring new possibility for the android application developers to create apps specifically for the Vuzix smart glasses.

How to implement Multiple Database(DB) Connection in Rails3

Rails 3In some scenarios, we need data from an external database to execute in different applications. Here, we need a bridge that will connect these two different databases.

In Ruby on Rails, this can be achieved through ActiveRecord’s establish_connection().

Following are the steps to create a rails application which uses multiple databases, where the existing database and the external database will work simultaneously.

Let’s say there are two different rails applications say “myapp” and “remoteapp” where “myapp” depends upon “remoteapp” user table.

Step#1

Edit the ‘database.yml‘ file for the ‘myapp‘ project
Add a new connection for ‘remoteapp‘ as below:

# Connection name, it will be used to connect from myapp
connect_remote:
adapter: mysql2
username: user_name             # username of the remoteapp database
password: password             # password of the remoteapp database
pool: 5
database: remoteapp_db_name    # database name of the remoteapp
host: www.remoteapphost.com      # host name of the db

Step#2

In models folder create a new file called user.rb if it is not already there. Write below code to establish connection with remote app’s database.

class User < ActiveRecord::Base
establish_connection("connect_remote")
end

Here use the connection name defined in the database.yml file in the establish_connection() method.
Like this you can create models to connect with remote databases.
Step#3

It will give you the flexibility for managing users’ data of remote app’s database like it is present in the myapp database.
Use the normal way to get data from the user’s table like

User.all                   #To get all the records
User.find(id)              #To get required record

Here you can also insert or update data in users table by normal way as it is
present in myapp application

#insert new record
user = User.new params[:user]
user.save
 
#update existing record
user = User.find params[:id]
user.update_attributes(params[:user])

How To Migrate CakePHP 1.x To 2.x

Today, we will focus on what we need to do to get CakePHP 1.3 application upgraded to CakePHP 2.2.3-the latest official stable release

Installation

This is pretty straight forward, same as CakePHP 1.3 version.
Download and unzip the CakePHP 2.2.3 and follow these below-mentioned instructions.

Configuration

  • core.php
  • Make sure to copy the security.salt and Security.cipher_seed from your old core.php
  • Take notice of how errors, sessions and caching have changed.
  • database.php
  • There is a minor change on this file,
  • CakePHP 1.3: ‘driver’ => ‘mysqli’
  • CakePHP 2.2.3: ‘datasource’ => ‘Database/Mysql’
  • routes.php
  • Don’t overwrite this file with your older one.
  • You can place your custom routes before or after CakePlugin::routes()
  • bootstrap.php
  • Copy all functions, constants and other code from your old bootstrap into the new one.

Folder Structure

  • The cake folder is now inside lib folder. There is nothing to do with this.
  • Files and folders are now CamelCased instead of lower_underscored
  • Example: The “users” folder inside the View becomes “Users”
  • The controller files are now UsersController.php instead of users_controller.php
  • project_user_controller.php becomes “ProjectUsersController.php”
  • The model files are now User.php instead of user.php
  • project_user.php model becomes “ProjectUser.php”
  • The components files are now FormatComponent.php instead of format.php
  • The helpers files are now DatetimeHelper.php instead of datetime.php

Moved APP files

  • The parent app_classes have been moved and renamed as well.
  • Instead of app_controller.php, app_model.php, and app_helper.php now become Controller/AppController.php, Model/AppModel.php, and View/Helper/AppHelper.php.

Auth Component and Login

  • Auth now supports multiple authorization adapters that can all be used together
  • Cake 1.3.x was automatically checking if user has correctly entered username/password inside your login () method of users_controller but in cake 2.x we need to manually call $this->Auth->login () this returns Boolean value based on successful login or failure.

If you are using “email” as your login field name
CakePHP 1.3: (inside AppController beforeFilter)

$this->Auth->fields = array('username' => 'email', 'password' => 'passw

CakePHP 2.2.3: (inside AppController beforeFilter)

$this->Auth->authenticate = array('Form' => array('fields' => array('username' => 'email', 'password' => 'password')));

Auth Login

CakePHP 2.2.3: (inside UsersController login function)

if (!empty($this->request->data)) {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
//$this->Session->setFlash('Your Email or Password was incorrect.');
}
}

CakePHP 2.x auth automatically hashes the password on login but not on save.

We can add a beforeSave() method on the User model to hash the password.

public function beforeSave($options = array())
{
$this->data['User']['password'] = AuthComponent::password($this->data['User']['password']); return true;
}

Request Data

  • CakePHP 2.0 has done some request related changes.
  • The Request Object does not have “form” element any longer.
  • You will need to replace $this->params[‘form’] with $this->request[‘data’] or $this->request->data.
  • $this->data needs to be replaced with $this->request->data
  • So, now we can use $this->request->data on both form submit and AJAX post.
  • Now, we need to check !empty($this->request->data) instead of “!empty($this->data)” while saving a form.

Views Changes

  • Use $this->Html->link() instead of $html->link()
  • Use $this->Form-> instead of $form->
  • Use $this->Session-> instead of $session->
  • Use $this->Paginator-> intead of $paginator ->
  • For JavaScript inclusion use $this->Html->script(“”) instead of $javascript->link()

Moved Email Elements

  • Email elements have been moved from views/elements to View/Emails.

Helpers

  • The Ajax, Javascript, and XML helpers have been removed. You will need to replace these helper calls with appropriate alternatives
  • Helpers can no longer be called with “$helper->function()”. You need to update your helper calls to use $this->Helper->function()
  • If you are loading or importing your helpers inside another custom helper or component,
  • $myhelper = new DatetimeHelper() becomes $myhelper = new DatetimeHelper($this->_View) or $myhelper = new DatetimeHelper(new View(null))

Components

  • All component files should be extended by Component Class instead of Object

DB and Code Caution

  • There is no Enum Support in cakephp2.x as sql server doesnt have similar datatype.
  • You can change enum to tinyint(2)
  • In cake 1.3 used tinyint(1) for is_active database fields.
  • While retrieveing from database it returns 0/1
  • But, cakePHP2.x no longer returns as 0. This will return bool(true) /bool(false)
  • Boolean column values will be casted to php native boolean type automatically.

__() Function and Pagination

  • The __() function no longer has the option to echo. It always returns
  • Change the Pagination code,

CakePHP 1.3:

echo $this->Paginator->counter(array( 'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%'', true)));

CakePHP 2.2.3:

echo $this->Paginator->counter(array( 'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%'')));

How to use ActiveRecord Callbacks in Rails

Rails3Callbacks are a great technique for achieving simplicity and flexibility. A callback allows you to run some code (usually a method) automatically when another piece of code runs. In Rails, you’ll commonly see callbacks that run before, after or even around other bits of code. Callback functions are minimizing the length of codes in controllers.

Implementing Callbacks

There are four types of callbacks accepted by the callback macros:

  • Method references (symbol)
  • Callback objects
  • Inline methods (using a proc)
  • Inline eval methods (using a string) – deprecated

Here is the list of some useful callback functions while saving AcriveRecord objects

  • before_save
  • after_save

before_save:

This method is called before an ActiveRecord object is saved.

class Post < ActiveRecord::Base before_save :update_slug protected def update_slug self[:slug] = [year, season_slug, season_type_slug].compact.join '/' end end

after_save:
Once the active record object saved some method will be fired in that scenario we have to use the after_save callback.

class Post < ActiveRecord::Base after_save :handle_status_changed protected def handle_status_changed Setting.create(:post_id=>self.id , :status => true) end end

Creating an Engine on Refinery CMS

Refinerycms

‘Engines’ are nothing but ‘plug-ins’ which adds up extended functionality to the existing Refinery application. Engines installs in the “vendor/extensions” folder in a refinery app.

Engines will create a tab in the Admin panel of the Refinery CMS to control the information on the engine.This example demonstrates creating an engine in an existing refinery app. The environments used are Ruby 1.9.3, Rails 3.2.8 & Refinery cms 2.0.8.

Step#1

To create an engine, just execute the below command

rails generate refinery:engine engine_name attribute:type attribute:name

NB: The engine name should be in singular which will generate the structure in plural form.
For example we want a FAQ engine for our CMS which will be controlled by CMS admin

rails generate refinery:engine MyFaq question:string answer:text

Running the above command will create a new folder “extensions” under “vendor” directory and in the “extensions” the new engine “my_faqs” will be created.

Step#2

After that run the below commands to make it executable

bundle install
rails generate refinery:my_faqs
rake db:migrate
rake db:seed

Step#3

Restart the server to get the effect. You will find the new tab “My Faqs” has been added both in the menu section of the user section and admin section.

Login as Admin to manage your FAQs

How to customize an engine during creation?

Creating the engine with a namespace

rails g refinery:engine MyFaq title description:text --namespace FAQ

Creating the engine by skipping the frontend pages

It will add menu and form page in the admin section only. User section will be omitted

rails g refinery:engine MyFaq title description:text --skip-frontend

How to cut down Amazon Web Services (AWS) billing?

Amazon_S3_online_servicesAndolasoft is specialized in providing Cloud Computing services to its customers. Here we have a huge team of skilled personnel to provide monitoring and support services for 24×7 across the world.

As a technology partner with Amazon Web Services, we would like to share some features as well as some useful tips about controlling the AWS billing cost.

What is Cloud Computing?

Integrating computing resources with World Wide Web to provide remote IT Infrastructure facilities is Cloud Computing. It’s an option to replace traditional IT infrastructures with virtual networking for faster job processing and higher productivity at lower costs.

What is AWS?

Amazon is providing similar IT infrastructure services as a web service, popularly known as Amazon Web Services or AWS. Currently it is providing services to millions of businesses in more than 190 countries.
Features that makes AWS unique in public cloud

  • Auto Scaling

Number of Amazon EC2 instances can be scaled dynamically or by user defined schedule to increase or decrease them automatically depending on the demand. You will receive notifications to initiate Auto Scaling actions, or when Auto Scaling completes an action. Auto scaling feature can be used via APIs or Command Line Tools with no additional fees.

  • Amazon Cloud Front and it’s Functionalities

Amazon Cloud Front is a web service to distribute contents to end users at high speed .Here you can store the original version of your files on one or more origin servers and configure them by using URL pattern matches to specify which origin has what contents. You can use distribution’s domain name in your web pages or application so when users request an object using this domain name, they are automatically routed to the nearest location to deliver your contents.

  • AWS Identity and Access Management (IAM)

Manage IAM users and their access- Identity and Access Management (IAM) offers greater security, flexibility, and control when using AWS. IAM enables you to create users in AWS and manage access to AWS services and resources for your users. It also enables you to grant access to users managed outside AWS. You can assign individual security credentials (access keys, password, Authentication devices) or request temporary security credentials to provide users access to AWS services.

Manage IAM roles and their permissions- You can create roles in IAM and manage permissions to grant specific operations to the entities.Manage access for federated users- You can enable identity federation to allow users to access the AWS Management Console, without creating an IAM user for each identity. It is done by requesting temporary security credentials. This temporary security credentials are comprised of short lived access keys and session tokens associated with them. Users can use the access keys the same way as before, but they also have to pass the token . They can further be restricted by specifying explicit permissions while creating them. Any number of temporary security credentials can be issued.

  • IAM provides the following access controls:

Fine-grained access control to your AWS resources: IAM enables you to add specific conditions to control how a user can use AWS, such as time of day, their IP address, by using SSL, or authenticating with a Multi-Factor Authenticationdevice.Identity federation between your enterprise and AWS services: IAM can be used to grant employees, and applications access to AWS Management Console and AWS service APIs, using existing identity systems.

Mobile and browser-based applications: Mobile and browser-based applications can also be enabled to access specific AWS resources using temporary security credentials for a configurable period of time.

Tips to cut down AWS Billing:

  • Use AWS reserved instance for long running projects and spot instances for short term projects.
  • Use AWS private IP for data transfer between instances.
  • Use AWS Rout53 DNS to reduce Elastic IP usages.
  • Use Linux based Instances.
  • AWS recently lunched Glacier which offers $0.01 per GB / month only. Use Glacier for data storage instead of S3 to reduce the price of S3.

Planning anything on AWS? Talk to our Experts