Anonymous Functions - Elixir

In Elixir, functions are first class citizens. What does it mean? It means that functions can be
Assigned to variablesPassed around as arguments to other functions Anonymous functions has no name and no modules. We can create them with syntax fn ->

my_function =fn(param) ->"Passed param: #{param}"end
In order to invoke this function we must use the .() syntax

Named function can take anonymous functions as argument. This helps promote decoupling. A sample example is shown below

defcalculate(first, second, operation) do
operation.(first, second)
multiply =fn(first, second) -> first * second end
addition = fn(first, second) -> first + second end

sum = Maths.calculate(2, 5, addition)
product = Maths.calculate(2, 5, multiply)
The expected value for sum and product will be 7 and 10 respectively. With this example we can conclude that anonymous functions can be passed as arguments to…

Functional Programming - Elixir

I recently came across a Elixir and thought it's a nice time to talk about it. Elixir is a programming language created in 2012 and is designed to build scalable and maintainable applications. It has following features
Functional - language is completely based on modules and functions. There are no classesDynamic - it is dynamic language. There is no need to define type while creating a variable. They are automatically assigned during run time.Compiled - source code of a elixir file (.exs) is compiled to byte codeDistributed and Concurrent - can run quickly and independentlyRuns on Erland Virtual Machine (BEAM) - highly stable and mature What is it used for? Elixir is a general purpose language especially suitable for Data ProcessingNetwork applicationsHigh Availability System Functions All named functions in Elixir must be a part of an enclosing module. A sample function declaration is shown below
defmyFunction(first_param, second_param)
first_param &…

Google Chrome Extension - ReactJS

An extension is a zipped bundle of files (HTML, CSS, Javascript, images etc). It allows us to add functionality to chrome without deeply diving into native code. They can interact with servers through XMLHttpRequest (ajax) and if we wish to read (or modify) HTML from existing web page then content script allows us to do so.

Google has already done a great job with documentation and you can find a "Getting Started" guide here.
Let's Start We are going to develop a simple extension which will show us the weather for selected city. We will be developing a single page application using ReactJS which will target weather API using XMLHttpRequest and then with help of plain old javascript we will process the JSON response to update UI.

You can find source code of this application on Github under "app" folder.
Packaging From the "app" folder you can extract the code for our single page application. This is the core of application and all UI logic is manag…

UI Build and Deployment

using grunt to automate build and deployment What is Grunt? There are many references available online to describe this question but to keep it very simple, Grunt is a Javascript task runner which allows us to automate task such as compilation, minification, unit testing, linting etc.
Iteration 1 - A Sample Application: To start with, we will be referring to a very simple UI application which shows an alert on page load. It can be downloaded from here. It contains three folders
csshtml andjavascript On this application we will be adding below tasks for Grunt automation
JS Lint,JS Minification,CSS Minification andHTML Compression Iteration 2 - GruntFile.js: To begin with any Grunt based setup we need to create a file "Gruntfile.js". Its a simple JavaScript file which define various tasks which can be executed during our build phase.
// a sample Grunt File module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), uglify: …

Angular JS, Require JS and Karma

Initial project setup and unit test cases using Mocha and Chai A TODO Application We will be writing a sample TODO app which helps our users to remember important tasks. During the process of development we will go through various concepts of AngularJS and how it can be used with RequireJS for dependency management and lazy loading of javascript files.

To keep our code in best possible quality, we will be relying on unit cases (and plenty of it) using Mocha and Chai which will run on Karma
Iteration 1 - Setup: To start with any angular js application we need to create a HTML page with all the css and javascript depenendencies defined. We will include below dependencies on our HTML
1.  Bootstap CSS2.  Angular JS3.  Require JS Our end result should look like below:
<html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device…