Data filtering based on multiple checkboxes in AngularJs. [HowTo]

Ok, this is just a quick post with some small pieces of code which shows how to filter data, to be precise a json object and present them in view. As you already know AngularJs is powerfull stuff, and this lines of code prooves that one more time. Have a look:

First the html:

<html ng-app="myApp">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script type='text/javascript' src="car.js"></script>
<body style="font-family:Verdana; font-size:14px;">
<div ng-controller="MyCtrl">
	<h4>Pick a brand to see the models</h4>
    <div ng-init="group = (cars | groupBy:'make')" style="width:100%">
        <div ng-repeat="m in group"   style="width:100px; float:left;">
            <b><input type="checkbox" ng-model="useMakes[$index]"/>{{m}}</b>
        </div>
    </div>
    <div style="clear:both;"></div>
    <div>
        <ul>
			<li  ng-repeat="car in cars | filter:filterMakes()"><p><b>{{car.make}} - {{car.model}}</b></p></li>
        </ul>    
    </div>
</div>
</body>
</html>

And the javascript below:

var myApp = angular.module('myApp',[]);

function MyCtrl($scope, filterFilter) {
    $scope.useMakes = [];
    
    $scope.filterMakes = function () {
        return function (p) {
            for (var i in $scope.useMakes) {
                if (p.make == $scope.group[i] && $scope.useMakes[i]) {
                    return true;
                }
            }
        };
    };
    
    $scope.cars = [
        {model: '316', make: 'Bmw'},
        {model: '520', make: 'Bmw'},
        {model: 'Fiesta', make: 'Ford'},
        {model: 'Focus', make: 'Ford'},
        {model: 'Clio', make: 'Renault'},
		{model: 'Toledo', make: 'Seat'},
		{model: 'Leon', make: 'Seat'},
		{model: 'Insignia', make: 'Opel'},
		{model: 'Astra', make: 'Opel'},
        {model: 'Corsa', make: 'Opel'}
    ];    
}


var uniqueItems = function (data, key) {
    var result = new Array();
    for (var i = 0; i < data.length; i++) {
        var value = data[i][key];
 
        if (result.indexOf(value) == -1) {
            result.push(value);
        }
    
    }
    return result;
};

myApp.filter('groupBy',
            function () {
                return function (collection, key) {
                    if (collection === null) return;
                    return uniqueItems(collection, key);
        };
    });

So as you can see the most important part is the creation of the filter groupBy. By creating this filter we can add it in the ng-repeat like this ng-repeat=”car in cars | filter:filterMakes()” and it checks each car in the json object.

Result

angularjs checkbox filterSee it live here: http://jsfiddle.net/rzgWr/123/

 

Add a TFT Display to your Arduino projects (1.8 TFT SPI 128×160)

In all my arduino projects I was using cheap 1602 LCDs mostly because… they are cheap but also of the libraries flexibility.  Recently I found a nice TFT 1.8 inch 128×160 in a very competitive price and i thought to give it a go.  Just $4.5.

arduino_tft_128x160a

 

arduino_tft_128x160b

I had a little bit of trouble to make it work because you need to use a specific version of UTFT. You will find all the files at the bottom. Connection is easy enough just don’t forget to add 1KOhm resistors to all data lines.

-Connect to LCD_Pin SDA/SDI/MOSI(it means LCD_Model Pin_SDA/SDI/MOSI Connect to Arduino_UNO Pin11)
-Connect to LCD_Pin SCL/CLK/SCLK(it means LCD_Model Pin_SCL/CLK/SCLK Connect to Arduino_UNO Pin10)
-Connect to LCD_Pin CS/CE(it means LCD_Model Pin_CS/CE Connect to Arduino_UNO Pin9)
-Connect to LCD_Pin RST/RESET(it means LCD_Model Pin_RST/RESET Connect to Arduino_UNO Pin12)
-Connect to LCD_Pin RS/DC(it means LCD_Model Pin_RS/DC Connect to Arduino_UNO Pin8)
-Connect to LCD_Pin VCC and BL to Arduino 5v
-Connect to LCD_Pin GND to Arduino GND

 

IMG_20140528_220600

And here is a short demo

http://www.youtube.com/watch?v=uxjhD3Z20nA&list=UUXyVgABpnlyTj-pnHvdiySQ

I bought mine from Bangggood.com but you can them in ebay or in other chinese eshops.

Download the datasheets,diagrams,library and demos here.

AngularJs mini online course

angular-js-preview

Through 12 videos Gregg Pollack will teach you AngularJs, from basic stuff to custom directives and services. This course is free and it will be a shame if you loose it.

Learn to use Angular.js by adding behavior to your HTML and speeding up your application’s responsiveness. Get ready to dive into all the angles of Angular.js!

Link: https://www.codeschool.com/courses/shaping-up-with-angular-js

Arduino Zero

ArduinoZero

 

New member in the Arduino family. His name is Arduino Zero and it brings some features that was missing from previous arduino boards. The most important is the Atmel’s Embedded Debugger (EDBG), which provides a full debug interface without the need for additional hardware, significantly increasing the ease-of-use for software debugging. The board is powered by Atmel’s SAMD21 MCU, which features a 32-bit ARM Cortex® M0+ core. Below is the list of specs:

Microcontroller ATSAMD21G18, 48pins LQFP
Operating Voltage 3.3V
Digital I/O Pins 14, with 12 PWM and UART
Analog Input Pins 6, including 5 12bits ADC channels and one 10 bits DAC
DC Current per I/O Pin 7 mA
Flash Memory 256 KB
SRAM 32 KB
EEPROM up to 16KB by emulation
Clock Speed 48 MHz

Links: http://arduino.cc/en/Main/ArduinoBoardZero http://blog.arduino.cc/2014/05/15/meet-arduino-zero/

 

Arduino_Zero_front450

Arduino_Zero_Rear450

Become an Expert with Ionic

ionic-html5-native-framework

Ionic framework day by day becomes more and more popular. It has really nice features and if you plan to start developing apps for mobile devices then definitely you need to check it. Maybe as a beginner the most difficult part will be to set up the environment but when everything is ready working with Ionic will be really easy. Check the video tutorials in this link: http://learn.ionicframework.com/

Books I’ve read in 1st quarter of 2014

Working in IT sector means that you have to spend considerably amount of your time in educating yourself if you want to be up to scratch. I am sure you have seen it yourself that everyday people above you demand more and more. Of course if you are like me, a lifelong learner, then every time you finish reading a book you have that nice feeling that you achieved something. So I am starting these post series with my small reviews about some of the books I’ve read in the past months.

In these first three months of the year I read 6 books. Most of them were disappointing but a couple were good enough to be suggested. Lets see the list:

 Dependency Injection with AngularJS

Dependency Injection with AngularJS

This one is probably the worst of all. I still can’t believe how you can make so many mistakes in only 78 pages. The subject of the book supposed to be dependency injection in AngularJs but this is only a few poorly written pages(if I remember well, less than ten!). The rest is about general development with AngularJS. Clearly Alex Knox is not a professional writer. Amazon reviews confirms my words. Mark 1/5. Price:~ 18£ Amazon link

Instant Ubunt

Instant Ubuntu

Working as a developer doesn’t mean that you have to read books only about development, at least this is my point of view. I really want to have knowledge in other areas of IT. I am not saying that I want to be specialist in everything, its impossible after all, just that I feel better when in a chat with colleagues from other IT departments I understand what they are talking about and I can easily jump to the conversation to give my input. Said that  few weeks ago I thought that reading the book “Instant Ubuntu”  will be a good idea to understand better the Ubuntu OS. I’d say it was a complete failure. Not because of the book, but because of my expectations. This book is clearly written for very very beginners to Linux/Ubuntu OS. It would be great to give it as a Xmas gift to your father who is just going to try something except Windows for the first time in his life. It has many screenshots and some good explanations but that’s it. After all what did I expect from a 54 pages “book”. Mark 2/5. Price:~13£ Amazon link

Software Development Fundamentals (MTA98-361)

98-361-mta-software-development-fundamentals

This book was my main studying source for the Microsoft exam MTA 98-361. As a web developer my knowledge in developing Windows applications or Windows services was limited. By reading this book it really helped me to understand those areas and best of all it helped me to pass the exam! The book has 6 chapters, Introduction to programming, Introduction to Object-Oriented programming, Understanding General Software Development, Understanding Web applications, Understanding Desktop applications and Understanding Databases. I recommend this book to junior developers or to students that want to follow a carrier as software developers. It is very well written and I noticed only a few typos. Mark 4/5. Price: ~ 40£ Amazon link

Instant Selenium Testing Tools Starter

Instant Selenium Testing Tools Starter

I really wanted to learn more about Selenium, in fact I wanted to get a better understanding and some useful technics in order to apply them mostly to my personal projects. Unfortunately this book is not what I wanted. It starts with some basic usage of selenium and then out of nowhere it drops the reader to Java code blocks. I would like to give it a second read but for the moment it didn’t help me at all. Probably because I am working on a different environment. Mark 2/5. Price:~13.5£ Amazon link

The Problem with Native JavaScript APIs

The Problem with Native JavaScript APIs

I am not really sure if we can call book a 16 page “book”. It would have easily be a great blog post. Anyway, the reason I decided to spend an hour before going to bed with it was because Nicholas Zakas, the writter, is one of the very best developers out there, with deep knowledge in JavaScript language and I always enjoy his books. In this one he express’s his views about the use of Native javascript Api’s and I have to admit that I agree with most of his words. Mark 3/5. Price: free Kindle edition Amazon link

Raspberry Pi Cookbook

Raspberry Pi Cookbook

That was the best book I read in this quarter. I really enjoyed every page of it. If I remember well I’ve read it in just 3-4 days. It is very well written and the idea to learn through recipes is innovative. By reading this book you can become an expert in Raspberry Pi even if you are at a  beginner level at the moment. You will also learn some basic electronics by reading it. I totally recommend it and it will always have a place on my desk in my lab as a quick reference. Mark 5/5. Price:~15£ Amazon link

Books books books! Microsoft’s free ebooks

MVA-00-Free-eBooks-banner-green-730x120

I don’t know about you but speaking for myself free goodies are always welcome! The last few days added a category in Microsoft’s Virtual Academy in which you can find  plenty of free ebooks ready to download in several formats. Categories are Windows Server, Windows Azure, Windows, App Development, Microsoft System Center and Misc.

Link: http://www.microsoftvirtualacademy.com/ebooks

Intel MinnowBoard Max at $99

Surprise surprise! Intel announced the new MinnowBoard Max BUT this time at a really nice price. From $199 down to just $99! This version has an Atom E3800 series and Intel HD400 vga. You can run Linux or Android 4.4 and 1gb of Ram should be enough for most of the applications. There will also be another version with dual core Atom and 2gb’s of Ram for “extreme” users. Dimensions are down to 3.9 inches square.

intel_minnowboardmax3MinnowBoard_MAXintel-atom-e3800-diagintel_minnowboardmax_lsio

  • Processor — Atom E3800 (Bay Trail-I) with Intel HD 4000 Graphics:
    • Single-core E3815 @ 1.46GHz (5W TDP)
    • Dual-core E3825 @ 1.33GHz (6W TDP)
    • Dual-core E3826 @ 1.46GHz (7W TDP)
    • Dual-core E3827 @ 1.75GHz (8W TDP)
    • Quad-core E3845 @ 1.91GHz (10W TDP)
  • RAM — supports 1GB, 2GB, or 4GB DDR3 RAM
  • Flash — 8MB SPI flash (for UEFI/Coreboot/etc.)
  • Coastline I/O:
    • MicroSD slot
    • Micro-HDMI port
    • Gigabit Ethernet port (RJ45)
    • Dual USB ports — 1x USB 3.0 host; 1x USB 2.0 host
    • 1x SATA 3Gb/sec port
  • Expansion connectors:
    • Low-speed connector (26-pin) — SPI, I2C, I2S audio, 2x UARTs (TTL-level), 8x GPIO (2x supporting PWM), +5V, GND
    • High-speed connector (60-pin) — 1x PCIe Gen 2.0 lane, 1x SATA 3Gb/sec, 1x USB 2.0 host, I2C, GPIO, JTAG, +5V, GND
  • Other features — serial debug port (header); firmware flash port (header); heatsink; ACPI 5.0 support
  • Operating temperature — 0 to 70°C
  • Power — 5VDC
  • Dimensions — 99 x 74mm (3.9 x 2.9 in.)
  • Operating system — Debian GNU/Linux; Yocto Project Linux; Android 4.4