Conveniences of using LastPass

This post is intended for few of my friends, to whom I promised to explain how to save time and make their life better and information more secure at the same time.

Some of you saw me when I was logging in to LastPass with YubiKey and I promised to give detailed explanation.

In few words, LastPass is service that enables you to keep all your passwords, credit cards information, notes etc securely encrypted, and you access all of that information using single password (Last Pass that you will have to remember). It comes with plugins for most browsers, which automatically fills your login information when and where you need it. It also had password generator which can generate passwords of given complexity on key-press (shortcut is Alt+G):

Screenshot 2014-04-30-22-01-43-3304169

That means that you don’t have to use one password for multiple web sites, and if one of them gets hacked, others are still secure because they had different passwords.

To install LastPass, just go to their site and download it, you will have to register there with your email and Last Pass, and then when you download it wizard will ask you to import your passwords from your current browser.

 

Second great thing about Last Pass is their mobile app, which enables you to have your secure passwords on your mobile smart phone (smartphones are not really mobile anymore, until I got spare battery for mine, I was constantly connected to some power source). It has integrated browser that you can use for opening web sites combined with password management, but real deal is Last Pass Premium (1$/month), which then uses one of more recent features on Android – draw UI over other apps, and with that offers to fill password in Chrome and other browsers for Android, in your e-banking app, in your social network apps, everywhere. You can associate sites to apps in Android, and when you tap password field it automatically shows dialog to fill login information, or if it cannot find input fields, then you have option to copy username and password and paste into fields. I cannot give you screenshots of these as my phone says that it cannot capture them, because they are “DRM protected images”.

Third part of this post is YubiKey. It is hardware dongle that your computer sees as USB keyboard. It generates one-time password (every time different) that enables same security like token generator for e-banking. When you configure LastPass to use YubiKey, it will ask you for token every time you sign into a new browser (or every time if you don’t tick “trust this computer”). Advantage of using YubiKey is that makes your LastPass account much more secure, as it requires 2-factor authentication: something that you know (password), and something that you have (yubi key). In case that you are accessing your LastPass vault from computer that has i.e. keylogger, someone might get a hold of your password, but YubiKey code is unique, and it cannot be used more than once, so it cannot access your account without it.

However, YubiKey is not only way to give additional security to your LastPass account:
Screenshot 2014-04-30-22-44-52-9146121

Instead of YubiKey, you can use Google Authenticator or some other 2-factor authentication option, but reason why I especially like Yubi is that it is very high quality device (virtually indestructible) and you can have 5 of them associated with your LastPass, so that when you loose one, you can just disassociate it from LastPass. Bear in mind that Yubi is only usable in combination with LastPass Premium.

It is also possible to copy YubiKey seed from one key to another so that they are exchangeable (two keys act as one), but that is something risky unless you keep one in a secure safe and need it only to access something in case you loose first one. But, as soon you loose one, whatever it protects is compromised, and this makes sense only for special scenarios. In my opinion it is better to have different keys associated with one LastPass, as it supports it, and you can disable it as soon as you loose it. Loosing one of two identical generators can sometimes happen without you knowing about it.

Anyway, now that you know about it, first step is to get LastPass. Try it. If you like it, then you can decide if you want Yubi. Standard version comes with one slot configured for Yubi auth, and second empty. For same price (25$) you can also get YubiKey VIP, it gets with preconfigured Symantec VIP authenticator that you can associate to PayPal etc, to log in without LastPass. In second slot you get standard Yubi auth, and only downside is that when you want to use it is that you need press token few seconds longer.

As an added bonus, for any of your sites, credit cards etc. that you keep in LastPass vault, you can share with another user! This is much better way to exchange credit card information than to send it through email (or any other standard communication channel).

Disclaimer: I use affiliate links. If you register for Last Pass through links in this blog, both you and me get month of LastPass Premium for free!

Samsung ATIV Book 8 NP880Z5E-X01 (subjective owner’s) review

I have bought this computer some 6 months ago.

Samsung ATIV 8 on Amazon

It is my primary computer since, as I moved to Germany last year, and did not bring any computers with me, and as I did not permanently settle here, I did not want to buy any desktops until I decide where I’m going to live more than a year. I wanted something lightweight and small, but still with full HD screen, and if possible with decent VGA card, as I was collecting some games that I like on Steam, with plan to play sometimes, so it was nice to have feature.

My primary use of computer is Visual Studio (with Resharper), Office (365 installed offline), reading articles and Skype/Viber. I also run virtual machines in VmWare player or VirtualBox when I want to test something etc. Therefore I wanted computer with i7 CPU. Ram was to be 16GB as it is max that current generation of motherboards can support, and SSD drive as mechanical hard drive is slow (biggest bottleneck of any computer), heavy, and unnatural for an electronic device. I also wanted good keyboard, but I could not find computer which has it combined with all other qualities, so I decided to buy Das Keyboard Model S Ultimate later.

If you take a look at this computer, it is not really what I wanted, as it has 1TB mechanical, 5400RPM drive and 8GB of RAM. As everything else was acceptable, and it has decent Radeon 8000 series graphics card, I decided I can live with less than perfect keyboard (from what reviews said) and bought it.

First downside, HDD was fixed with Samsung 840 Pro 256GB, which was easy to install, and original HDD is now in this External 2.5″ HDD enclosure, which is very good and I can only recommend it, it even has special connector (not standard mini-USB, but with double contacts, for better power supply). To install HDD into this computer, whole bottom cover needs to be removed, and also you need to disconnect quite a few connectors inside to access HDD, but it should not be a problem for anyone who ever opened a tablet or phone. To find out how to do it yourself, you can see this video on YouTube.

Second downside was trivial to solve, as laptop is delivered with one soldered (you cannot replace it) 8GB RAM module, and I just ordered Kingston 8GB DDR3 1600MHz and plugged it in (there is small cover for installing RAM, so you don’t have to open whole computer).

As I’m not trying to give an complete and objective review on this device (there are already plenty on the Internet), I want to go straight to the point that interests any of you thinking about buying it – what are “hidden” downsides and problems of this device, that you cannot really read from reviews, but you have to use it extensively to find out:

  1. Touch screen functionality enabling/disabling requires you to log out, and if you just close screen lid while computer is on and unlocked, touch is not disabled while screen is off, metal surface interacts with screen (random touch/click/drag events) and can cause all kind of weird things happening on your desktop (from my experience, worse than letting 2-year old play with touch screen). This is one of most annoying issues, that Samsung could solve by providing bug fix for their driver software.
  2. Hard drive is slow, not anything specially slower than other mechanical drives (even faster), but still, in my opinion computer is completely unusable with default hard drive, and if you plan to spend money on this computer, calculate additional cost of SSD with, or otherwise go for similarly priced computer that already has SSD. You don’t need Core i7 in same computer that only has spinning platters storage inside. With SSD, it is completely different device, especially with this Samsung 840 Pro, as Samsung Magician software has “Rapid mode” that uses system RAM for caching, so in normal usage achieves results that are impossible through SATA 3 interface:

    Crystal disk mark of Samsung SSD pro 256GB
    Crystal disk mark of Samsung SSD pro 256GB
  3. If you put it to sleep, while you have “Hybrid sleep” enabled, and configured options to go to hibernation after certain time in sleep (i.e. 2 hours), when moment to go to hibernation comes, computer turns on, and stops on screen saying it cannot load windows. There were very weird things happening with it, i.e. sometimes I would put it to sleep in evening, and when I turn it on in the morning it would freeze on windows welcome. Then I would kill it with holding 4 seconds power switch, do a clean boot, and then just send it to hibernation and turn on again to get my session from last night! I know it sounds crazy, but I did it more than once. Something is wrong with either computer or how windows saves memory to drive, and then it remains for next session. Sometimes this would cause computer to turn on to go to hibernation, and then as I’m not there it would stay so on “cannot load windows screen” few hours, and it would become very hot. It happened in bag once, and if I did not remove it it could have been roasted. If you leave it to sleep in evening with charger disconnected, you may encounter in morning that it is off and battery completely drained, with your windows session gone. I’m not sure if it is caused by installing SSD and enabling Rapid mode, or maybe with installing another RAM module, but I don’t remember having this issue when computer was completely new, but it might have never been configured to go to hibernation after some sleep at that time. For me, issue is solved by disabling sleep, I configured it to always go to hibernation. As SSD is very fast, difference is unnoticeable, so it is very good workaround that completely eliminates issue.
  4. SD card slot is “reduced size” (half depth), so if you are used to carry around a fast and big SD-card to extend your HDD capacity like me, then count it out on this computer, as half of the card sticks out of computer
  5. If you require robust device, but also care that your computer is not scratched, you will be disappointed with Samsung’s decision to put plastic on top of the screen, as it is one of most sensitive areas when computer is in messenger bag:
  6.  Bottom cover is plastic, it will get scratched, change color, and deformed on places which run hot on the inside:

 

So, these are all problems that I experienced with this machine so far. I’m very happy with it, and only first one is annoying, as I forget about it sometimes and close unlocked windows. It is very good device otherwise, I spilled water on it once, keyboard is very good and does not let it inside, and battery is really good, you can work on it 4-5 hours without power.

If you already own it, I can recommend this TeckNet® 90W power supply, which has compatible connector, it is lighter and better looking than original one:

 

If you are still indecisive, feel free to send your questions in comments.

 

Why uptime on WP7 cannot be longer than 24.9 days?

This morning I saw in System View on my Samsung Omnia 7 that uptime is “more than 24.9 days”, and boot time is “earlier than 30-Dec-11 13:07:24”. At first I was amazed, how can it be “earlier than”, and how that reference in time is not fixed (it was 29-Dec yesterday). Then I realized that phone does not “remember” its time of boot, but has some sort of incrementing register for counting uptime, and it hits its limit on 24.9 days. It would be interesting for how long this phone can work without reboot, as it seems very stable, but it seems that cannot be known without manual recording of boot time Disappointed smile.

I did some calculations, and it seems that phone is using SIGNED int as register value which counts number of MILISECONDS since boot. As 25 days has about 2’160’000’000 milliseconds, and 2^31 is 2’147’483’648, it starts to seem logical where did number 24.9 days came from Nerd smile. It is logical that boot time itself is not recorded, as there it would be a possibility of reporting “fake” uptimes by setting the clock on the phone. However, in my opinion, method used is also not optimal.

So, what could be better here? Light bulb

- For start, it could be unsigned int, so the OS would be able to keep track for more than 49 days of uptime.
– It could also count seconds instead of milliseconds, that would make possible to count more than 1300 years of uptime Smile, or if for some reason needs to keep milliseconds (i.e. does not want to break all existing functionalities?), unsigned long (int64) could be used (although I don’t remember if it is available in WP7), to give overkilling amount of almost 585 millions of years Hot smile.

All this considered, it seems that 49 days would be enough, change would not break anything, and it requires changing only one variable declaration.

Solution for VHD_BOOT_HOST_VOLUME_NOT_ENOUGH_SPACE error in windows 8

If you are using VHD method of installing windows 8 to virtual disk on physical machine (Scot Hansellman has great tutorial: http://www.hanselman.com/blog/GuideToInstallingAndBootingWindows8DeveloperPreviewOffAVHDVirtualHardDisk.aspx) and you get VHD_BOOT_HOST_VOLUME_NOT_ENOUGH_SPACE error after installation, then your problem is probably dynamic VHD and not enough free space on disk containing that drive. I had the same problem, and googling for it did not solve it, as there is one little catch that is not very known:

You need to have enough free space on physical disk containing VHD that it can contain whole VHD IF IT WOULD GROW TO MAXIMUM DECLARED SIZE! So 100GB VHD on a 90GB free space is a no-go, it does not matter that Windows 8 will use only about 11GB after clean installation.

Windows 8 setup does not check for this, so you may be able to install it, and not able to boot it :)

ASP.NET MVC3 app (part 1) – Entity Framework and code first

How often you need to have cascading choices on UI in order to make your application user friendly? In my experience, almost every modern application has some form of hierarchy, and that is where cascading dropdowns are used. But, I want to make this less repetitive and more elegant. So, let’s begin. In first part (this) I will create an simple web app using entity framework code-first and make simple model which will be used for creating this functionality. It is one speedy run-through of new features, without advanced topics, so mind some bad practices, this blog post is not about good programming, first part is for MVC3/.NET 4 beginners with experience with older versions of MVC and .NET.

It will be an mvc3 razor internet application:

image

With latest MVC tools update there are already almost all necessary NuGet packages installed in new project:

image

I will just update all of jQuery packages as they have updates at the moment, and add EntityFramework.SqlServerCompact (NuGet will add dependencies), so SQL server won’t be needed.

As this is demo app, I will put everything into single project. It will be an product catalogue.

This is data model:

image

Central object will be product model (I will use vehicles domain), which has type, version, trim level and manufacturer. Simple enough. Objects on diagram are simple POCO objects with collection properties marked as virtual, so entity framework can override them and inject DynamicProxy objects for lazy loading.

This will be my repository:

image

For this DbContext to work, I need to do one more thing – to put connection string into my web.config:

image

As I don’t want to create test data every time I change my model, I can use database initializer class to create test data (this is useful for unit testing):

image

And this is it. I now have database and data. Actually, I will have it when I start my application, if I add this to global.asax:

image

To test this, I will use controller autoscaffold feature of new MVC tools update:

image

This will autocreate controller and all views Smile. After this action, starting app and visiting http://localhost:57095/Manufacturer will give:

image

Note that only manufacturers for which I created Models are in database. This is because I only added Models, and EF added all related objects, and BMW was not among them.

Using auto scaffold I created controllers for all model objects in couple of minutes.

This is end of part 1, I now have application which will I use to create unobtrusive cascading dropdowns. In the next part I will make cascading dropdown loading using standard methods (jQuery and ajax).

For more info about EF Code First, visit

http://www.hanselman.com/blog/SimpleCodeFirstWithEntityFramework4MagicUnicornFeatureCTP4.aspx

and

http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx

UPDATE: Added part 2

Take my work with me

How often did I need to copy whole virtual machine because I needed to continue work on another location? A way too often. And moments when I wait for 20-30GB to copy, sometimes seem like eternity.

Well, I spent couple minutes last night to prevent that :)

Here is a batch script which copies folder with my work from hdd and takes backup of database. Even more, it restores everything back when I arrive at another location :)

So, save this script as common.bat:

@echo off
set server=HOSTNAME\INSTANCE
set dbName=DATABASE
set projFolder="C:\Users\gorano\Documents\visual studio 2010\Projects"
set backupFolder=%CD%
 
if "%1"=="leaving" GOTO backup
if "%1"=="arriving" GOTO restore
echo Invalid first argument, must be "leaving" or "arriving"
GOTO end
 
:backup
echo backup database %dbName%
@echo on
sqlcmd -E -S %server% -Q "BACKUP DATABASE [%dbName%] TO  DISK = N'%backupFolder%\%dbName%.bak' WITH NOFORMAT, INIT, NAME = N'%dbName%-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10"
xcopy %projfolder% %backupFolder%\Projects  /E /I /Y /Q
GOTO end
 
:restore
if "%2"=="DeleteOld" GOTO deleteold
:restoreNoDelete
echo restore database %dbName%
sqlcmd -E -S %server% -Q "RESTORE DATABASE [%dbName%] FROM DISK = N'%backupFolder%\%dbName%.bak' WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 10"
xcopy %projfolder% %projfolder%.backup  /E /I /Y /Q
xcopy %backupFolder%\Projects %projfolder%  /E /I /Y /Q
GOTO end
 
:deleteold
@echo Press any key to delete database %dbName% on sql server %server%
pause
sqlcmd -E -S %server% -Q "ALTER DATABASE [%dbName%] SET  SINGLE_USER WITH ROLLBACK IMMEDIATE"
sqlcmd -E -S %server% -Q "DROP REMOVETHISWORD DATABASE [%dbName%]"
GOTO restoreNoDelete
 
:end
pause

To run this easily, make “i’mleaving.bat” with

common leaving

and “i arrived.bat” with

common arriving DeleteOld

All you need to change is to set your server\instance, database name, folder with projects, and to delete “REMOVETHISWORD” under :deleteold, as words DROP and DATABASE does not stand well together (I don’t want to hack wordpress script injection protection to post this) :)
In combination with DropBox, this is great thing. You can also add 7z line to compress/decompress these files so dropbox sharing is more meaningfull (if you have large database).

Fix selected tab in SharePoint top links menu

Fastest way to accomplish this is to use jquery! :)

function fixTabs(){
    $.each($(".customNavTabActive"), function() {
        $(this).removeClass("customNavTabActive");
        $(this).parentsUntil("table").each(function() {
            $(this).removeClass("customNavTabActive");
        });
    });
    $.each($("a.customNavTab"), function() {
        if (this.href == document.location.href || this.href + "/default.aspx" == document.location.href) {
            $(this).parent("td").addClass("customNavTabActive");
        }
    });
}

Update: I have improved this code a little bit :)

function fixTabs(){
    var normalNavTavCss = "customNavTab";
    var firstCellActiveCss = "customNavTabActive";
    var firstCellCss = "customNavTab";
    var lastCellActiveCss = "customNavTabActive";
    var lastCellCss = "customNavTab";
    var cellActiveCss = "customNavTabActive";
    $.each($("." + cellActiveCss), function() {
        $(this).removeClass(cellActiveCss);
        $(this).parentsUntil("table").each(function() {
        $(this).removeClass(cellActiveCss);
        });
    });
    var lastCell;
    var lastCellSelected;
    $.each($("." + normalNavTavCss + " a"), function(i) {
        lastCell = $(this).parent("td");
        var location = document.location.href.replace("/default.aspx", "");
        var link = this.href.replace("/default.aspx", "");
        lastCellSelected = (link == location || location.indexOf(link) > -1);
        if (lastCellSelected) {
            if (i == 0) {
                lastCell.addClass(firstCellActiveCss);
            }
            else {
                lastCell.addClass(cellActiveCss);
            }
        }
        else if (i == 0) {
            lastCell.addClass(firstCellCss);
        }
    });
    if (lastCellSelected) {
        lastCell.removeClass(cellActiveCss);
        lastCell.removeClass(firstCellActiveCss);
        lastCell.addClass(lastCellActiveCss);
    }
    else {
        lastCell.addClass(lastCellCss);
    }
}

Localizing Sharepoint resources – transliteration to Cyrillic

Recently I tried to localize MS WSS 3.0 site collection to unsupported language – Serbian, cyrillic (Serbia). LCID of this culture is 3098. This language is almost the same as existing latin localization to Serbian (Serbia) with LCID 2074. To get cyrillic version of resource files (resx), I installed Serbian latin language pack and searched wwwroot and 12 folders for “sr-latn-cs”, and took following files: core.sr-latn-cs.resx, resources.sr-latn-cs.resx, spadmin.sr-latn-cs.resx, spcore.sr-latn-cs.resx, spsearchadmin.sr-latn-cs.resx and wss.sr-latn-cs.resx

I got Search Center and language pack for it installed, so in an environment without search center, there should be some of these files missing.

To get sr-cyrl-cs.resx versions of theese files, I made small console application which parsed through xml files and replaced latin letters with cyrillic. Character swap is simple, and to parse xml I used following code:

static void Main(string[] args)
        {
            if (args.Length == 0) args = new string[]{"source", "destination"};
            DirectoryInfo source = new DirectoryInfo(args[0]);
            foreach (FileInfo file in source.EnumerateFiles())
            {
                XmlTextReader reader = new XmlTextReader(file.OpenText());
                XmlDocument doc = new XmlDocument();
                doc.Load(reader);
                reader.Close();
                FileInfo dest = file.CopyTo(Path.Combine(args[1], file.Name.Replace(SourceLang, DestLang)), true);
                XmlDocument destination = new XmlDocument();
                foreach (XmlNode node in doc.ChildNodes)
                {
                    ParseChildren(node);
                }
 
                XmlTextWriter writer = new XmlTextWriter(dest.OpenWrite(), Encoding.Unicode);
                doc.Save(writer);
                writer.Close();
            }
        }
 
        private static void ParseChildren(XmlNode sourceNode)
        {
            foreach (XmlNode node in sourceNode.ChildNodes)
            {
                switch (node.NodeType)
                {
                    case XmlNodeType.Text:
                        if (node.Name == "#text" && node.HasChildNodes == false 
                            && node.Value.Length > 0 && node.ParentNode.ParentNode.Name == "data")
                        {
                            if (!node.ParentNode.ParentNode.Attributes["name"].Value.ToUpper().Contains("accesskey".ToUpper())
                                && !node.ParentNode.ParentNode.Attributes["name"].Value.ToUpper().Contains("_AK".ToUpper()))
                            {
                                node.Value = SmartConvertToCyrillic(node.Value);
                            }
                            else
                            {
                                break;
                            }
                        }
                        break;
                    default:
                        break;
                }
                if (node.HasChildNodes)
                    ParseChildren(node);
            }
        }

Important lines here are in case XmlNodeType.Text:

Those lines discriminate nodes which are values and need to be transliterated to Cyrillic.

When new resx files have been placed back to same respective folders where their sources for transliteration were found, then new language had to be enabled in Sharepoint.

Registry key HKEY_LOCAL_MACHINESOFTWAREMicrosoftShared ToolsWeb Server Extensions12.0InstalledLanguages contains string values whose names are LCID-s of installed languages, and value is version of satellite assembly of microsoft.sharepoint.intl.resources.dll in GAC. I added new string value named “3098” with value “12.0.0.0”. I even disassembled latin version of this dll and made cyrillic but I have what it seems unsolvable problem of impossibility to build that dll in Language version other than “Language neutral”, and I believe that is the key to enable localization of administration pages and parts of UI that is not localized.

Adding 3098 registry value enabled “Serbian Cyrillic” language in “New Web Site” SharePoint page, but to get templates for Team site, Blank, etc, it is necessary to make “3098” folder in C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATE

I used 2074 folder as a template, and edited files in 2074/XML subfolder to get site templates in site creation wizard.

Newly created site was mostly localized – parts which are visible to users, but administrative pages are localized from satellite dll, and I did not succeed in building language specific version of dll to use it for this purpose. Also, this dll must be signed for SharePoint to use it, and to circumvent this I used delay sign, and then added exception for signature verification using gacutil.

This was very useful resource http://social.msdn.microsoft.com/Forums/en/sharepointdevelopmentprerelease/thread/023d1fb9-c415-405a-8944-c709c0cc8f01

Useful links

Page with bunch of useful software (Stranica sa hrpom korisnog softvera)

http://www.weethet.nl/english/download.php

Find alternatives to well known programs:

http://alternativeto.net/

Windows 7 hotkeys:

http://hubka.net/archive/2009/03/29/windows-7-hotkeys.aspx

Fix MSN pop-up on minimizing Firefox:

http://jonathanhu.com/2009/05/15/how-to-fix-windows-live-msn-pop-up-when-minimize-firefox-in-windows-7/

Change default location for Windows 7 Windows Explorer:

http://www.windows7hacker.com/index.php/2009/05/how-to-change-the-default-location-in-windows-explorer-to-my-computer-in-windows-7/

PID/VID database – info on any unknown hardware

http://www.pcidatabase.com/

Fix Vista TCP/IP after clicking on “Remove outdated LSP”:

Reinstall and Reset TCP/IP (Internet Protocol) in Windows Vista, 2003 and XP » My Digital Life

Many pdf books on computer sciences:

FlazX – Welcome to your Computer & IT learning center