Tuesday, March 31, 2015

Microsoft IOT DevCamp in Pune & Hyderabad

Microsoft DevCamps are no-fluff events for developers, by developers. You learn from experts in an interactive way and then get to apply what you’ve learned.
.
Our upcoming IoT DevCamp will show how to use Microsoft's Azure services (specifically Event Hub, Streaming Analytics, and Web Sites) in the context of a full end-to-end IoT solution. The lab currently includes a sensor/gateway approach with low-cost Arduino devices as the sensor end-point, and Raspberry Pi as the gateway. A dummy Windows console gateway is provided for those who wish to focus solely on the Azure solution.
.
Participants are also encouraged to bring their own devices to hack, and learn to connect to Azure. At the end of the session, you will have a good end-to-end understanding of a typical IoT solution.
.
  Topics that will be covered:
.
IoT overview, architecture, Microsoft platform
Event Hubs 
Azure NRT
Devices (Arduino, Raspberry Pi, etc.)
.
   Instruction, demos, equipment and hands on labs will be provided in class.
When & Where
.
.
City:
.
Pune
.
Date:
.
29th April 2015
.
Timings:
.
9:00 am - 6:00 pm
.
Venue:
.
The O Hotel, North Main Road, Koregaon Park, Pune 411001
.
.
City:
.
Hyderabad
.
Date:
.
24th April 2015
.
Timings:
.
9:00 am - 6:00 pm
.
Venue:
.
Radisson Hyderabad Hitec City, Gachibowli, Miyapur Road, Hyderabad 500032
.
.
Pre-requisites for pre-event online
briefing:
.
You should be IoT Start-ups or IoT enthusiasts having a working knowledge of Embedded/IoT/System on Chips devices.
.
Details about the pre-event online briefing will be sent by email a few days after you register. Attendance is required.
.
.
Pre-Requisites for the Event:
.
A Laptop with Visual Studio 2013 Update 4
.
Microsoft Azure Subscription (MSDN, BizSpark, Trial, Pay-As-You-Go or Company/Individual Account)
Explore the world of Azure with IoT

Microsoft Office 2013 - Upto 15% off

Today is the last day to register for Microsoft Office 2013 and get discounts of up to 15%. This is valid only for Small and Medium Businesses. Find your cloud partner here.


Monday, March 30, 2015

Microsoft Azure App Service Now available

Microsoft recently announced the Azure App Service which helps developers deliver cross-platform, cloud-connected apps faster. This solution integrates the Microsoft Azure Websites, Mobile Services and Biztalk Services into a single service with a common app hosting, runtime and extensibility model, enabling simplified integration with popular consumer and commercial services and on-premises systems, all for one low price.
Read more here. 

Windows 10: Windows Insider Hub

I have been using Microsoft Windows 10 for over two month now. Cortana is a big help and right now I am more or less using it as my "Search" cum "Run-as" feature. The side notification center situated on the task bar is a big help. Quick look up and turning features and settings of my machine on-off. The outlook and calender apps are the most used one at the moment as I could not find much exciting otherwise there. The good news Microsoft will update this to the RTM version of Windows 10 for free. Anyways with VS2014 community edition now also free its good for developers. 

One great thing about the Windows 10 preview built is the Windows Insider Hub app, through which you can give feedback and suggestions directly to the Microsoft team, which is really really cool. I can up vote on features requested by others which they would like to see. There are different categories under which you can directly provide your views and must haves directly to the concerned teams. 

Saturday, March 28, 2015

R: Selecting unique values out of dataset

Many a times you have a dataset or a column which has a range of values and you wish to know the domain or range of values the column assumes. To do so run the following command:
>  y<-c('A', 'A','A','A','B', 'B','B','B','B','B','B','B','B', 'C','C','D','D', 'E','E', 'E','E','E' ,'E','E','E' ,'E','F','F','F', 'F','F', 'F','F', 'F','F')
> levels(factor(y))
[1] "A" "B" "C" "D" "E" "F"
> unique(y)
[1] "A" "B" "C" "D" "E" "F"

Wednesday, March 25, 2015

Windows 10 preview build Updates

I must say that when I installed and ran the first publicly available build of windows 10 announced in January this year, I was a little upset with the performance of the system. It ran so many apps and processes in the background that the machine felt sluggish and slow and non-responsive.

You had to keep it running for few minutes after boot before you could start working on it. This was a total turn off. With the recent updates it started running a lot better. No more background CPU hogging processes. Hope the improvements keep on coming.

Sunday, March 22, 2015

Renumbering rows after ordering in R

Many a times after data cleaning and reordering, the dataset row numbers get jumbled up. To solve the issue simple run the following command:

> row.names(myDataFrame) <- 1:nrow(myDataFrame)

Happy programming!!

Thursday, March 19, 2015

R : Adding column names to data

Sometimes you have a huge data with multiple fields and the data stored in your file is not marked with header information (i.e. column names).
To add column names to your data frame or matrix after it is read into a variable run the following command:

> CustColName <- c("time", "Age", "Surname", "Standard", "RollNo", "Name")
> colnames(StudData) <- CustColName

R : Removing empty rows from Data

Often the data we have collected in R has empty rows or has some rows which have the interesting or mandatory columns missing or NA.

To remove such rows from your data run the following:
 myDF <- myDF[!is.na(studentData$RollNo),]

Wednesday, March 18, 2015

R : Subsetting data

To subset a data frame or matrix:


> x <- c(1,2,3,4,5,6)
> y <- c(3,5,2,4,1,4)
> z <- c(2,3,4,3,2,1)
> dataF<-data.frame(x,y,z)
> dataF
  x y z
1 1 3 2
2 2 5 3
3 3 2 4
4 4 4 3
5 5 1 2
6 6 4 1
dataF[2,]
  x y
2 2 5
dataF[2:5,]
  x y
2 2 5
3 3 2
4 4 4
5 5 1
dataF$x <- NULL
dataF
  y
1 3
2 5
3 2
4 4
5 1
6 4




If you are beginning with the R language, and need tips and help feel free to put down a comment below. 

Sunday, March 15, 2015

R: Renaming Row numbers (Identifiers)

Many a times in R you have a dataset for which R provides a default numerical representation for identifying the individual rows :

> myData <- cbind(x = 3, y = c(4:1, 2:5))
> myData
     x  y
[1,]  3  4
[2,]  3  3
[3,]  3  2
[4,]  3  1
[5,]  3  2
[6,]  3  3
[7,]  3  4
[8,]  3  5
If you want to rename the rows as per your needs, you can do so by running the following command:

> dimnames(myData)[[1]] <- letters[1:8]
> myData
   x y
a  3  4
b  3  3
c  3  2
d  3  1
e  3  2
f  3  3
g  3  4
h  3  5
Happy programming!

Thursday, March 05, 2015

R: Appending rows to create new data (appending columns)

If you have a requirement of appending rows from different sources to create a new data row (for eg. Professor and Department he works in, to create an information snippet) here is the simplest trick, use cbind:

> profSharma<-professors(professors$Pid==3,)
> phyDepartment<-department(department$Did==19,)
> cbind(profSharma,phyDepartment)
Happy Programming!

Friday, February 27, 2015

R: Removing columns from a Dataset

If you need to remove certain columns from your dataset, you can do it the following way:

> iris[1:5,]
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa
4          4.6         3.1          1.5         0.2  setosa
5          5.0         3.6          1.4         0.2  setosa
> iris[,-5][1:5,]
  Sepal.Length Sepal.Width Petal.Length Petal.Width
1          5.1         3.5          1.4         0.2
2          4.9         3.0          1.4         0.2
3          4.7         3.2          1.3         0.2
4          4.6         3.1          1.5         0.2
5          5.0         3.6          1.4         0.2
> 

Monday, February 16, 2015

R : Using grepl

Sometimes the need is for selecting and displaying all columns of a dataset except for 1 or 2 columns.
Identifying the columns by index no may not always be possible. If the data is correctly labelled and column names are aptly named, then using index number hinders the code readability. To overcome such scenario use the following code:

 > studentData <- data.frame(ID=paste0("Student",1:50),
+                           Math=sample(100,50),
+                           Science=sample(100,50),
+                           History=sample(100,50),
+                           Final=sample(100,50))
> studentData
          ID Math Science History Final
1   Student1   15      78      41    93
2   Student2   85      46      52    75
3   Student3   10      12      17    99.....

> studentData[,!grepl("ID",colnames(studentData))]
   Math Science History Final
1    15      78      41    93
2    85      46      52    75
3    10      12      17    99...
Happy programming!!

Wednesday, February 11, 2015

R: Initializing an empty list

If you are new to R, there is a thick chance that you may want to grow your dataset (dataframe) dynamically. As we all in know that dynamic memory allocation is a tricky business and in R it is more so.

In R, dynamically allocated memory in loops and function affects the performance of the system(program). A vector object’s growth in each iteration of a loop takes its own time for the loop to complete, which decreases the program speed.
The best solution to get rid of such speed issues is to predefined size of vector and fill it up with the values inside for loop, whenever possible.

For example:
>emptyData <- rep(NA, 100000)
>emptyData <- rep(1:100)
>emptyData <- rep(1:10, times=3)
Happy programming!

Tuesday, February 10, 2015

R : Reading data from CSV file

To read data from a csv file, you can use the use the read.table function in R:

> myData <- read.table("C:/Downloads/R_Tutorial/18MarchStudentInfo.csv", header=TRUE, sep=",")
The above command assumes your csv file has a header field at the begining of the file describing the column names. If your CSV does not contain a row describing the column names you can use it as :

> mydata <- read.table("C:/Downloads/R_Tutorial/18MarchStudentInfo.csv", header=FALSE, sep=",")
Change sep field appropriately depending on your column delimiter in your CSV

Wednesday, January 21, 2015

R : Beginners Guide

If you are starting with the R language and want to know the basics, here is good link which I came across.  Here you can start with understanding the basic types, assignments, functions:

http://www.johndcook.com/blog/r_language_for_programmers/

Happy Programming!!

Thursday, January 15, 2015

Zipping file and folders in Linux CentOS Fedora

To zip a file (or multiple files) in a zip (compressed format for distribution, saving disk space or emailing as attachment), you can use the zip utility present in allmost all the linux distros.

To check if you have zip installed on your machine type
# zip -h

if it is not present, it can be installed via yum Hence the task
# yum install zip
# yum install unzip
Or if you prefer apt over yum then run the following commands:
# apt-get install zip
# apt-get install unzip
Next you can zip files by running the following command. No need to add .zip file extension as it will be added by the zip utility:
$ zip myZip_FileName *
To compress a directory (and all sub-directories within it) run:
$  zip -r myZipped_FolderName *
To decompress (or deflate or unzip) the zip simply run the following command from your command prompt:

$ unzip  zippedFile.zip
To simply view the contents of a zip and not actually unzip it run:

$ unzip -tq zippedFile.zip
To unzip the contents of a zip in a new directory (for avoiding clutter and confusion) run:
$ unzip zippedFile.zip  -d /Folder_to_Unpack_into




Thursday, December 18, 2014

Google introduces Hindi ad Support

Google recently announced that AdWords now supports Hindi ads across the Google Display Network. From now on you can expect to see more ads in India's most spoken language.

What does this mean?

AdWords advertisers can now build campaigns reaching Hindi language sites on the Google Display Network using text, image, rich media, and video display ad formats.

Read more here.

Sunday, November 30, 2014

Debugging with GDB: Examining Call Stack and Call Stack Frames


If you are debugging a programming with gdb and want to see the call stack, and the call stack is really big (spanning the whole page), it makes sense to see only the top (innermost) 5-6 stack frames rather than the entire stack.


(gdb) backtrace
#0  0x00007ffff7bc2620 in thirdPartyFFTransform () from ./liblzo2.so
#1  0x00007ffff7108e43 in useMD5Checksum (karlCoef=0x7ffff2cd0ff0, ffCoef=0x7ffff2cd10c0) at ThirdParty/HardFFTrf.c:99
#2  0x00007ffff71091d5 in FastCheckSum (gamma=3426, delta=0x7ffff730e4c8 <acc_no> "x^2+5y  ", capillaryRise=0x7ffff2cd1120, 
    pCheckSumList=0x7ffff2cd10c0) at ThirdParty/HardFFTrf.c:152
#3  0x00007ffff7107349 in compute_fourier (gamma=40127, delta=0x7ffff2cd1120, CoefA=0x7ffff2cd123a) at ThirdPartyFF.c:1125
#4  0x0000000000491c6e in example::MathCalculator::FastFourierHelper::getCoefficient(FastFourier::Coefficient const*) ()
#5  0x0000000000492a44 in example::MathCalculator::FastFourierHelper::createFFDescriptor(std::vector<example::MathCalculator::ComputeIterationN*, std::allocator<example::MathCalculator::ComputeIterationN*> > const&, int) ()
#6  0x0000000000478767 in example::MathCalculator::FTransform::FTransform(example::MathCalculator::MessageQueue<example::MathCalculator::QMessg, 1024ul>*, example::MathCalculator::MessageQueue<example::MathCalculator::QueueMessage, 1024ul>*, std::vector<example::MathCalculator::ComputeIterationN*, std::allocator<example::MathCalculator::ComputeIterationN*> >&, example::MathCalculator::Accumulator*) ()
#7  0x0000000000474f23 in example::MathCalculator::MathEngine::createJobFactory(FastFourier::EquationDescription*) ()
#8  0x0000000000476856 in example::MathCalculator::MathEngine::processQueue() ()
#9  0x00000000004770b1 in example::MathCalculator::MathEngine::checkAssignments() ()
#10 0x00000000004a7d2e in example::MathCalculator::MathComputeEngine::Calculate() ()
#11 0x000000000046072c in example::MathCalculator::MMain::runMathLibThread(int) ()
#12 0x00007ffff7787b53 in thread_proxy () from ./libboost_thread.so.1.48.0
#13 0x00007ffff5ecadc5 in start_thread () from /lib64/libpthread.so.0
#14 0x00007ffff63de73d in clone () from /lib64/libc.so.6
(gdb) 
(gdb) 
(gdb) bt 4
#0  0x00007ffff7bc2620 in thirdPartyFFTransform () from ./liblzo2.so
#1  0x00007ffff7108e43 in useMD5Checksum (karlCoef=0x7ffff2cd0ff0, ffCoef=0x7ffff2cd10c0) at ThirdParty/HardFFTrf.c:99
#2  0x00007ffff71091d5 in FastCheckSum (gamma=3426, delta=0x7ffff730e4c8 <acc_no> "x^2+5y  ", capillaryRise=0x7ffff2cd1120, 
    pCheckSumList=0x7ffff2cd10c0) at ThirdParty/HardFFTrf.c:152
#3  0x00007ffff7107349 in compute_fourier (gamma=40127, delta=0x7ffff2cd1120, CoefA=0x7ffff2cd123a) at ThirdPartyFF.c:1125
#4  0x0000000000491c6e in example::MathCalculator::FastFourierHelper::getCoefficient(FastFourier::Coefficient const*) ()
(gdb) 
(gdb) 
(gdb) bt -4
#11 0x000000000046072c in example::MathCalculator::MMain::runMathLibThread(int) ()
#12 0x00007ffff7787b53 in thread_proxy () from ./libboost_thread.so.1.48.0
#13 0x00007ffff5ecadc5 in start_thread () from /lib64/libpthread.so.0
#14 0x00007ffff63de73d in clone () from /lib64/libc.so.6

Stack frames

Consider the following stack dump


(gdb) backtrace
#0  0x0000000000401449 in autoPtrExample (rm=3) at MultiUseHeader.hpp:81
#1  0x0000000000401254 in registerQuickExitHandlers (k=3, comment="called from main") at MultiUseHeader.hpp:66
#2  0x00000000004015aa in registeringExitHandlers () at samAutoPtr.cpp:22
#3  0x0000000000401610 in main () at samAutoPtr.cpp:30
(gdb) backtrace -2
#2  0x00000000004015aa in registeringExitHandlers () at samAutoPtr.cpp:22
#3  0x0000000000401610 in main () at samAutoPtr.cpp:30
(gdb) bt 2
#0  0x0000000000401449 in autoPtrExample (rm=3) at MultiUseHeader.hpp:81
#1  0x0000000000401254 in registerQuickExitHandlers (k=3, comment="called from main") at MultiUseHeader.hpp:66
(More stack frames follow...)

You can select your frame of interest using the frame command.


(gdb) frame 0
#0  0x0000000000401449 in autoPtrExample (rm=3) at MultiUseHeader.hpp:81
81  cout << "Printing Rollno: p " << m->roll << " q " << n->roll << "\n"; // <- Seg fault
(gdb) frame 1
#1  0x0000000000401254 in registerQuickExitHandlers (k=3, comment="called from main") at MultiUseHeader.hpp:66
66  autoPtrExample(3);
(gdb) 

Similarly to traverse one frame in either direction one at a time use the up/down command


(gdb) up
#2  0x00000000004015aa in registeringExitHandlers () at samAutoPtr.cpp:22
22  registerQuickExitHandlers(3, "called from main");
(gdb) up
#3  0x0000000000401610 in main () at samAutoPtr.cpp:30
30  registeringExitHandlers();
(gdb) up
Initial frame selected; you cannot go up.
(gdb) down
#2  0x00000000004015aa in registeringExitHandlers () at samAutoPtr.cpp:22
22  registerQuickExitHandlers(3, "called from main");
(gdb) down
#1  0x0000000000401254 in registerQuickExitHandlers (k=3, comment="called from main") at MultiUseHeader.hpp:66
66  autoPtrExample(3);
(gdb) down
#0  0x0000000000401449 in autoPtrExample (rm=3) at MultiUseHeader.hpp:81
81  cout << "Printing Rollno: p " << m->roll << " q " << n->roll << "\n"; // <- Seg fault
(gdb) down
Bottom (innermost) frame selected; you cannot go down.

To see the arguments passed in a particular frame use the info args command once the frame of interest is selected

(gdb) frame
#0  0x0000000000401449 in autoPtrExample (rm=3) at MultiUseHeader.hpp:81
81  cout << "Printing Rollno: p " << m->roll << " q " << n->roll << "\n"; // <- Seg fault
(gdb) up
#1  0x0000000000401254 in registerQuickExitHandlers (k=3, comment="called from main") at MultiUseHeader.hpp:66
66  autoPtrExample(3);
(gdb) info args
k = 3
comment = "called from main"
(gdb) 

To see the local arguments of the selected frame use the info locals command to print the variables:


(gdb) info locals
filename = "./StateWisePopulationRecord.csv"
(gdb) 

[C#] Mutliple Concurrent Producers and Consumers pattern for a Task Queue

If you are in need of a basic concurrent Producers consumers pattern to be used in your application, here is a sample C# program to refer to...