Uncategorized

Angular Digest Cycle

Published by:

I am going to explore the Angular digest cycle, which is the process behind Angular data binding. By the end of this post, you’ll understand how data binding works in angular, what is digest cycle, how we trigger digest cycle by calling $scope.$apply() and how exactly digest cycle works.

First of all, let me tell you one thing about Javascript .i.e
Javascript Is Turn Based.
The JavaScript code we write doesn’t all run in one go, instead it executes in turns. Each of these turns runs uninterrupted from start to finish, and when a turn is running, nothing else happens in our browser.
Instead, whenever there is a task that takes some amount of time, such as an Ajax request, waiting for a click event, or setting a timeout, we set up a callback function and finish our current turn. Later, when the Ajax request completes, a click is detected, or the timer completes, a new JavaScript turn is created and the callback is run to completion.

Let’s look at the below code

When the JavaScript code is loaded, that is a single turn. It finds a button, adds a click listener, and sets a timeout. Then the turn is complete, and the browser will update the web page if necessary, and begin accepting user input.

If the browser detects a click on #clickMe, it creates a new turn, which executes the buttonClicked function. When that function returns, that turn is complete.
Now take a look at a very simple AngularJS snippet where you start typing your name into an input field. There is also a div that shows what you typed, in real time:

Whenever the name model changes, the expression automatically updates itself. It’s done just by setting up a watcher on the name model.

Most watchExpressions are created implicitly within AngularJS, but you can also create them manually. Let me show you how to do that:

Note : Here in watch expression we pass newValue and oldValue. When watch expression changes, then the listener function is called. This is also known as dirty checking.

For this strategy to work, we need to know when data has possibly changed, and this is where $scope.$apply comes into play.

The step that checks to see if any binding values have changed actually has a method, $scope.$digest(). But we almost never call it directly, instead we use $scope.$apply() which will call $scope.$digest() for you.

$scope.$apply() takes a function or an Angular expression string, and executes it, then calls $scope.$digest() to update any bindings or watchers.You can also say that it just  starts new javascript turn. Digest cycle executes at least twice.

So, when do you need to call $apply()? Very rarely, actually. AngularJS actually calls almost all of your code within an $apply call. Events like ng-click, controller initialization, $http callbacks are all wrapped in $scope.$apply(). So you don’t need to call it yourself, in fact you can’t. Calling $apply inside $apply will throw an error.

So what happens when we write

1. The directive ng-model registers a keydown listener with the input field. When the input field text changes a keydown event is fired and the corresponding listener is called to handle it.

2. Inside the keydown listener the directive assigns the new value of input field to the scope model specified in ng-model. In our case the model name is updated with the new value. This code is wrapped inside $apply() call.

3. After $apply() ends the digest cycle starts in which the watchers are called. If you have an expression {{name}} in the view it has already set up a watcher on scope model name. So, in digest cycle this watcher gets called and the listener function executes with the newValue and oldValue as arguments. The job of this listener is to update the DOM with the newValue probably using innerHTML.

4. The overall result is that you see the {{name}} updated with whatever you type into the input field instantly.
References:

http://www.thinkful.com/projects/understanding-the-digest-cycle-528/

Notes On AngularJS Scope Life-Cycle

 

Uncategorized

Native vs Cross-Platform apps: The eternal dilemma

Published by:

With Facebook reporting that 90% of their 2015 Q4 monthly active user coming from mobile users (52% from mobile only) mobile apps are truly taking off. In India, a country of 1.3 billion people, mobile phone subscriptions have already reached 1 billion mark. It’s increasingly becoming a norm to have mobile apps which compliment  a business’s website.

With an average person said to be spending at least 90mins a day on his/her smartphone, it’s more important than ever to develop good experiences for mobile users. Mobile devices are truly personal and they offer unique opportunities for businesses to connect with users. But this also comes as a challenge as only 16 percent of users will give a second or third chance to an app which failed to provide a good experience. Users are more likely to download your app if it has a higher rating either in the apple or google play store, which makes developing great user experience in mobile apps a number one priority.

Performance of your app is also a critical feature that cannot be overlooked as users uninstall and leave bad ratings. In fact nearly 59% of users uninstall apps which are slow and 42% say they uninstall apps because they didn’t like the user interface.

Another survey conducted to check how crashes and slow apps have an effect on the user showed following results

user_stats

All this in mind it becomes hard for a company to choose whether to build a native or a cross-platform app.

Now when we talk about cross-platform apps they come in two flavours

  • Cross-Platform apps which are wrapped in web view (Cordova, Ionic etc).
  • Cross-Platform apps which get compiled down to native code (Xamarine, React-Native etc).

Here’s a breakdown on some of the features of both.

Features:

Cross-Platform(WebView) Cross-Platform(Native) Pure Native
Low development time Low development time Moderate development time
Low performance High performance Highest performance
One codebase, no need for multiple type of developers for different platforms One codebase, no need for multiple type of developers for different platforms Need different type of developers for different platforms that you plan on supporting
Can access some of the native functionalities like location service, maps etc, but very limited Can access most of the native functionalities but does not have complete control like native apps Has complete control over native apis and functionalities
UI and UX is mediocre Can build great UI and UX for mid and high end devices Can build great UI and UX for all devices
Support for wearable devices non-existent Support exists for wearable devices, but is very new and trying to play catch up with ever changing native apps Complete support for wearable devices
Support for updating app on fly Support for updating app on fly No support
Does not provide a personalised experience (no support for detecting network speed, contacts etc) Provides a satisfactory personalised experience (support for all native functionalities, but most features are playing catch up and doesn’t provide complete flexibility) Provides a truly personalised experience

The above listed points are some of the most prominent features of hybrid and native apps respectively. So back to the question as to what we should be using, well in theory this is how it should be.

  • If your app is something internal, which doesn’t make use of any core native features like camera, sms etc. and you want to get the app out as soon as possible to most of the mobile platforms go for Web View wrapped cross-platform apps.

  • If your app is complicated and doesn’t require you to build a lot of custom stuff or make use of a lot of native features and ok with compromising on some of the UI features (happens rarely but be prepared for it) go for Cross-platform apps which compile to native.

  • If delivering a great app is your priority and you are willing to invest more time and money for it then go for Native apps.

That being said there are only a handful of apps in the playstore(both android and ios) which have actually been built using cross-platform apps. On the other hand native apps have been tried and tested for a long period of time with ready solutions to a lot of previously faced problems.

Building native apps is always much more reliable than building cross-platform apps and that is one of the most important things when you build a mobile app, because unlike web apps where you can visit any link without any commitment, a user makes a commitment by downloading your app. You need to make sure to provide the best experience possible to value that commitment. Remember it’s almost impossible to gain back a user and the user expects nothing less than a reliable, high-performance app when he/she does download your app.

Development

“How to make your office creative? Caution DIY ahead! “

Published by:

Meanwhile in India and in everywhere else, Internet of Things (IOT) has  been the most discussed technology of this decade. The obsession went to a new level with the IOT trend.

But wait! We are not one of those who moves with the trend. We follow our own, WITH SWAG.

THE INCEPTION:

When we moved to our new workspace, we were happy, energized and excited. Trust me, this new space plays an important role in making CYBORG’s come to office regularly and sign in their presence in the attendance register.

Wait? What Attendance register? Yes, we were missing those sci-fi  bio-metric attendance system in our office which was trending then in almost every offices in India and here we felt the necessity of getting an attendance machine. But, as I said “We are not one of those who moves with the trend. We follow our own, WITH SWAG” thus the birth of an idea took place and we thought of creating such system by ourself.

GATHERING MATERIALS:

It all began when Mr Kunal Singh aka Kunaldo (as called by the machine) had this vision of creating our own sci-fi smart RFID based attendance system. So what next? As we have a idea now, it was the time to search for the heart that will live up the machine. We came up with few options but after understanding the complexity of our system, we found our hero in “Raspberry-Pi” (the credit card size computer) and ordered it from amazon and started exploring it with other modules as RFID Scanner, Matrix sized keyboard, Speaker and LCD. As Kunal also leads the app development team in Cybrilla he had his other works too. While building the system side by side along with his traditional office work, it took him almost a month to make the system breathe, sense and talk. His smart system scans RFID, identifies cyborg and even speaks out their name in order to mark their attendance.

DIY ATTENDENCE REGISTER

DESIGN:

After the compilation of the system we were confused about how to shape the system so that it looks more creative and becomes more handy to handle. After a session of brainstorming, Punith aka “The Designer Cyborg” came up with a solution. He left office with his smartphone which is only used to book a cab and went for the quest of the “Vintage Coin PCO Box” after a long search (not in google but in the local streets of Bangalore) and longer UBER bills he finally found what he was searching for, “the Vintage Coin PCO Box” and thus we found the IDENTITY for the Identity Machine.

INSTALLATION:Cybrilla_DIY_003

It seemed that the wait was going to get finally over and thus there was a sudden rise in the adrenaline levels of other cyborgs too. We all were excited for the attendance system and more for our new ID Cards, which was technically going to be our first ID Card in last six years.

On 1st of Aug we made the new smart system replace the existing traditional register  and trust me the smile that bloomed in every other cyborgs was undepictable and this also added on the list of Why we love to work in Cybrilla?

And at the end, Kunaldo was crowned with million dollar smiles and satisfaction.Cybrilla_DIY_002

Javascript jQuery Organisation ProgrammingTips

jQuery Best Practices- Performance

Published by:

Despite being one of the most popular JavaScript libraries today jQuery has its shortcomings too.

If used carelessly, it can lead to performance issues. This post will list some of the best practices in using jQuery that will help us avoid them.

  1. Limit DOM Interaction 
    There is a cost when manipulating the DOM tree using jquery. So try to limit interaction with the DOM. Lets take a look at the below code:

    Well, no points for guessing whats wrong here. This piece of code works just fine, since the fruits array is of 8 items only. But suppose we had a list of 1000 items, it would really mess up the speed of the website because we are repeatedly appending elements to the DOM, inside a loop.
    Instead of doing this, we can build up a html first and then append it to the DOM.
  2. Handling Events on Selectors
    Though jQuery can select elements very quickly, it is not necessary to search for the same elements many times.

  3. Optimize Selectors
    With the first approach, jQuery queries the DOM using document.querySelectorAll(). With the second, jQuery uses document.getElementById(), which is faster, although the speed improvement may be diminished by the subsequent call to .find().

    Specificity: 
    Be specific on the right-hand side of your selector, and less specific on the left.
  4. Detach Elements to Work with Them
    The DOM is slow; you want to avoid manipulating it as much as possible. jQuery introduced detach()  in version 1.4 to help address this issue, allowing you to remove an element from the DOM while you work with it.
  5. Use Stylesheets for Changing CSS
    If you’re changing the CSS of more than 20 elements using .css(), consider adding a style tag to the page instead for a nearly 60% increase in speed.
  6. Avoid $( window ).load()

    The $( document ).ready() is fired when a page’s own DOM is loaded, but not external assets like images and stylesheets while $( window ).load() is fired when everything a page is made up of, including its own content and its sub-resources are loaded.

    So, if you’re writing a script that relies on a page’s sub-resources, like changing the background color of a div that’s styled by an external stylesheet, only then use $( window ).load() else it’s better to stick to $( document ).ready().

 

Uncategorized

Performing Exercism on Ruby!

Published by:

One day I stumbled upon this awesome site called “Exercism”. It mainly focuses on improving your skills via Deep Practice & Crowdsourced Mentorship, Strengthening your problem-solving skills by guiding others through the process. I got hooked onto it and then I thought why not share my learning with all. Being a Ruby programmer, my notes are Ruby based.

Things To Keep In Mind

Before tackling any program/problem/challenge you should keep certain points in your mind. Some are general, some are more language specific.

Some questions you might want to ask yourself:

  1. Am I adhering to the Single Responsibility Principle?
  2. Is all my code on the same abstraction level?
  3. Can I combine conditional clauses?
  4. How does my API look to clients of this code (i.e. how do other classes interact with this class)?
  5. Do I have duplication?
  6. What requirements are likely to change? Would I be able to implement such changes painlessly? [Note that it is not that you should normally guess what future requirements are, but it can be helpful on Exercism]

Use Private, that way you limit the public API of any class. It’s considered a good practice to expose as few methods as possible, so you don’t come up with a “fat interface” and has to maintain a lot of methods that probably nobody else uses (this is troublesome when you want to refactor your code but you aren’t sure if somebody is using method x or not.

If you are using in-built methods you should understand them first – how they work, what are the pros & cons, in which use-case you should use them. Don’t assume, dig them up. Some examples:

  • p & puts are not the same
    p foo does puts foo.inspect , i.e., it prints the value of inspect instead of to_s, which is more suitable for debugging (for example, you can tell the difference between 1, “1” and “2\b1”, which you can’t when printing without inspect).
  • to_a  is super-expensive on big ranges.
  • Use string interpolation only when necessary.
  • a.map(&:to_i) i.e. Symbol#to_proc  : you are passing a reference to the block (instead of a local variable) to a method. Also Symbol class implements the to_proc method which will unwrap the short version into it’s longer variant. Example:

Some problems from Exercism

I have described what I learned from individual problem. I am also putting names of the relevant problems so that you can look them up. My code is uploaded on Github. Also I have explained why I used certain in-built Ruby methods. I have highlighted some specific things that you should consider in general.

Accumulate

Two ways to yield a block in ruby : yield & call

(Read “ZOMG WHY IS THIS CODE SO SLOW?”)

  • Yield returns the last evaluated expression (from inside the block). So in other words, the value that yield returns is the value the block returns.
  • If you want to return an array use map/select depending on situation. You don’t need to initialize an array & return it.

Anagram

Anagrams are same if sorted.

select  will return element if condition satisfies. So in case of conditions use select  over map / each .

Beer-songs

Follow this link

Binary

Use map.with_index  so that you do not have to initialize another variable & directly apply  inject on the result.

Bob

Start simple. Try to make test pass in a very easy way.

Etl

Use of each_with_object :

Grade-school

Initialize an empty hash and declare values as an array. To sort & return a hash use hash.sort.to_h .

Grains

Sometimes solution could be a single word. Check for patterns. For instance, here you don’t have to iterate 64 separate calculations in self.total. Think about the totals for the first few squares: 1, 3, 7, 15, 31. Now think about those totals in relation to powers of two. Total is a series of (2x-1) where x is 2**(n-1).

Hamming

  • raise  could be another method. Always look out for single responsibility principle.
  • select  &  count  are perfect methods here.
  • It is considered a good practice to expose as few methods as possible, so you don’t come up with a “fat interface” and maintain a lot of methods that probably nobody else will use. This is troublesome when you want to refactor your code but you aren’t sure if somebody is using that method or not. In this exercise, the only method being called is self.compute , so this means you could make self.raise_size_mismatch  private and avoid exposing it.

Hello-world

You can pass default argument to a Ruby method :

Leap

You can minimize loop:

to:

But I won’t prefer it, because the former one is more readable. Sometimes you have to gauge which is worthier.

Phone-number

Interesting use of sub:

Raindrops

Assign common values as constant. Avoid unnecessary computing. For example you only need to check if 3, 5 & 7 are factors.

Robot-name

shuffle  method of Array (can be applied to a-z but will be futile for 0-999 as it takes lots of memory & computation). Use Default assignment  ||=

 

That’s it for now. Please do let me know how this blog helped you and whether I missed something that should be included. Sayonara for now!

Uncategorized

The Coffee Mug Paradigm

Published by:

On 9th Feb, 2016, Cybrilla Product Owner, Nitish Gulati, delivered a Mangalwari Gyan session on The Coffee Mug Paradigm – A Lean Product Management Strategy at our talk space in Bengaluru. His talk is slowly gathering audience and he will be a speaker at Discuss Agile’s Conference. The talk throws light on lean product strategies and agile methodologies. He he describes lean product marketing as a combination of agile & lean approaches.Nitish performed the case study to analyse marketing strategies of startups. The Coffee Mug Paradigm can help product lead companies better understand & implement lean product marketing strategies.

Uncategorized

Not The Best – Just Perfect

Published by:

Cybrilla_Interior
If you search for ‘world’s most awesome offices’, we may not feature(that result is biased in the favour of Google!).

That search result reflects the perspective of certain individuals/publishers. Seen under the light of the morning sun that brightens up the mood early morning and the track lights in the evening, ours might not fall far behind.

Cybrilla Collaboration Desk


And to correct those search page listings on interesting office spaces, this is our honest attempt to making a slight dent in the universe of google search results.

We actually do not compete on fancy lounge spaces, conference rooms etc. Hell we don’t even have those fancy biometric access. Ours becomes a competitive space with the people put together. In my opinion, the garages where HP or Apple began were more iconic than their current offices, so was ours.

Cybrilla Office Inaugration


The office is workshop inspired & a Cyborg made attendance system welcomes you. But it encapsulates all features of a cutting edge system – scans RFID, uses Raspberry Pi (the credit card size computer), scanner, speaker for text to speech conversion and matrix keypad size 3X4 for delivering output in graph & charts.

Cybrilla Reception

We gave a detailed thought to every aspect of design and consulted with one of the best interior designers to create a work-space that has our brand values at its heart. We now have an open space office that provides us the platform to take the company forward.

With growing footprint in the international markets, we needed a space equipped with all the amenities for communication with our overseas clients. Our new office comes equipped with a conference room.

Cybrilla Confrence Room

 As a company we believe in frequent iterations and our discussion room is designed in a manner that facilitates short discussions. The high table is purposefully high, so that we do not sit and keep the meetings short and when we have to, there are high chairs that are not meant for sitting for long. That’s right, we create more – discuss less.

Cybrilla Library & Discussion Room


Similarly, the large desks with capacity to seat entire teams has been designed to achieve greater collaboration. But then, for a short while everyday, you need space, for that we have the solitary room. For relaxing after work we have the kitchen area with pub like seating so that you do not have to leave office to unwind. Stay as long as you like, stay because you like it.

Cybrilla Kitchen


Cybrilla Interior


To keep our team members well read, we have designed a library. To help our mobile first workforce, we developed the Liborg App. The app is built with the functionality to issue books, search books by image, barcode scanning, image issue and the ability to preview any book using search.

Cybrilla Library & Discussion Room


Interestingly, the most iconic office space should be judged on whether it put a dent in its’ industry & not by being ‘Garage Inspired’.

The most iconic as judged are designed in manner that if someone has to stay back for the night, they do not miss home. That validation is subject to circumstances, ours is a welcome space where Cyborgs routinely stay back for Star War Movie Marathons & Counter Strike Nights. 

We have outgrown 5 offices in as many years and every time we moved because of organic reasons and not because we could afford it.

  • The new office is more spacious, in sync with our expertise of scaling up, applications and workforce. Its’ a 3300 sq. foot space with a mix of open space and rooms, crafted to suit the needs of developers.
  • The kitchen is right there with ample space to stock. This ensures the builders of robust applications stay fueled.
  • We have a mini auditorium where people can speak to be heard, especially where Mangalwari Gyan and Meetups which are a regular feature.
  • There are no separate rooms/cabin so that even the CEO knows he’s being watched!
  • The large desks double up as dining tables for the frequent parties.
  • Designed to optimize on daylight.Twinkling Cybrilla In Evening

    We have tried to craft a fun and collaborative work space so that our people – Cyborgs feel addicted to come & stay back. Happy developers equal successful products, which in turn equals happy clients.

    We’re observing a rapid growth here, which means we’ll be able to deliver inspiring products from our inspired office. We’re on a mission to change the world using software as a vehicle and are excited to see what Summer has in store for us. With all this space we’ll also be able to host events at our office, so we’ll be excited to invite people in and show them what Cybrilla is all about.

    If you’re looking to make a career move this Summer, we are hot, why not join us in our brand new office? We’ll be hiring in many more positions in the months to come, so keep checking our latest job openings here.

    Don’t forget you can follow us on Twitter, Facebook, LinkedIn, Google + & YouTube for all the latest news from Cybrilla & Software Industry.


Conference Event Management Open Source Community Organisation

The Conference Way of Achieving Excellence

Published by:

cybrilla_conference_blog_banner

There is a Plethora of blog posts on ‘X things you should do to organise a successful event’, this is the Plethora+1th one, but with a difference.

Two and a half years ago Prakash brought up the idea of organising a regional Ruby conference. Seemed doable. He had organised national level events before, didn’t seem like much of a trouble. One man brought up another and soon we were a team of 8 many programmers tasked to organize India’s first Regional Ruby conference. And thus GCRC – Ruby Conference of Bangalore was born.

Based on experience and proficiency, we delegated domains to ourselves. Swanand, Dheeraj, Prakash, Hemant, Emil, Leena, Tejas, Kashyap and I to name all, were to be accountable for a domain each and juggle in more than one sometimes. The idea was to develop GCRC like a program, in separate modules, compile parts and run. Except that things do not work in that fashion in the real world. Among many others, these are the practical aspects one should not miss.

Don’t Underestimate The Mess of Paperwork

Charged with organization & finance, our first target was to register GCRC as a legal entity. But then it’s not as simple as it sounds. Available resources do not enable easy comprehension by the common man or the software developers. We had to actually write a blog explaining the Visa process as there were many expatriate speakers. Maybe it’s kept that way on purpose, lest we would start taking up our own legal case as law permits. But that debate is for another day.

After having spent a lot of time figuring out the best suited legal entity for the activities GCRC intended to take up, we reached nowhere. Going by the better judgement of our CA, we decided to register GCRC as a trust, only to experience the sceptical nature of the system. It seemed like ‘Satyamev Jayate’ had given way to ‘Only In God we trust, rest have to follow a lengthy process’. Despite the non-profit nature of our endeavour, it took 3 months to complete the registration process. Our tryst with the system did not end there, everything we intended to do fell short of procedural expectations. Even opening a bank account required a lot of patience.

The last 2 years have witnessed easing up of those norms to a large extent. Those who still make a hue & cry about India’s rank in Doing Business Rankings should probably go back to history or be prosecuted for intolerance. That said, there is still a long way to go and India can do better.

My experience taught me that one should accrue due diligence & plan the paperwork as it can take a lot of time.

There are no Free Lunches or Sponsorships

Sponsorship as a word is generally misunderstood in the Indian context. It’s used for a host of meanings ranging from PR opportunity to product placement. GCRC being a community event did not completely fall in any of those categories. The turnaround time for marketing spend was higher, however the returns accrued were even higher over and after a period of time.

It takes a few big sponsors to make an event successful, till then you keep pitching. Every company in the industry was a prospect and that made it even difficult. There were the thrifty, the tight budgeted and the generous, and don’t forget the corporate marketers who want every bang for their buck. Nevertheless, the key to accumulating substantial sponsorship is to start early. Most companies follow an annual budgetary allocation scheme, being cash strapped or sitting on it towards the end of financial year. The likelihood of encountering the latter scenario being rare. Therefore, one should start approaching prospective sponsors as early as they can.

Even though, we were not the first to start looking for sponsorship, We were fortunate to have our share of sponsors.

Vendors are like kids, best dealt with care!

For an event of the scale of GCRC, you need multiple vendors. And there is a separate vendor for Audiovisuals, Delegate Parties, Accommodation, Printing etc. Event management is an area with plethora of service providers. Name the price and there is someone willing to do it. When faced with situations like these, use principles of operations management. Optimization helps you settle.

Irrespective of your choice of vendors and the quality of their service, it’s always advisable to maintain amicable relations with all, you never know who ends up becoming your saviour/provider in future.

Save for Rainy Days & Miscellaneous expenses

Expenses have a habit of exceeding the budget, being frugal helps if you don’t want to end up out of pocket. Probably that is why being frugal in engineering or expenses is such a fad!

No matter how much you plan, there are still likely to be items that you miss out. It’s a financial management best policy to account for them, so is in organisation.

Contribution First, Impressions Second

GCRC was fortunate to attract proposals from leading Open Source Evangelists of the software development world. I felt cursed at a personal level. The responsibility to select few eminent speakers from a host of proposals from across the world was a stressful job. Each proposal was so distinguished that at one point of time we considered picking from the draw of lots. Good sense prevailed and we applied and implemented the ‘Wisdom of the panel’. Wisdom of the panel is also called mutual agreement in common parlance. We selected speakers based on the average of scores allotted by panel members in various aspects like reputation of speaker, topic & its’ relevance to audience. Among other distinguished speakers, we were lucky to have Chad Fowler, General Manager – Wanderlust, Microsoft for the inaugural edition.

Decades of Ivy league hunting has left the corporate world prone to first impressions. It has now become a symbiotic relationship with one casting impression over the other. This impressionability of industry and individuals is leading us to making wrong choices.

Every pebble creates its own ripples, we should take due care in throwing our pebbles.

To err is human, fixing them is organisation

Even after having used your eye for detail or having stressed through those half rimmed eyeglasses, some tasks stay hidden to the normal eye and reveal themselves at crucial moments. We had one such experience with Event T Shirts. There was a communication goof up and we were left clueless while the T Shirts lay pretty with the hotel reception. Though it gave us a sleepless night, things like these happen & there is not much we can do about it. Interestingly, these goof ups seem to be governed by a law, ‘The Murphy’s Law’. So make your plans, execute them, till murphy ruins them!

Memories are your biggest ROI

Despite your best efforts, the probability of an event being successful is always 1/2. Having fun while organising is another independent event where the sample space is having fun while whatever happens. You realise this while trying to write a blog about it and all that you have to refer is a folder on drive. And that gives you one more recommendation.

Always hire a photographer, memories are the biggest take aways and what better way to lock memories than pictures.

 

Javascript ProgrammingTips

Execute a function within a Directive from outside in AngularJS

Published by:

We were working on two problem statements at different points in time of a project and we interestingly found similar solution for both.

Problem A: We have a form, one of the input fields  (defined as a directive) has a clear button. This clears the text in the input field, the data in the ng-model as well as the data held in the variable that gets submitted finally via the form. Now, we have a universal clear button that also needs to clear all the 3 data points.

Problem B: We have a section that has been defined as a directive which can be expanded/collapsed using a toggle button. The expand/collapse is handled by the directive. The initial state of the directive, whether it should be expanded or collapsed, is actually dependent on a value obtained from an API call.

In both cases the common thing that one can notice is that there is an external trigger that needs to be passed on into the directive. In Angular 1.4 there is no direct way to do this. Directives do support two way binding, and passing initial values. But neither would solve the exact requirement in both problems.

The solution that we came up with was passing a control object to the directive. The controller defined a control object, a key of which will be pointing to a function. This object was passed on to the directive, and directive initialised the control object’s key (control object which is two-way bound) with a function that gives access to the variables/functions inside the directive. Being two-way bound, this function is now available in the controller. This can be passed on to anywhere (factory, as it was in case of solution for problem B) or used locally.

Sample code:

 

Uncategorized

Party at Work..Why Not!

Published by:

IMG-20151110-WA0041 (1) (1)

In sync with our policy of celebrating all major festivals and even minor successes, we celebrated Diwali at our ‘Nice View’ office. Diwali, also known as the Festival of Lights is celebrated in verve by lighting Diyas (earthen clay shells with a lighted wick) to signify the triumph of good over evil. Staying true to the spirit of Celebrilla errr Cybrilla, Diwali Party was a congenial affair.

At Cybrilla, we have a vibrant culture that celebrates festivals from across the country. Diwali Party shed light on it through a 100 LED’s as we avoid Diyas and crackers for the love of environment.

From adoring the floor with a beautiful Rangoli, the walls and tables with garlands and flowers to dressing in ethnic Indian wear to ordering everything that is otherwise cooked at home(Yes! we took a few shortcuts). All stomachs looked convex after having been stuffed with Gol Gappas and other delicacies.

The lack of sound of fireworks was soon replaced by the Cyborgs on dance floor who went all footloose dancing to the top charts. The cherry on the cake was the solo performance of Satish Perala, our CEO, who set the bar high for upcoming dance events. It was amazing to see an otherwise code filled evening progress into an amazing night of Cyborg get together. The Diwali Party was yet another gem we would preserve in our memories.