Unable to resolve sequelize package

I recently decided to use a more opinionated migrations manager for a new microservice we are building on top of the loopback framework. In my opinion, loopback’s automigrate feature leaves a lot to be desired. After doing some search, we settled on Sequelize. I got started with the instructions on http://docs.sequelizejs.com/en/latest/docs/migrations/. Interestingly enough, I kept getting the following error when I tried to init the sequelize project:

Unable to resolve sequelize package in /Users/looneydoodle/…

After going through the forums and the github issues, I realized the error wasnt really in the code. It was because I had to install the sequelize package separately and it was not set as a dependency for the sequelize-cli package. So I ran npm install sequelize and we were on our merry way.

 

Ruby split ignores empty fields

Came across a little weirdness with the string split function in ruby today. Basically

"a,b,c".split(",") #=> ["a,b,c"] # this is correct
"a,b,c,,".split(",") #=> ["a", "b", "c"] # this is weird

I was expecting the second one to have 2 extra empty fields. After doing some digging, turns out there is a limit param.

If the limit parameter is omitted, trailing null fields are suppressed. If limit is a positive number, at most that number of fields will be returned (if limit is 1, the entire string is returned as the only entry in an array). If negative, there is no limit to the number of fields returned, and trailing null fields are not suppressed.

source: Class: String (ruby 2.1.4)

Essentially, the split function needs to be called with a limit the same way as you would in Scala.

"a,b,c,,".split(",",-1) #=> ["a", "b", "c", "", ""]
 

FLAR Manager, Multi Marker Multi Collada

Marker

I ve been toying around with Augmented Reality a lot lately. I came across FLARManager which is the easiest way to implement AR. Somehow i haven’t found any code out there till now that displays multiple collada files on multiple markers. So, here is my implementation of the concept.

package {

import com.transmote.flar.FLARManager;

import com.transmote.flar.marker.FLARMarker;

import com.transmote.flar.marker.FLARMarkerEvent;

import com.transmote.flar.utils.geom.FLARPVGeomUtils;

import flash.display.Sprite;

import flash.events.Event;

import org.libspark.flartoolkit.support.pv3d.FLARCamera3D;

import org.papervision3d.lights.PointLight3D;

import org.papervision3d.objects.DisplayObject3D;

import org.papervision3d.objects.parsers.DAE;

import org.papervision3d.render.LazyRenderEngine;

import org.papervision3d.scenes.Scene3D;

import org.papervision3d.view.Viewport3D;

public class MultiMarkerMultiDae extends Sprite {

private var flarManager:FLARManager;

private var scene3D:Scene3D;

private var camera3D:FLARCamera3D;

private var viewport3D:Viewport3D;

private var renderEngine:LazyRenderEngine;

private var pointLight3D:PointLight3D;

private var activeMarker1:FLARMarker;

private var activeMarker2:FLARMarker;

private var activeMarker3:FLARMarker;

private var activeMarker:FLARMarker;

private var modelContainer:DisplayObject3D;

private var modelContainer1:DisplayObject3D;

private var modelContainer3:DisplayObject3D;

private var markerId:int;

public function MultiMarkerMultiDae ()

{

// pass the path to the FLARManager xml config file into the FLARManager constructor.

// FLARManager creates and uses a FLARCameraSource by default.

// the image from the first detected camera will be used for marker detection.

this.flarManager = new FLARManager("flar/flarConfig.xml");

// add FLARManager.flarSource to the display list to display the video capture.

this.addChild(Sprite(this.flarManager.flarSource));

// begin listening for FLARMarkerEvents.

this.flarManager.addEventListener(FLARMarkerEvent.MARKER_ADDED, this.onMarkerAdded);

this.flarManager.addEventListener(FLARMarkerEvent.MARKER_UPDATED, this.onMarkerUpdated);

this.flarManager.addEventListener(FLARMarkerEvent.MARKER_REMOVED, this.onMarkerRemoved);

// wait for FLARManager to initialize before setting up Papervision3D environment.

this.flarManager.addEventListener(Event.INIT, this.onFlarManagerInited);

}

private function onFlarManagerInited (evt:Event) :void

{

this.flarManager.removeEventListener(Event.INIT, this.onFlarManagerInited);

this.scene3D = new Scene3D();

// initialize FLARCamera3D with parsed camera parameters.

this.camera3D = new FLARCamera3D(this.flarManager.cameraParams);

this.viewport3D = new Viewport3D(this.stage.stageWidth, this.stage.stageHeight);

this.addChild(this.viewport3D);

this.renderEngine = new LazyRenderEngine(this.scene3D, this.camera3D, this.viewport3D);

this.pointLight3D = new PointLight3D();

this.pointLight3D.x = 1000;

this.pointLight3D.y = 1000;

this.pointLight3D.z = -1000;

// load the model.

// (this model has to be scaled and rotated to fit the marker; every model is different.)

var model1:DAE = new DAE(true, "model1", true);

model1.load("assets/model4.dae");

model1.rotationX = 0;

model1.rotationY = 0;

model1.rotationZ = 0;

model1.scale = 10;

// load the model.

// (this model has to be scaled and rotated to fit the marker; every model is different.)

var model2:DAE = new DAE(true, "model2", true);

model2.load("assets/model4.dae");

trace("model4 loaded");

model2.rotationX = 0;

model2.rotationY= 0;

model2.rotationZ = 0;

model2.scale = 10;

// load the model.

// (this model has to be scaled and rotated to fit the marker; every model is different.)

var model3:DAE = new DAE(true, "model3", true);

model3.load("assets/model4.dae");

model3.rotationX = 0;

model3.rotationY= 0;

model3.rotationZ = 0;

model3.scale = 10;

// // create a container for the model, that will accept matrix transformations.

// create a container for the model, that will accept matrix transformations.

this.modelContainer = new DisplayObject3D();

this.modelContainer.addChild(model1);

this.modelContainer.visible = false;

this.scene3D.addChild(this.modelContainer);

this.modelContainer1 = new DisplayObject3D();

this.modelContainer1.addChild(model2);

this.modelContainer1.visible = false;

this.scene3D.addChild(this.modelContainer1);

this.modelContainer3 = new DisplayObject3D();

this.modelContainer3.addChild(model3);

this.modelContainer3.visible = false;

this.scene3D.addChild(this.modelContainer3);

//------------------------------------------------------------------------- ---------

this.addEventListener(Event.ENTER_FRAME, this.onEnterFrame);

}

private function onMarkerAdded (evt:FLARMarkerEvent) :void

{

trace("["+evt.marker.patternId+"] added");

if(evt.marker.patternId == 1)

{

trace("Pattern 1 Added");

markerAdded(1);

this.activeMarker1 = evt.marker;

}

if(evt.marker.patternId == 2)

{

trace("Pattern 2 Added");

markerAdded(2);

this.activeMarker2 = evt.marker;

}

if(evt.marker.patternId == 3)

{

trace("Pattern 3 Added");

markerAdded(3);

this.activeMarker3 = evt.marker;

}

this.activeMarker = evt.marker;

}

private function onMarkerUpdated (evt:FLARMarkerEvent) :void

{

trace("["+evt.marker.patternId+"] updated");

if(evt.marker.patternId == 1)

{

trace("Pattern 1 Updated");

markerAdded(1);

this.activeMarker1 = evt.marker;

}

if(evt.marker.patternId == 2)

{

trace("Pattern 2 Updated");

markerAdded(2);

this.activeMarker2 = evt.marker;

}

if(evt.marker.patternId == 3)

{

trace("Pattern 3 Updated");

markerAdded(3);

this.activeMarker3 = evt.marker;

}

}

private function onMarkerRemoved (evt:FLARMarkerEvent) :void {

trace("["+evt.marker.patternId+"] removed");

if(evt.marker.patternId == 1)

{

trace("Pattern 1 Removed");

markerRemoved(1);

}

if(evt.marker.patternId == 2)

{

trace("Pattern 2 Removed");

markerRemoved(2);

}

if(evt.marker.patternId == 3)

{

trace("Pattern 3 Removed");

markerRemoved(3);

}

this.activeMarker = null;

this.activeMarker1 = null;

this.activeMarker2 = null;

this.activeMarker3 = null;

}

private function onEnterFrame (evt:Event) :void {

// apply the FLARToolkit transformation matrix to the Cube.

if (this.activeMarker) {

this.modelContainer.transform = FLARPVGeomUtils.convertFLARMatrixToPVMatrix(this.activeMarker.transformMatrix);

}

if (this.activeMarker1) {

this.modelContainer.transform = FLARPVGeomUtils.convertFLARMatrixToPVMatrix(this.activeMarker1.transformMatrix);

}

if (this.activeMarker2) {

this.modelContainer1.transform = FLARPVGeomUtils.convertFLARMatrixToPVMatrix(this.activeMarker2.transformMatrix);

}

if (this.activeMarker3) {

this.modelContainer3.transform = FLARPVGeomUtils.convertFLARMatrixToPVMatrix(this.activeMarker3.transformMatrix);

}

// // apply the FLARToolkit transformation matrix to the Cube.

this.renderEngine.render();

}

//EVENTS FOR ADDED MARKER

private function markerAdded(markerId:int):void

{

trace(markerId);

var x:int = markerId;

switch(x)

{

case 1:

{

trace("1 Yeah");

if(modelContainer1.visible==false)

{

modelContainer1.visible=true;

break;

}

else

break;

}

case 2:

{

if(modelContainer.visible==false)

{

modelContainer.visible=true;

break;

}

else

break;

}

case 3:

{

trace("1 Yeah");

if(modelContainer3.visible==false)

{

modelContainer3.visible=true;

break;

}

else

break;

}

}

}

private function markerRemoved(markerId:int):void

{

var x:int = markerId;

switch(x)

{

case 1:

{

if(modelContainer1.visible==true)

{

modelContainer1.visible=false;

break;

}

else

break;

}

case 2:

{

if(modelContainer.visible==true)

{

modelContainer.visible=false;

break;

}

else

{

break;

}

}

case 3:

{

if(modelContainer3.visible==true)

{

modelContainer3.visible=false;

break;

}

else

break;

}

}

}

}

}

Just link back to me if you use this code. Here is the example of how the code works. Download the marker here.

If it does not load, click here.

 

Tips to the new Entrepreneurs

There will be this one time in life where you get this brilliant idea, a business plan forms in your mind and you have a huge bright bulb glowing above your head. That is your “WOW” moment. Some people are gifted with a lot of these moments and some people are not gifted with them at all. What matters the most is not getting the idea but how well you execute it. Now that’s a Bummer, ain’t it?

I had a lot of those moments and I ve leart a great deal from executing them and not executing them. I have a feeling people need to understand the mistakes that are done commonly even though making an error is the best way to learn. So here are some pointers.

1. The IDEA

This is the most important of all. It defines what you want to do. You need to be clear on what you want to do. You can’t sell cars when you want to be selling spaceships.

2. The Market

You need to understand who your target audience. Not just who they are, but what they do and what they like and dislike. You cant sell chicken to a vegan, if you do – well you ve got great marketing skills. Which brings us to…

3. Marketing

This is not something you learn. This is an instinct. A right word at the right tome can make you a million dollars. You need to do your homework before you set out to market your idea or product. You shouldn’t have a problem if you the two things above right. You ll still require one other thing…

4. Pricing

This is one place you need to be clear about. You need to know at what prices to offer your servuces or products at. It’s not business if you end up making a loss even after you ve got the clients and finished the work on time. New entrepreneurs often find themselves in situations where they have to compromise on the price. This is where you need to get your marketing people to act smart. You need to set the minimum price for the work you will be doing. This should cover all the expenses involved for the whole team that might be involved in it. Everone has to eat, drink and sleep, that is the why they need to work.

5. Training

This is one of the most important part of a job well done. People can’t do something unless they are thaught how to do it. That is why there is so much demand for experienced people in any industry.

6. Satisfy your employees

The important part of getting a team to do their work is to keep the team moivated in all situations. It is okay to make a small investment if that means keeping your people happy and working. Seriously, buy that wii.

7. Keep your promises

Never promise the client that you can get the job done in 2 days if that is all it actually takes. Always leave time to correct errors and to make up for lost time. It’s always better totell the client you will get it done in 4 days and deliver the product early. It reflects on how fast you can get the job done. But this does not work at all times, it’s a risk but a calculated one. If it works you get a lot more business but it doesn’t well, you start all over again.

8. Always respond to your email

On some days, you will get hundreds of emails. On others, you will get none at all. You need to read everything and make intelligent replies to all of them. Be smart, always be nice. You never know when you will need one of them to help you out.

9. Be Organized

There is no alternative to this. You need to be organized at all times, keep your calender up to date. Attend all the events you are invited to. Attend all those breakfast things that people go to. Speak to people, get your brand out there.

10. ASK

You need something done, but you don’t know how to do it. You need to get someone to do something and you are trying to be polite. Well, before you know it, the person would be gone and you would have to go look for someone else who can do it. All it takes to get something done is to ask. There are endless things that can be accomplished by asking. People get huge deals by asking, people get stuff for free by asking. You might get that break you need by asking. SO, ASK.

11. Watch your step

You are your brand. Always watch what you say in public. Everything you say is attributed to your brand. Watch your language at all times, especially if your brand is related to kids in anyway. Watch what you post on the social networking sites.

12. NETWORKING, NETWORKING, NETWORKING.

You need to tell people what you are doing, at the same time you need to know what others are doing. Its all about networking. You know someone who knows someone who knows someone who can get you a deal on something you’ve been searching for. And, before you know it you will be great friends with all those people.

13. Talk to people about your idea

One of the mistakes entrepreneurs do is to keep their idea a huge secret from their friends. You will find that if you tell people about the idea, you get a lot of critics that is very helpful in how you proceed with the plan. But be smart about who you tell it to or someone might just use the idea. Get a lot of views on how you will be executing the plan. Trust me, it helps. A lot of problems in your proposal will be uncovered along with possible solutions.

14. Get some goodies made

People love goodies and handouts. It is one of the most effective ways to market your brand. It might just be an awesome wall paper. It can be as cool as a gadget that you can giveaway. But there has to be something that they(your target audience) can relate to.

15. Have FUN

You are not going to make it big unless you  enjoy what you do. Have fun doing it and there is nothing better.

 

The great showdown with Air India

So i had to go to chennai as soon as possible today to pay my visa fees. Right after i came down from kodaikkanal early this morning, i did a quick search for the earliest flight to chennai and there it was, the airline with whom my flying began about 10 years ago. Little did i know that this was the last time i would be flying with them, to say the least.