Posts

C# - Intersect and Except in Linq form

Something the intersect and except won't be enough for some comparisons. we will have to dig in for some particular type of values like ids, name, etc. Below is an example of this. Intersect in linq form- A.Intersect(B) => gives stuff in  both A and B             var intersect = A.Where(x => B.Select(y => y.Id).Contains(x.Id)).ToList(); Except in linq form- A.Except(B) => gives stuff in  A and NOT B             var intersect = A.Where(x => !B.Select(y => y.Id).Contains(x.Id)).ToList();

Reading and writing a CSV file in c # using csvHelper Example

Below is an example to write and read a csv file using csvHelper Library in c sharp. First you will have to include the csvHelper lib in to your project by going in to NuGet packages in your project and adding it. Once you don’t that you can examine the below program and implement the program. NB:- The below is just a snippet of code and the objects are not declared properly. So please make necessary changes before running the program. For writing a file- public void WriteFile( Data data)         {             String pathIp = “input_your_filePath”;             StreamWriter writeIp = new StreamWriter (pathIp);             CsvWriter cswIp = new CsvWriter (writeIp);                ...

Performance evaluation of reading/writing data from CSV and Excel in C sharp

Recently I did a performance evaluation(not part of my plan) on the performance In reading CSV and Excel files and there was a clear winner. I did this test because I had to process a hell lot of data which was given to me was in excel format. I used C# as my platform to start and immediately I found some libraries such as Interop to help me out. It was pretty easy. At the beginning I used only a small portion of the data and when I started using the original files which has like thousands of records, it started to take a lot of time. So I has a preprocessing function where I write this data to a CSV file. And when I started to read from the CSV, it was very fast. Instead of taking some five minutes, now it take less than 10 seconds. I used the csvHelper lib to help me out and it was pretty easy. Even though it might be a one time execution in the production system, while you are doing the coding you might have to execute it a hundred times. So I would suggest to convert it into a CS...

How to return two objects at the same time in c sharp or Example of Tuple in c sharp

I found ‘Tuple’ to be  a very special , where you want to return two objects in the same function itself. I will explain with the help of below code. My aim in the below code is to return two objects in the same function. Lets consider those two objects are emp_Permanent and emp_Temp which I need when I call a function. These two objects are of the class Employee. public Tuple < Employee , Employee > splitEmployee( Employee employee)         {                                                                               // here I am splitting my employee obje...

How to calculate the run time/time required for a program in visual studio or in C Sharp

I recently started programming in C# and I found it far better than Java already. To find the time took by your code , you will have to insert the below snippet . For more information, you can go to the msdn link. /* importing the lib*/ using System.Diagnostics; /* creating the object of Stopwatch, where we can it to calculate the time*/ Stopwatch stopwatch = new Stopwatch (); stopwatch.Start();// Start the time stopwatch.Stop();// Stop the time TimeSpan ts = stopwatch.Elapsed;             long elapsedMilliseconds;             elapsedMilliseconds = stopwatch.ElapsedMilliseconds; /*Conversion of elapsed time to milliseconds. We can even convert it in to minutes or hours. For more information please check the below link to msdn*/ Console .WriteLine( "RunTime " + elapsedMilliseconds); Msdn Link

Startx Gives error in Raspberry Pi - Authority issues

Here is one of the solution for the problem. This error can be because of the permission issues of the Authority file.So here we need to give permission for the files.So the steps are- Login with your Username and Password in terminal Type : sudo chmod 777 /home/pi This will provide enough permission for the authority file to run. Hope this helps.

Configuring Edimax Wifi Dongle in Raspberry Pi 2

Image
I am going to be very quick here- Open the terminal  Type : sudo su Type in the root password(or your password) Type :  nano /etc/network/interfaces This will open the nano interfaces.Here you need to configure you Wifi Settings as shown below- PS - Please tyoe in your SSID and password for your WiFi connection. Once you have made your changes use Ctrl+X and "Y" to save the file. Use this command to restart the service- sudo service networking reload Final step is to Restart the system

Sample program to print hello world in servlets - Example

Image
A  Java servlet  is a  Java  program that extends the capabilities of a server. Although  servlets can respond to any types of requests, they most commonly implement applications hosted on Web servers. - Wiki Just a small introduction from my side- A Servelt contains following modules- init() - For initialisation service() - For performing the services destroy() - servlets are destroyed using this fucntion Sample program- (I am using netbeans here for the example) Open netbeans and add a new project as shown below- Now we need to create a servlet, so Right click on the project>New > Servlets and click on finish. Now your servlet is ready to run. Right click on your servlet file and click on run It will open up the default browser and you can see the sample program running there. By default the netbeans will provide some sample text to print in the server page.

Communicating with an another PC in ubuntu/Linux

We can use the below command in the terminal for accessing the other terminal Format - ssh -v -X [username]@[ip Address of the destination system] PS:Please ignore the brackets Example - ssh -v -X spec@192.168.1.3

How to get the current time in AnglarJS and convert it in to milliseconds

Here is how you can get the current system time and convert it in to milliseconds in the AngularJS- var t = new Date(); var time = new Date( t ). getTime (); $scope. time = time ;
How to install MATE in Ubuntu 14.04 Add the following repositories to  /etc/apt/sources.list  using the following commands: sudo apt-add-repository ppa:ubuntu-mate-dev/ppa sudo apt-add-repository ppa:ubuntu-mate-dev/trusty-mate Make sure your package list and packages are up to date: sudo apt-get update sudo apt-get upgrade Select one of the three following commands to install MATE: This will install the base packages required for a minimal MATE desktop. sudo apt-get install mate-desktop-environment-core This will install the complete MATE desktop. sudo apt-get install mate-desktop-environment This will install the complete MATE desktop including a few extras. sudo apt-get install mate-desktop-environment-extras Instead of lightdm use lightdm-gtk-greeter for the login display manager as recommended by the MATE team: sudo apt-get install lightdm-gtk-greeter sudo shutdown -r now # reboot

Referenced file 'cordova_plugins.js' not found error

Hi, While doing the Cordova using you may encounter the below errors- -Referenced file 'cordova_plugins.js' not found - Could not find cordova.js script tag One solution of this issue may due to the lack of the webApp plugin. To install it , go to your config.xml file [in your app] and then in the plugins section select in App Browser and add it.Once added successfully, the application will work.

How to install and configure MongoDB in Windows

Image
How to install and configure MongoDB in Windows "" MongoDB is an open-source  document database  that provides high performance, high availability, and automatic scaling. MongoDB obviates the need for an Object Relational Mapping (ORM) to facilitate development."" -Download the .msi installer from the MongoDB site- Download MongoDB -Go to the main folder (which contain "bin" folder) -Create two folders       1.Data       2.Log -Inside the Log folder create a log file(eg: mongolog.log) -Now come back to the main folder and create a config file , say 'mongo.config' -Now open the config file and enter details as below-    systemLog:     destination: file     path:    storage:     dbPath: -Now open cmd and navigate to the mainfolder ->Then ' cd bin' ->mongod.exe --config="path of the config file" Please refer the picture below- Now Mongo...

How to install boardcom driver in ubuntu 15.04

Image
This is the procedure to install the Boardcom WiFi driver in Ubuntu 15.04. Open terminal and type the below command sudo apt-get install bcmwl-kernel-source Then type your password and press 'y'once prompt comes. Once completed, the WiFi option will be enabled in the panel. 

Not able to access Windows 8 Drives/Partition in Ubuntu 15.04?

Image
Folks, After installing the Ubuntu 15.04 , I was not able to access the Windows 8 partition. It was giving error every time i tried to mount up. The reason was pretty simple .The latest windows 8 uses fast boot up feature in order to speed up the boot process.Follow the below steps to disable the fast boot NB : If you disable the fast boot, it will cause more time for the Windows to load. Go to Power Options [Go to start menu and type 'power option'] Click on the Choose what the power buttons do Click on the Change settings that are currently unavailable  Under Shutdown settings, un check the Turn on fast startup box Now Save it

How to install Flash plugin in Chromium Ubuntu 15.04

Image
Hi Folks, For the new chromium,the Flash wont work unless you will have to install it separately. Unlike.Unlike the firefox , we need to install the pepper flash plugin separately in order to see the websites which need Flash. Open terminal[Ctrl+Alt+T]- Type the below commands in order to install the Flash plugin sudo apt-get install pepperflashplugin-nonfree  The above command is for installing the pepper flash plugin sudo update-pepperflashplugin-nonfree --install The above command is for updating the pepper flash plugin Hopefully this works for eeryone.

Guidelines to visit Air Show Bangalore For Photographers

Image
Hi Folks, I decided to write this blog when i completed watching the Air show, because i wished that i had a guideline before i came there. There are certain few thing which you will have to take care before going to the Air show, otherwise you will regret it in the end. First of all you can book the tickets online through the government site itselt.It was Rs 600 for the Air show and Rs 2500 for the exhibition and Air show category. The main thing you need to know before going is that, which gate you need to enter. There are lots of gates there and you will get easily confused even if you ask some ones help. For the 2015 year show for those who has 2500 can enter the compound through gate 4, 5 which includes exhibition also. For the Rs 600 entry you will have to go to Gate 9A,9B, 10.These people can only watch the Air show , which was the one for me.Actually i circled around 4 Km before i found this gate in the end. I would like that you take the following pr...