Thursday, September 8, 2016

Solution: Vagrant stopped working - `open': Access is denied. (5) (ChildProcess::Error)

Be The First To Comment
ERROR from CMD with out running vagrant up as administrator

There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["showvminfo", "18021ea0-83ee-43c3-9adb-26ad7eb0c6ca"]

Stderr: VBoxManage.exe: error: Failed to create the VirtualBox object!
VBoxManage.exe: error: Code CO_E_SERVER_EXEC_FAILURE (0x80080005) - Server execu
tion failed (extended info not available)
VBoxManage.exe: error: Most likely, the VirtualBox COM server is not running or
failed to start.

Error on running vagrant up as administrator from CMD

C:/HashiCorp/Vagrant/embedded/gems/gems/childprocess-0.5.9/lib/childprocess/wind
ows/handle.rb:12:in `open': Access is denied. (5) (ChildProcess::Error)
        from C:/HashiCorp/Vagrant/embedded/gems/gems/childprocess-0.5.9/lib/chil
dprocess/windows/process.rb:70:in `launch_process'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/childprocess-0.5.9/lib/chil
dprocess/abstract_process.rb:82:in `start'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/u
til/subprocess.rb:122:in `block in execute'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/u
til/safe_chdir.rb:26:in `block (2 levels) in safe_chdir'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/u
til/safe_chdir.rb:25:in `chdir'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/u
til/safe_chdir.rb:25:in `block in safe_chdir'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/u
til/safe_chdir.rb:24:in `synchronize'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/u
til/safe_chdir.rb:24:in `safe_chdir'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/u
til/subprocess.rb:121:in `execute'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/u
til/subprocess.rb:22:in `execute'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/u
til/platform.rb:129:in `cygwin_windows_path'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/provi
ders/virtualbox/driver/base.rb:50:in `block in initialize'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/provi
ders/virtualbox/driver/base.rb:42:in `each'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/provi
ders/virtualbox/driver/base.rb:42:in `initialize'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/provi
ders/virtualbox/driver/meta.rb:36:in `initialize'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/provi
ders/virtualbox/provider.rb:20:in `new'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/provi
ders/virtualbox/provider.rb:20:in `usable?'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/v
agrantfile.rb:138:in `machine_config'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/v
agrantfile.rb:45:in `machine'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/e
nvironment.rb:663:in `machine'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/p
lugin/v2/command.rb:177:in `block in with_target_vms'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/p
lugin/v2/command.rb:201:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/p
lugin/v2/command.rb:201:in `block in with_target_vms'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/p
lugin/v2/command.rb:183:in `each'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/p
lugin/v2/command.rb:183:in `with_target_vms'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/comma
nds/up/command.rb:131:in `install_providers'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/comma
nds/up/command.rb:85:in `execute'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/c
li.rb:42:in `execute'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/e
nvironment.rb:302:in `cli'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/bin/vagrant:1
74:in `<main>'

Similar issue on Question from Stack Overflow

Fix steps for my machine-

1. Installed fresh - Vagrant (1.8.5)
2. Installed fresh Virtual box VirtualBox 5.1.4 for Windows host x86/amd64 - Version 5.1.4 r110228 (Qt5.5.1) 
3. Install Git bash version 2.8.2.windows.1 (64 bit)
4. Running Git bash as admin and calling vagrant up through that elevated console

Solution-
https://laracasts.com/discuss/channels/servers/vagrant-up-failing-trying-to-add-to-hosts

Friday, August 19, 2016

Code snippet: Open Folder Browser Dialog in WPF

Be The First To Comment
Install WPFFolderBrowser 1.0.2 from nuget gallery to use the Windows Vista / Windows 7 Folder Browser Dialog from your WPF projects, without any additional dependencies.

Install-Package WPFFolderBrowser
then import WPFFolderBrowser

using WPFFolderBrowser;
private void BrowseFolder()
        {
            WPFFolderBrowserDialog dd = new WPFFolderBrowserDialog();
            var result = dd.ShowDialog();
            if (result.HasValue)
            {
                TxtFvsAccessDbPath = dd.FileName;
            }
        }

Code snippet: WPF UWP ListView SelectionChanged Event Handling in ViewModel

Be The First To Comment
Solution from Dhaval Patel in Sliverlight application works perfectly on my WPF application. I prefer his idea because it is more clear and cleaner than other solutions that  I have came with. The event handling approach explained as -"This is the way where You can Reach the Selection changed events in Your MVVM Application First Of all i tell you that Command Property only work in Button now we have to Explicitly binding that property in our Selection Changed event like List box or combo box in Your XMAL file"
<ListBox Name="MyListBox" ItemsSource="{Binding ListItems}" Height="150" Width="150" Margin="281,32,-31,118">

        <Local:Interaction.Triggers>
            <Local:EventTrigger EventName="SelectionChanged">
                <Local:InvokeCommandAction Command="{Binding MyCommand}" CommandParameter="{Binding ElementName=MyListBox,Path=SelectedItem}"/>
            </Local:EventTrigger>
        </Local:Interaction.Triggers>
    </ListBox>
for this you have to add dll Syatem.Windows.Interactivity now u have to add references in your xaml file namespace like
 xmlns:Local="clr-namespace:System.Windows.Interactivityassembly=System.Windows.Interactivity"

Thursday, August 18, 2016

Code snippet: Data binding between ViewModel and Radio Button in WPF

Be The First To Comment
Following example shows the data binding between radio buttons and ViewModel in WPF.

Parts of View.xaml

<Grid.Resources>
    <Utilities:RadioHelper x:Key="RadioConverter" />
    <Utilities:RadioHelper x:Key="InverseRadioConverter" Inverse="True" />
</Grid.Resources>
<RadioButton Name="radFvsOracle" GroupName="fvsStorage" Content="Oracle" Margin="7,0,0,0" IsChecked="{Binding Path=RadFvsResults, Converter= {StaticResource ResourceKey=RadioConverter}}"></RadioButton>
<RadioButton Name="radFvsAccess" GroupName="fvsStorage" Content="Access" Grid.Column="2" Margin="11,0,0,0" IsChecked="{Binding Path=RadFvsResults, Converter= {StaticResource ResourceKey=InverseRadioConverter}}"></RadioButton>

Parts of RadioHelper.cs

public class RadioHelper:IValueConverter 
    {
        public bool Inverse { get; set; }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                bool boolValue = (bool)value;
                return this.Inverse ? !boolValue : boolValue;
            }
            return Binding.DoNothing;
       }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool boolValue = (bool)value;
            if (!boolValue)
            {
                    return Binding.DoNothing;
            }
            return !this.Inverse;
        }
    }

Friday, August 12, 2016

Random Forest Regression, Negative Variance Explained mechanism

1 Comment
Jeffery Evans, Senior Landscape Ecologist, The Nature Conservancy, Global Lands Science Team, Affiliate Assistant Professor, Zoology & Physiology, University of Wyoming explains a negative percent variance explained in a random forest regression in hilarious way -

I have recently been asked the question: “why do I receive a negative percent variance explained in a random forest regression”. Besides the obvious answer “because your model is crap” I thought that I would explain the mechanism at work here so the assumption is not that randomForests is producing erroneous results. For poorly supported models it is, in fact, possible to receive a negative percent variance explained.

Generally, explained variance (R²) is defined as:

R² = 1 - sum((ลท-mean(y))²) / sum((mean(y)-y)²)

However, as indicated by Breiman (2001) and the R randomForest documentation the (regression only) “pseudo R-squared” is derived as:

R² = 1 – (mean squared error) / var(y)

Which, mathematically can produce negative values. A simple interpretation of a negative R² (rsq), is that you are better off predicting any given sample as equal to overall estimated mean, indicating very poor model performance. 

Multi-item Selection WPF ListBox using Attached Property

Be The First To Comment
The attached property class looks like -
ListBoxHelper.cs
1:  public static class ListBoxHelper  
2:    {  
3:      public static readonly DependencyProperty SelectedItemsProperty =  
4:                          DependencyProperty.RegisterAttached("SelectedItems",   
5:                          typeof(IList),   
6:                          typeof(ListBoxHelper),   
7:                          new PropertyMetadata(default(List<string>),   
8:                          OnSelectedItemsChanged));  
9:        
10:      public static IList GetSelectedItems(DependencyObject d)  
11:      {  
12:        return (IList)d.GetValue(SelectedItemsProperty);  
13:      }  
14:    
15:      public static void SetSelectedItems(DependencyObject d, IList value)  
16:      {  
17:        d.SetValue(SelectedItemsProperty,value);  
18:      }  
19:    
20:      private static void OnSelectedItemsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)  
21:      {  
22:        var listBox = (ListBox)d;  
23:        ReSetSelectedItems(listBox);  
24:        listBox.SelectionChanged += delegate  
25:        {  
26:          ReSetSelectedItems(listBox);  
27:        };  
28:      }  
29:    
30:      private static void ReSetSelectedItems(ListBox listBox)  
31:      {  
32:        IList selectedItems = GetSelectedItems(listBox);  
33:        selectedItems.Clear();  
34:        if (listBox.SelectedItems != null)  
35:        {  
36:          foreach (var item in listBox.SelectedItems)  
37:            selectedItems.Add(item.ToString());  
38:        }  
39:      }  
40:    }  


Difference between PropertyMetadata vs FrameworkPropertyMetadata in .NET

Be The First To Comment

Databind between View and ViewModel for PasswordBox WPF

Be The First To Comment
"When you try to databind the password property of a PasswordBox you will recognize that you cannot do data binding on it. The reason for this is, that the password property is not backed by a DependencyProperty.

The reason is databinding passwords is not a good design for security reasons and should be avoided. But sometimes this security is not necessary, then it's only cumbersome that you cannot bind to the password property. In this special cases you can take advantage of the following PasswortBoxHelper.

The PasswordHelper is attached to the password box by calling the PasswordHelper.Attach property. The attached property PasswordHelper.Password provides a bindable copy of the original password property of the PasswordBox control."

Published on -


PasswordHelper.cs
1:  public static class PasswordHelper  
2:  {  
3:    public static readonly DependencyProperty PasswordProperty =  
4:      DependencyProperty.RegisterAttached("Password",  
5:      typeof(string), typeof(PasswordHelper),  
6:      new FrameworkPropertyMetadata(string.Empty, OnPasswordPropertyChanged));  
7:     
8:    public static readonly DependencyProperty AttachProperty =  
9:      DependencyProperty.RegisterAttached("Attach",  
10:      typeof(bool), typeof(PasswordHelper), new PropertyMetadata(false, Attach));  
11:     
12:    private static readonly DependencyProperty IsUpdatingProperty =  
13:      DependencyProperty.RegisterAttached("IsUpdating", typeof(bool),   
14:      typeof(PasswordHelper));  
15:     
16:     
17:    public static void SetAttach(DependencyObject dp, bool value)  
18:    {  
19:      dp.SetValue(AttachProperty, value);  
20:    }  
21:     
22:    public static bool GetAttach(DependencyObject dp)  
23:    {  
24:      return (bool)dp.GetValue(AttachProperty);  
25:    }  
26:     
27:    public static string GetPassword(DependencyObject dp)  
28:    {  
29:      return (string)dp.GetValue(PasswordProperty);  
30:    }  
31:     

Tuesday, June 28, 2016

Interactive KML Placemarks using HTML/JavaScript

Be The First To Comment
My colleague stopped by this morning and asked me to see if there is any way to  implement combo box / drop-down list in KML file for dynamically selecting the Placemarks' information. Few hour of googling come up with a quick and dirty KML (adding custom data) using HTML/JavaScript in <ExtendedData> tag with combo box selection and pasted it here for our future reference. It may helps others as well. If there are any alternatives feel free to chime in.

 <?xml version="1.0" encoding="UTF-8"?>  
 <kml xmlns="http://www.opengis.net/kml/2.2">  
      <Document>  
         
      <Style id="MyBalloonStyle">  
           <BalloonStyle>  
                <text> <![CDATA[  
                <b>Example extended data template</b>  
   
                <div style="width:350px;" id="tree"></div>  
   
                <table id="table" border="1" >  
                     <tr><td>Company Name</td></tr>  
                     <tr><td><i>$[Company_Name]</i></td></tr>  
                     <tr><td>  
                          <select id = "treeListSelection" onchange = 'treeListChanged(value)'>  
                           <option>--Select--</option>  
                           <option value="tree 1">'Tree 1'</option>  
                           <option value="tree 2">'Tree 2'</option>   
                          </select>  
                     </td></tr>  
                </table>    
   
                <script type="text/javascript">   
                 function treeListChanged(value){  
                     document.getElementById('tree').innerHTML = value ;        
                 }  
                </script>  
   
                ]]></text>  
                <bgColor>ffffffbb</bgColor>  
           </BalloonStyle>  
           <IconStyle> <color>ffffffff</color> <scale>1</scale>  
                <Icon><href>http://maps.google.com/mapfiles/kml/pushpin/grn-pushpin.png</href>  
                </Icon>  
           </IconStyle>  
           <LabelStyle>   
                <scale>0</scale>   
           </LabelStyle>  
      </Style>  

Monday, June 27, 2016

[SOLUTION] Vagrant - Remote connection disconnect. Retrying ...

Be The First To Comment
Here is error from guest machine, complaining about remote connection

 ==> default: Attempting graceful shutdown of VM...  
 ==> default: Clearing any previously set forwarded ports...  
 ==> default: Clearing any previously set network interfaces...  
 ==> default: Preparing network interfaces based on configuration...  
   default: Adapter 1: nat  
   default: Adapter 2: hostonly  
 ==> default: Forwarding ports...  
   default: 80 (guest) => 8080 (host) (adapter 1)  
   default: 3000 (guest) => 3000 (host) (adapter 1)  
   default: 22 (guest) => 2222 (host) (adapter 1)  
 ==> default: Running 'pre-boot' VM customizations...  
 ==> default: Booting VM...  
 ==> default: Waiting for machine to boot. This may take a few minutes...  
   default: SSH address: 127.0.0.1:2222  
   default: SSH username: vagrant  
   default: SSH auth method: private key  
   default: Warning: Remote connection disconnect. Retrying...  
   default: Warning: Remote connection disconnect. Retrying...  
   default: Warning: Remote connection disconnect. Retrying...  
   default: Warning: Remote connection disconnect. Retrying...  
   default: Warning: Remote connection disconnect. Retrying...  
   default: Warning: Remote connection disconnect. Retrying...  
   default: Warning: Remote connection disconnect. Retrying...  
   default: Warning: Remote connection disconnect. Retrying...  
   default: Warning: Remote connection disconnect. Retrying...  
   default: Warning: Remote connection disconnect. Retrying...  
   default: Warning: Remote connection disconnect. Retrying...  
   default: Warning: Remote connection disconnect. Retrying...  

 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me