Sunday, August 25, 2013

Amazon Authentication failed. How to recovery

The problem with EC2 instance when I try to connect via SSH. Authentication failed.Permission denied
  1. Stop the running EC2 instance
  2. Detach its /dev/sda1 volume (let's call it volume A)
  3. Start new t1.micro EC2 instance, using a new key pair
  4. Attach volume A to the new micro instance, as /dev/xvdf
  5. SSH to the new micro instance and $ sudo mkdir /mnt/tmp
  6. $ mount /dev/xvdf  /mnt/tmp
  7. $ cd /mnt/tmp and copy all needed data
  8. You can try to change  keypair for you your old instance on a new
     Copy ~/.ssh/authorized_keys to /mnt/tmp/home/ubuntu/.ssh/authorized_keys
  9. Logout
  10. Terminate micro instance
  11. Detach volume A from it
  12. Attach volume A back to the main instance as /dev/sda1
  13. Start the main instance
  14. Login as before, using your new .pem file

Monday, March 18, 2013

Quickly open a Command window on a folder in Windows 7

It is rather tedious to change the folder in the command line. If you use Windows 7 or Vista you can open a Windows Explorer, browse to the required folder. Hold the SHIFT key while you right-click the folder and select the context menu "Open command window here".

Saturday, July 7, 2012

Calculation of the optimal darts strategy


In the game of darts, players throw darts at a board to score points.
The circular board has a 'bulls-eye' in the center and 20 slices
called sections, numbered 1 to 20, radiating out from the bulls-eye.
The board is also divided into concentric rings.  The bulls-eye has
two rings: an outer 'single' ring and an inner 'double' ring.  Each
section is divided into 4 rings: starting at the center we have a
thick single ring, a thin triple ring, another thick single ring, and
a thin double ring.  A ring/section combination is called a 'target';
they have names like 'S20', 'D20' and 'T20' for single, double, and
triple 20, respectively; these score 20, 40, and 60 points. The
bulls-eyes are named 'SB' and 'DB', worth 25 and 50 points
respectively.

There are several variants of darts play; in the game called '501',
each player throws three darts per turn, adding up points until they
total exactly 501. However, the final dart must be in a double ring.


Often there are several ways to achieve a total.  You must return a
shortest possible list.

It was tasked to create a program to solve this problem. I used Python  and Google Application Engine for this. First of all I've defined shortest way to win from each point of the game. For example , your current score is 170 and the program calculates that the shortest way to win is T20,T20 and DB (bull-eye)  . But real darts players have different accuracy. I've used the simple test for the player's accuracy. He should hit bull-eye 100 times and calculate his correct hits. The program recalculates this value in Gaussian deviation and defines probability of hitting each target on the darts board. After that the program shows optimal targets for a next turn. If  your accuracy more than 50% the program show the shortest way to win, but if you're not a such experienced player  the program will recommend  a more likely way to achieve the win.
I've implemented the optimal strategy algorithm in the small web application in GAE. You can see it here Darts Strategy  I think it will work on Android and iPhone too.

Saturday, June 23, 2012

IT Garden Diary-Second step -define plant care

Each plant requires care. It can be watering, fertilizing, weeding, pruning, etc.You have to do each procedure in a particular time and place. IT Garden Diary will help you organize all of these procedures and will remind you what  to do today and where. Open the Plant list and click on the button "Care" for any plant. Click the button "Create new". Enter all needed parameters for this procedure Start Date, End Date and Repeat every.


Save this procedure and check the Todo list. You'll see several new deals in it .
Click on the button Map and you'll see the a small markers with a tractor  on the map of your garden. There are places of your today works. Click on any marker and you will see what should you do.

IT Garden Diary-First step adding plants

First of all, you should register your garden at gardendiary.azurewebsites.net . Then click on the Map icon and find your place at Google Maps. Click the button "Draw bound" and draw bound of your garden on the map. After that, click the button "Save bound".
Now, you can place plants on the map using the button "Add plant" . You should enter a name for each plant in the prompt dialog box. Click the button "Save plants" and IT Garden Diary will save all locations at the garden map.If you open the Plant list you'll see all added plants in it. You can edit any records and enter additional information about your plants. itgardendiary

Wednesday, June 20, 2012

Why I've created Garden Diary

This application was created at the request of my wife Victoria. She loves house plants and cares for a small indoor garden. Several times I started working on this problem, but every time delayed due to other cases. At first, I planned to write a small program for desktop computers, but then I thought that the gardeners are not very convinient to walk around the garden with a computer. As time went on sale tablets iPad, Andoid and other. But I did not know very well how to write applications for them. So I decided to make a web application running on any device. It's really cool when any user starts to work immediately with your application without any installations and configurations. Now that everything is almost ready I can say what Garden Diary can do. First, you can record all your plants, along with their pictures. Then enter for each plant the necessary procedures that you do on a regular basis such as watering, fertilizing, weeding and so on. All procedures are automatically placed in the to-do list that needs to be done, and then implement them in your annual Gardener's Journal. Just in time to create this application, I listened to amazing lectures by Steve Huffman on udasity.com where he suggested how to use Google Map in own web applications. It was a great idea. Now, any gardener can show all his plants directly on the map and the program will show when and where he should work now. I hope Garden Diary will be useful not only my wife but also to other gardeners and plant lovers. itgardendiary