ideas on 23 october 2015

gallery for printing companies
what they did on customer consent
online
---
give freenlance work to existing known freelancer with your friend, company

Allocating elastic ip, deallocating ip, moving elastic ip

Junit fixed method order annontation

Junit test method you wrote don't follow the order of methods 
to follow the order add @FixMethodOrder on Test class

Elastic IP

Elastic IP is
1)Static IP
2)Attached with AWS account
3)Not with ec2 instance
4)You can map elastic ip to another ec2 instance.


reference: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html


Street Food India - Indian Street Food Mumbai - Malaysia Street Food (Part 11)

butane cylinder with nossil to burn

butane cylinder with nossil to burn

use this butane gas cylinder to heat, weld..

butane gas torch

Aluminium sheet /materialwelding

portable(mobile) automatic electric weighing machine

http://www.amazon.in/Digital-Kitchen-Battery-Electricity-Operated/dp/B00WK9OFLO/ref=sr_1_1?ie=UTF8&qid=1445181863&sr=8-1&keywords=electronic+weight+machine

  • Capacity: 10 kg, Accuracy: 1 gm
  • Works on 2 AAA pencil cells and has a power slot
  • Weight conversions of g / kg / lb / oz
  • Large LCD showing 5 digits and 20 mm height
  • Outside calibration, auto zero tracking, auto backlight, auto shut off, tare function, overload indicator


Portable Electronic Digital LCD Weighing Scale(Colours May Vary)

199.00 

  • Portable Electronic Scale with Superior LCD Screen, Backlight with 2 Nos. Powercell AAA Batteries
  • Suitable for Weighing Luggage, Bags, Etc. Ideal for Office, Outings, Travellers and Shopping Applications
  • Automatically Adjusts Accuracy Based on Goods and Weight
  • Multi-Unit Conversion Feature Converts Measurement Units Automatically
  • Colours May Vary

thermal bluetooth prinnter receipt printer,


Thermal bluetooth printer
cost around 4500
charge it
portable
no need to connect through wires
use bluetooth
connect with android table/phone for even more small compact functionality

search in quickr, buy in SP road, Bangalore

you need to buy thermal roll paper for printing

link: http://bangalore.quikr.com/Thermal-POS-printer-IBM-4610-for-sale-W0QQAdIdZ226313252
but this link from quickr, may not be there forever

Elastic BeanStalk command line usage create application, create environment, deploy, terminate, git branch

Elastic BeanStalk 
#create elastic bean stalk applicaiton
eb init
#create elastic bean stalk environment for current applicaiton
eb create

#push current branch the code to current default environment of current applicaiton
eb deploy

# list environment for the current application
eb list

#set default environment name for git branch
eb use

#connect to ec2 instace
eb ssh
#show slogs
eb logs


#open amazon console of elasticbean for this application
eb console

#check environment health
eb health

#sets environment variable of the current environment, current applicaton
eb setenv name="ikbhal" age=20

#print the enviroment variable of the current enviromnet, current application
eb printenv

#status of the environment
eb status
status: updating, terminating
health: Grey, Green

#terminate the environment
eb terminate

#list all the git branch
git branch

#change the git branch
git chekcout

#delete the git branch
git branch -d
note: you can not delete the current branch

#to force delte git branch
git branch -D


#merge to master
git checkout master
git merge

How to create controller in yeoman and push to aws elastic bean stalk

yo angular
yo angular:controller testController
..add some directives / views etc..
grunt server -- serves up pages correctly on port 9000
grunt -- which creates the dist folder
reference: http://stackoverflow.com/questions/18325510/how-to-deploy-a-yeoman-build-to-aws-node-js

aws cli configure with aws access key id, secret access key

aws configure
enter access key ID
enter Secret Access Key
Default regio name: ap-southeast-1 #for singpore
Default output format [none]: #nothing

Install AWS cli(command line) on mac?

reference: http://docs.aws.amazon.com/cli/latest/userguide/installing.html#install-bundle-other-os

Requirement:
2.6.5+ or 3.3+

sudo pip install awscli

to upgrade
suod pip install --upgrade awscli

start the node js server

#install node
#npm instal if not exist
#install bower on elastic bean stalk
npm install -g bower
bower install
grunt serve
localhost:9000

How to create AWS instance profile via command line?

1)Create instance profile
aws iam create-instance-profile

2)Attach role to instance profile
aws iam add-role-to-instance-profile

# Create the role and attach the trust policy that enables EC2 to assume this role.
aws iam create-role --role-name Test-Role-for-EC2 --assume-role-policy-document file://C:\policies\trustpolicyforec2.json

# Embed the permissions policy (in this example an inline policy) to the role to specify what it is allowed to do.
aws iam put-role-policy --role-name Test-Role-for-EC2 --policy-name Permissions-Policy-For-Ec2 --policy-document file://c:\policies\permissionspolicyforec2.json

# Create the instance profile required by EC2 to contain the role
aws iam create-instance-profile --instance-profile-name EC2-ListBucket-S3

# Finally, add the role to the instance profile
aws iam add-role-to-instance-profile --instance-profile-name EC2-ListBucket-S3 --role-name Test-Role-for-EC2

What is Amazon instance profile?

if you are using AWS ec2 or AWS serive that uses AWS ec2 then
    you have to store role in intance profile
end

instance profile is container that store role
will attach to AWS ec2.

Create role for AWS service via command line

1)Create role
aws iam create-role

2)attch policy to role

2.1)Attach managed poilicy to role
aws iam attach-role-plicy

or
2.2)Attach inline policy
aws iam put-role-plicy

What is service role in AWS?

Service is role is AWS Role
this is for AWS Service
Through which we grant permission to service.

Services like: AWS ec2, AWS data pipeline, AWS ops work, AWS elastic Bean Stalk.

These resources will access AWS resources.
You can create role to determine what the services is allowed to do with these resources.

Assign the policy to role
This policy can be AWS managed policy
or custom policy
or policy base from AWS Managed policy.

Amazon ec2 instanct type c3.large

c3.large

1-YEAR TERM
Payment OptionUpfrontMonthly*Effective Hourly**Savings over On-DemandOn-Demand Hourly
No Upfront$0$71.54$0.09826%$0.132 per Hour
Partial Upfront$356$32.12$0.084636%
All Upfront$726$0$0.082937%

Create zip from only the files in the folder not the top level forlder , include hiiden files

zip ../mapp.zip -r * .[^.]*

How to delete all documents in collection in Mongo db?

Lets you collection name is dummy

db.dummy.remove({})

How to start mongo db server ?

On mac
sudo mongod

If you  want to change the db storage locaiton
sudo mongod --dbpath


How to change play.http.router parameter in playframework java

referernce : http://stackoverflow.com/questions/31509026/play-2-4-how-do-i-disable-routes-file-loading-during-unit-tests

ex: javauides.tests.routes files map to javaguide.tests.Routes class

Play's route compiler task compiles all files in conf folder ending with .routes as well as the default routes file. Generated class name is always Routes, but the package name depends on the file name. If the file name is routes (the default routes file), compiled class is placed in router package, so the fully qualified class name is router.Routes (which is the default value for play.http.router).
For all other route files, RouteCompiler derives the package name by dropping the .routes from the file name. So for my.test.routesplay.http.router value should be my.test.Routes.
Here is the base class for my tests, with custom router and db configuration elements.
public class MyTestBase extends WithApplication {
    @Override
    protected Application provideApplication() {
        Application application = new GuiceApplicationBuilder()
                .configure("db.default.driver", "org.h2.Driver")
                .configure("db.default.url", "jdbc:h2:mem:play")
                .configure("play.http.router", "my.test.Routes")
                .build();
        return application;
    }
}

What is scala twirl

Twirl is play framework scala based template engine.
https://github.com/spray/twirl

How to write class in Scala

class Point(xc:Int, yc:Int){
 var x: Int = xc
 var y: Int = yc
 def move(dx:Int, dy:Int){
  x = x+ dx
  y = y+dy
 }
override def toString():String = "(" + x + "," + y + ")";
}

android-arsenal find ui components, libraries for android

https://android-arsenal.com/
android-arsenal find ui components, libraries for android

android material design working with tabs

android material design edit text

Android material design tutorial

Coffee tea making machine

Branded coffee tea making machine.
Sell them, you make what you want, use your own materials.

coffee tea making machine branded for small business

Group people of different talent work under product, provide branding, support, calcenter support, operation support, marketing support

Group people of different talent work under product, provide branding, support, calcenter support, operation support, marketing support
Even this support can be any group member.

Chai boy branded franchise network

chai boy will come to your place give chai.
Branded chai
Quality maintained
even takes app, website.
No hassle for chai boy for money collection, record keeping.
no need of company registration for chai boy wala
Just maintain quality.
You don't know about how to make good quality.
We give good chai, you just deliver.
You collect money.


Improve small business man power vehcile 3 cycle by using electricity battery , add design sense, even network them

Improve small business man power vehcile 3 cycle by using electricity battery , add design sense, even network them

collect points for sharing selected item you buy on your social network site

collect points for sharing selected item you buy on your social network site

Coffee day branch applying

https://www.cafecoffeeday.com/lease-enquiry

Mobile Coffeeday machines with battery, solar panels

Coffeeday machine on mobile via battery, UPS, solar power on streets, movable cart

monkey runner android testing

android testing your app
do all the events

http://developer.android.com/tools/help/monkeyrunner_concepts.html

What is QSR companies

fast food companies like McDonald, Subway, ..
They have franchise, supplied matrial franchisers, they sell, collect money from franchiser
Market the product on tv, internet
offers
technology
app, website

Yum brands

Yum! Brands, which operates KFC, Pizza Hut, and Taco Bell in India,” says Gaurav. For KFC, ColdEx manages daily pickups from 80 vendors and delivers frozen goods to six Yum! Brands distribution centres in a -18°C environment.

Promote your product with Working marketing executive as part time

You have good product/servie(website/app/anything)
You need market help, leverage part time marketing exeutive who working in other comapnies.
Even leverage their contact
If you like in future, you can onboard them as full employee.
If he is super talent make him part of founding team

ex: marketing exective in wipro, logistics

AWS Dynamo DB operations

package com.amazonaws.codesamples.datamodeling;

import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;

public class ObjectPersistenceCRUDExample {
    
    static AmazonDynamoDBClient client = new AmazonDynamoDBClient(new ProfileCredentialsProvider());
        
    public static void main(String[] args) throws IOException {
        testCRUDOperations();  
        System.out.println("Example complete!");
    }

    @DynamoDBTable(tableName="ProductCatalog")
    public static class CatalogItem {
        private Integer id;
        private String title;
        private String ISBN;
        private Set bookAuthors;
        
        @DynamoDBHashKey(attributeName="Id")
        public Integer getId() { return id; }
        public void setId(Integer id) { this.id = id; }
        
        @DynamoDBAttribute(attributeName="Title")
        public String getTitle() { return title; }    
        public void setTitle(String title) { this.title = title; }
        
        @DynamoDBAttribute(attributeName="ISBN")
        public String getISBN() { return ISBN; }    
        public void setISBN(String ISBN) { this.ISBN = ISBN;}
        
        @DynamoDBAttribute(attributeName = "Authors")
        public Set getBookAuthors() { return bookAuthors; }    
        public void setBookAuthors(Set bookAuthors) { this.bookAuthors = bookAuthors; }
        @Override
        public String toString() {
            return "Book [ISBN=" + ISBN + ", bookAuthors=" + bookAuthors
            + ", id=" + id + ", title=" + title + "]";            
        }
    }
        
    private static void testCRUDOperations() {

        CatalogItem item = new CatalogItem();
        item.setId(601);
        item.setTitle("Book 601");
        item.setISBN("611-1111111111");
        item.setBookAuthors(new HashSet(Arrays.asList("Author1", "Author2")));
        
        // Save the item (book).
        DynamoDBMapper mapper = new DynamoDBMapper(client);
        mapper.save(item);
        
        // Retrieve the item.
        CatalogItem itemRetrieved = mapper.load(CatalogItem.class, 601);
        System.out.println("Item retrieved:");
        System.out.println(itemRetrieved);

        // Update the item.
        itemRetrieved.setISBN("622-2222222222");
        itemRetrieved.setBookAuthors(new HashSet(Arrays.asList("Author1", "Author3")));
        mapper.save(itemRetrieved);
        System.out.println("Item updated:");
        System.out.println(itemRetrieved);
        
        // Retrieve the updated item.
        DynamoDBMapperConfig config = new DynamoDBMapperConfig(DynamoDBMapperConfig.ConsistentReads.CONSISTENT);
        CatalogItem updatedItem = mapper.load(CatalogItem.class, 601, config);
        System.out.println("Retrieved the previously updated item:");
        System.out.println(updatedItem);
        
        // Delete the item.
        mapper.delete(updatedItem);
        
        // Try to retrieve deleted item.
        CatalogItem deletedItem = mapper.load(CatalogItem.class, updatedItem.getId(), config);
        if (deletedItem == null) {
            System.out.println("Done - Sample item is deleted.");
        }
    }
}

          

Amazon Dynamo DB java maven


com.amazonaws
aws-java-sdk-dynamodb
1.10.26

Singapore Dynamo db pricing

  • Write Throughput: $0.0074 per hour for every 10 units of Write Capacity
    (enough capacity to do up to 36,000 writes per hour)*
  • Read Throughput: $0.0074 per hour for every 50 units of Read Capacity
    (enough capacity to do up to 180,000 strongly consistent reads, or 360,000 eventually consistent reads, per hour)*

Dynamo db FAQ

Dynamo db free quota details

Free Tier*
As part of AWS’s Free Tier, AWS customers can get started with Amazon DynamoDB for free. DynamoDB customers get 25 GB of free storage, as well as up to 25 write capacity units and 25 read capacity units of ongoing throughput capacity (enough throughput to handle up to 200 million requests per month) and 2.5 million read requests from DynamoDB Streams for free.

Migrating from Mongodb to Dynamo db

referernce: https://www.codementor.io/devops/tutorial/handling-date-and-datetime-in-dynamodb


Dynamo Db does not support multiple indexes
It supports only Hash key, hash key + range key only
Does not support native date, DateTime object

Advantage:
No worries of scaling, monitoring, security updates.
average good response.

Use unix time stamp, store as Number
Combine multiple mongo db key if required
Database denormalization
Based on query patter, create schema

Dynamo DB is  NO SQL db

Queries are slow
GetItem call as fast

Terminology
Table , Item, Attribute, Primary Key, hash attribute value, hash and range attribute values
secondary index on non key attibute value

Start the dynamo db locally
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -help
Dynamo db port: 8000

Create table
var params = {
  TableName : "Music",
  KeySchema:[
    {AttributeName:"Artist", KeyType:"Hash"},
    {AttributeName:"SongTitle", KeyType:"Range"}
  ],
  AttributeDefinitions:[
     {AttibuteName:"Artist", AttibuteType:"S"},
     {AttibuteName:"SongTitle", AttibuteType:"S"},
  ],
  ProvisionedThroughput:{
      ReadCapacityUnits:1,
      WriteCapacityUnits: 1
  }
};
dynamodb.createTable(params, function(err, data){

});

TableStatus is should be Active

2)
var params = { TableName: "Music" }; dynamodb.describeTable(params, function(err, data) { if (err) console.log(JSON.stringify(err, null, 2)); else console.log(JSON.stringify(data, null, 2)); });

3)
var params = {}; dynamodb.listTables(params, function(err, data) { if (err) console.log(JSON.stringify(err, null, 2)); else console.log(JSON.stringify(data, null, 2)); });

4)

var
params = { TableName: "Music", Item: { "Artist":"No One You Know", "SongTitle":"Call Me Today", "AlbumTitle":"Somewhat Famous", "Year": 2015, "Price": 2.14, "Genre": "Country", "Tags": { "Composers": [ "Smith", "Jones", "Davis" ], "LengthInSeconds": 214 } } }; dynamodb.putItem(params, function(err, data) { if (err) console.log(JSON.stringify(err, null, 2)); else console.log(JSON.stringify(data, null, 2)); });

primarykey is must, remaining attribute are optional

5)Condition Expressoin

var
params = { TableName: "Music", Item: { "Artist":"No One You Know", "SongTitle":"Call Me Today", "AlbumTitle":"Somewhat Famous", "Year": 2015, "Price": 2.14, "Genre": "Country", "Tags": { "Composers": [ "Smith", "Jones", "Davis" ], "LengthInSeconds": 214 } }, "ConditionExpression": "attribute_not_exists(Artist) and attribute_not_exists(SongTitle)" };

6)Batch insert
var params = { RequestItems: { "Music": [ { PutRequest: { Item: { "Artist": "No One You Know", "SongTitle": "My Dog Spot", "AlbumTitle":"Hey Now", "Price": 1.98, "Genre": "Country", "CriticRating": 8.4 } } }, { PutRequest: { Item: { "Artist": "No One You Know", "SongTitle": "Somewhere Down The Road", "AlbumTitle":"Somewhat Famous", "Genre": "Country", "CriticRating": 8.4, "Year": 1984 } } }
]}

7)Dynamo db data types
String, number, float, map, list

8)
var params = { TableName: "Music", Key: { "Artist": "No One You Know", "SongTitle": "Call Me Today" } }; dynamodb.getItem(params, function(err, data) { if (err) console.log(JSON.stringify(err, null, 2)); else console.log(JSON.stringify(data, null, 2)); });
9)
var params = { TableName: "Music", Key: { "Artist": "No One You Know", "SongTitle": "Call Me Today" }, ProjectionExpression: "AlbumTitle" };
10)
var params = { TableName: "Music", KeyConditionExpression: "Artist = :artist", ExpressionAttributeValues: { ":artist": "No One You Know" } }; dynamodb.query(params, function(err, data) { if (err) console.log(JSON.stringify(err, null, 2)); else console.log(JSON.stringify(data, null, 2)); });

11)
var params = { TableName: "Music" }; dynamodb.scan(params, function(err, data) { if (err) console.log(JSON.stringify(err, null, 2)); else console.log(JSON.stringify(data, null, 2)); });
Operations

12)

var
params = { TableName: "Music", AttributeDefinitions:[ {AttributeName: "Genre", AttributeType: "S"}, {AttributeName: "Price", AttributeType: "N"} ], GlobalSecondaryIndexUpdates: [ { Create: { IndexName: "GenreAndPriceIndex", KeySchema: [ {AttributeName: "Genre", KeyType: "HASH"}, {AttributeName: "Price", KeyType: "RANGE"}, ], Projection: { "ProjectionType": "ALL" }, ProvisionedThroughput: { "ReadCapacityUnits": 1,"WriteCapacityUnits": 1 } } } ] }; dynamodb.updateTable(params, function(err, data) { if (err) console.log(JSON.stringify(err, null, 2)); else console.log(JSON.stringify(data, null, 2)); });

13)
var params = { TableName: "Music", Key: { "Artist":"No One You Know", "SongTitle":"Call Me Today" }, UpdateExpression: "SET RecordLabel = :label", ExpressionAttributeValues: { ":label": "Global Records" }, ReturnValues: "ALL_NEW" }; dynamodb.updateItem(params, function(err, data) { if (err) console.log(JSON.stringify(err, null, 2)); else console.log(JSON.stringify(data, null, 2)); });

15)Automatic counter

15)
var params = { TableName: "Music", Key: { Artist: "The Acme Band", SongTitle: "Look Out, World" } }; dynamodb.deleteItem(params, function(err, data) { if (err) console.log(JSON.stringify(err, null, 2)); else console.log(JSON.stringify(data, null, 2)); });

http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/BestPractices.html

refernce: http://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/GettingStarted.Java.html