R and C++ integration

R (from R-Project) is a language and environment for statistical computing and graphics. R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible.

The Rcpp package provides a C++ library which facilitates the integration of R and C++. R data types (SEXP) are matched to C++ objects in a class hierarchy. All R types are supported and each type is mapped to a dedicated class.

The RInside package provides C++ classes that make it easier to embed R in C++ code — on either Linux, OS X or Windows.

I’ll show how I install everything required for programming in C++11 and calling R-scripts from C++ programs on Ubuntu 12.04 LTS (which has g++ 4.6 by default).
Read more [+]

Ubuntu under VirtualBox on Windows 8 and Mac OS X

Devices:

1) MacBook Air mid 2012:
Core i5 1800 MHz
Intel HD Graphics 4000
Mac OS X
macair
2) Samsung 900X3C-A04:
Core i5 1700 MHz
Intel HD Graphics 4000
Windows 8
samsung
Read more [+]

Disassembling and changing case of WD1600E1MS-00 USB drive

I did not find any videos with instructions about how to disassemble this type of USB drives, so I decided to record my own.

How I disassembled WD Elements 160Gb and changed its not working USB-SATA adaptor to Kingston. I made it a little brutally:)
Read more [+]

Microsoft, please NO! My eyes!

Why does Microsoft use such garish colors in web design? Yes, I know..Metro style and so on, but let’s compare design of web pages selling Microsoft Surface RT and Apple MacBook PRO.

Read more [+]

How to block ads in Skype

How to remove advertisements on the main window:

1. Open this file for edit: C:\Windows\System32\drivers\etc\hosts
2. Add the following line at the end:

127.0.0.1            rad.msn.com

3. Save file and restart Skype.

 

How to remove popup ads:

1. Open the following dialog in Skype: Options>>Notifications>>Alerts and messages;
2. Uncheck Help and Skype tips and Promotions items;
3. Save options and restart Skype.

Distance between two points on the Earth

What is the distance between New York and Moscow? Let’s calculate it.

To be specific let’s take the 1st point in Moscow on Red Square. Its coordinates (latutude and longitude respectively) are: (55.753904, 37.620076).

And the second point is in New York (Statue of Liberty): (40.689289, -74.044545).

Read more [+]

Calculating GPS satellite position (ephemerides) in Mathematica

In this post I’ll show implementation of algorithm for calculating position of GPS satellite on its orbit (see download link at the bottom). I followed equations described in ICD-GPS-200C (Interface Control Document of U.S. Department of Homeland Security).

In order to calculate the position we’ll need satellite almanac that defines current orbital parameters of the satellite. What information is contained in almanacs:

Read more [+]

Atan2 function in MATLAB vs Mathematica

The two-argument function atan2 is a variation of the arctangent function. For any real number (e.g., floating point) arguments x and y not both equal to zero, atan2(y, x) is the angle in radians between the positive x-axis of a plane and the point given by the coordinates (x, y) on it.
It is quite strange that notation is different in MATLAB and Wolfram Mathematica:
Let’s assume, that X^2+Y^2=1 (in order to have a circle of radius 1), then
In MATLAB we have the same values of P for calls:

P = Atan2(Y, X)
P = Atan(Y/X)

But in Mathematica order of parameters is reversed (both calls will also return the same value):

P = ArcTan[X,Y]
P = ArcTan[Y/X]

Therefore it is possible to make a mistake when porting code between languages.

Real location of “Crysis” game

Yesterday, when I played “Crysis” I noticed that some coordinates (latitude and longitude) are displayed in “binoculars” mode. After that I stopped playing and started my investigation. I made couple of screenshots and found those coordinates in google map. And what do you think? It is in Korea? No! The action happens in Germany:)

Read more [+]

Creating virtual null-modem in linux for using in Wine

In order to create virtual COM ports connected via virtual null-modem cable in Linux you’ll need to install the following software:

1) socat – is a relay for bidirectional data transfer between two independent data channels. Data channels may be files, pipes, devices (terminal or modem, etc.);

2) minicom – is a text-based modem control and terminal emulation program for Unix-like operating systems;

3) wine – is a free and open source software application that aims to allow applications designed for Microsoft Windows to run on Unix-like operating systems.

Read more [+]