Showing posts from 2016

Introduction to Hadoop

I am new to Apache Hadoop, here are brief notes on my Hadoop and related technologies learning. First, I share the key ideas from Hadoop basics. Life without Hadoop? For computing and storage intensive tasks, single processor or even multi-processor computer is not enough, because it would take long to process millions of tasks on Peta Bytes of data. The cheapest way to improve the performance is utilizing tens or hundreds of computer connected to Local Area Network. But to use computers connected to LAN, we have to write program that would transfer data on them and copy the program on all computers too. Then we need to decide what chunk of records should be processed on which computer on network, that means more programming to manage task distribution. We also have to use socket programming or MPI or RMI or EJBs or DCOM type approaches to make other computers to receive and process the data. Its all doable but its low level programming in a sense thats its not the primary task in-hand

ACM Inter Collegiate Programming Contest - UMT Lahore

This post is a call for participation for ACM Inter Collegiate Programming Contest which is regional level contest for World Final to be held in the US in May 2017. I would strongly urge you to register your teams before the deadline 16th November 2016. Furthermore, I would request you to please share this message in your circles. This will certainly help us finding the best team of the country to represent us in the world finals. Event: ACM ICPC Venue: UMT, Lahore Registration Deadline: 16th November, 2016 Event First Round: 19th November, 2016 (Online) Event On-site (Pakistan Final): 26-27th November, 2016 World Final in US: May 2017 ------------------------------------------------------------------------------------ ACM-ICPC, the Association of Computer Machinery – International Collegiate Programming Competition, Regional contest i.e. ACM-ICPC Lahore Regional 2

Problems with Current Style of Education - In Universities

I am teaching for couple of years and I strongly feel about following aspects should be improved. ( Please note, these are my personal opinions and nothing to do with my current employer. No offence intended.) In classroom of mostly private universities, some students are highly motivated to learn and go an extra mile what is taught to them, but teacher waste their energy and time by teaching them same material that is taught to whole class. I strongly believe, 10-15% students in class can learn same stuff in 1 month that a teacher teach them in 5 months. Model sections or video based training may be more beneficial for these motivated folks). First tier universities don't have such issue as because of higher merit that attract same level students or who differ with at lower degree. Same issue hold with students who need to put more energy to absorb the delivered content. Mostly teachers instruct keeping the average student in mind or expect an good enough level of prior understand

Laravel 5.2 Eloquent Insert Row or Add Record

Introduction to Eloquent Most of applications code is based on Object Oriented Design but the database contains tables and relations and return set of rows instead list of objects. So there is inhereit mismatch between application code and database artifacts. Different Lanaugage provide object relational mapping (ORM) technologies that fill this mismatch gap. Eloquent is ORM that is used by Laravel. Eloquent is used to interact with the database to perform select, insert, update and other database operations. We create model calsses corresponding to every table. Each Model class help in performaing database related operations with associate table. You must know what are migrations and how setup database for Laravel applications to proceed further. Create Model Class By default the model classes are located in 'App' folder. If you see you Laravel application's App folder you will see a User.php file, its already created model class by Laravel. Migration for users table are a

How to Get Request Data in Laravel 5.2

This post explain how to get request data in routes.php file and in Laravel 5.2 controllers. The request data includes the parameters submitted via URL query string e.g. /search?category=furniture, here category  is parameter name and furniture is parameter value. If a form is submitted via GET or POST, the data that is sent to server is also called request data. In short, request data is data that a request carries. When Laravel framework receive an HTTP request, before transferring request processing to controllers, the framework extract data from request and instantiate an object of type Request , which is Laravel provided class. The Request object contain all the data that HTTP request carries. The Laravel framework passes the object using dependency injection into controller methods. It is passed only if we have expressed our interest by declaring an argument of type Request in controller methods. After receiving the Request object as argument, we can read the parameter valu

How to Get Route Parameters in Controller of Laravel 5.2

Requests in Laravel can contain data in two different ways i.e. as URL route parameters or as request parameters. This article explains how to get URL route parameters inside controller. The Route Parameters are those which are submitted as part of the URL Pattern. Assume users access the url /users/search/lahore.   Here we can treat "lahore" as route parameter for city. Inside Controller we must get city name in a variable so that we can query database for users living in Lahore. To get route parameters, we define appropriate URL pattern in routes.php file. Lets see the mapping for above URL in routes.php file and how we would receive the variable inside controller. Route::get('/users/search/{city}', 'UsersController@search'); We can receive the value of city placeholder inside controller by declaring just an argument in search method, as below: namespace App\Http\Controllers; class UsersController extends Controller { public function search($c

How to Return View from Controller in Laravel 5.2

In previous tutorial , I explained the different operations that a controller performs in Laravel. We also learned how to make hello world controller that return some text to user. In this post, I would explain how to make controllers that return view template. I would also explain how we can pass data to view templates from the controller. In HelloWorldController, we looked at how controller can return short string to browser. In real applications, controller render response using views which are defined outside the controllers. These views are located at /resources/views folder of your Laravel application. After a controller has done its working e.g. interaction with model etc. Controller select a view and send its contents to browser. Remember, views are just PHP files that contains PHP, HTML, CSS etc. To demonstrate above concepts, below I create UsersController. C:\wamp\www\laraveltutorials>php artisan make:controller UsersController Controller created successfully. H

Laravel 5.2 Hello World Controller Example

Lets first see what a controller is and what task it performs, then I would make a simple controller that prints hello world message to browser. Controller is core component in MVC architecture. A controller in Laravel perform three major tasks: Controller interpret the request i.e. extracting request and URL route parameters Controller interact with application persistence state, called Model. Model is not limited to database; interacting with caches, indexing servers, directory servers, file store, or even third party APIs is all part of persistence state related operations. Controller do not perform these operations itself, it calls other software module or components e.g. services or data access objects to communicate with persistence state. Based on URL, request & route parameters and results returned by Model, controller renders response to user. Controller render the response using one of these approaches: Controller passes data retrieved from model to view template

Laravel Routing / Routes.php Tutorial with Examples

All MVC Frameworks provide some mechanism to define rules that are used to map different requests to corresponding controllers. In Laravel MVC Framework, we define these rules in routes.php (located in http\Http folder) file to map different URL patterns to controllers. I assume you have created your first laravel project. Here I explain how to define mapping rules in routes.php file. Simplest Routing Rule Route::get('/hello-world', function () { return "Hello World"; }); Laravel provide a class with different static methods e.g. get, post etc. The method name tells about the type of HTTP request (get, post, ...) for which the rule is defined. The first parameter is URL Pattern, means what a user enter in the browser address bar after the context path or domain name. Here "/hello-world" pattern shows this rule would be used to process or delegate requests coming from domain-name/hello-world pattern. The 2nd parameter can be a string