IsVisualStudio2012ProInstalled


Warning: count(): Parameter must be an array or an object that implements Countable in /home/cbc8fzob0jbt/domains/uhleeka.com/html/blog/wp-content/plugins/uhleeka-codebox/uhleeka-codebox.php on line 65

When trying to execute an SSIS package in Visual Studio 2012, I got the following error:

Method not found: ‘Boolean
Microsoft.SqlServer.Dts.Design.VisualStudio2012Utils.IsVisualStudio2012ProInstalled()’.
(Microsoft.DataTransformationServices.VsIntegration)

Stackoverflow pointed me in the right direction, http://stackoverflow.com/q/24745396/152852, but I needed to execute the gacutil.exe from the C:\Windows\System32 directory instead of the SDK folder.

C:\Windows\System32>gacutil.exe /if "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\Microsoft.SqlServer.Dts.Design.dll"
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.18020
Copyright (c) Microsoft Corporation.  All rights reserved.

Assembly successfully added to the cache

Now that the assembly is successfully added, restart Visual Studio 2012.

Git Sparse Checkout Exclude

To exclude a directory, first include everything (e.g. /*), then exclude the specific folder or file:

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ git config core.sparsecheckout true

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ echo '/*' > .git/info/sparse-checkout

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ echo '!a_directory_i_want_to_exclude/' >> .git/info/sparse-checkout

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ git read-tree -m -u HEAD

This works with git 2.1.4

$ git --version
git version 2.1.4
Filed Under: Git | Tagged:

Bash Setup

Base:

#green (local)
echo "export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '" >> ~/.bash_profile
#cyan (remote)
echo "export PS1='\[\e]0;\w\a\]\n\[\e[36m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '" >> ~/.bash_profile
#red (root)
echo "export PS1='\[\e]0;\w\a\]\n\[\e[31m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '" >> ~/.bash_profile

echo "" >> ~/.bash_profile

echo "export HISTSIZE=50000" >> ~/.bash_profile
echo "export HISTFILESIZE=50000" >> ~/.bash_profile

echo "" >> ~/.bash_profile

echo "alias ls='ls -al --color=auto'" >> ~/.bash_profile
echo "alias grep='grep --color=auto'" >> ~/.bash_profile
echo "alias sudo='sudo '" >> ~/.bash_profile
echo "alias vi='vim'" >> ~/.bash_profile

source ~/.bash_profile

curl -o ~/.vimrc http://amix.dk/vim/vimrc.txt

Git:

echo "" >> ~/.bash_profile

echo "function ps1_git_branch {" >> ~/.bash_profile
echo "    git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/';" >> ~/.bash_profile
echo "}" >> ~/.bash_profile
echo "export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\$(ps1_git_branch)\[\e[0m\]\n\$ '" >> ~/.bash_profile

echo "" >> ~/.bash_profile

echo "export HISTSIZE=50000" >> ~/.bash_profile
echo "export HISTFILESIZE=50000" >> ~/.bash_profile

echo "" >> ~/.bash_profile

echo "alias ls='ls -al --color=auto'" >> ~/.bash_profile
echo "alias grep='grep --color=auto'" >> ~/.bash_profile
echo "alias sudo='sudo '" >> ~/.bash_profile
echo "alias vi='vim'" >> ~/.bash_profile
echo "alias gitlog='git log --graph --pretty=format:'\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit --date=relative'" >> ~/.bash_profile

git config --global push.default simple
git config --global color.ui auto

source ~/.bash_profile

curl -o ~/.vimrc http://amix.dk/vim/vimrc.txt

PerformancePoint Dashboard Render Callback

Doing some JIT branding on a SharePoint 2010 site with bootstrap v2, I needed a way to determine when the PerformancePoint elements on a dashboard had finished loading. PerformancePoint has a problem (or maybe it’s my problem) calculating the width of its components with regard to bootstrap; I fooled it by giving the content area extra margin-left (67px in my case), and then taking it away once all PerformancePoint elements are loaded:

<script type="text/javascript">
    var NotifyBrowserOfAsyncUpdateTimeout = false;

    function NotifyBrowserOfAsyncUpdate(elem) {
        window.console && window.console.log('NotifyBrowserOfAsyncUpdate');
        if (NotifyBrowserOfAsyncUpdateTimeout) {
            clearTimeout(NotifyBrowserOfAsyncUpdateTimeout);
        }
        NotifyBrowserOfAsyncUpdateTimeout = setTimeout(function() {
            // do some stuff
            jQuery('#MSO_ContentTable').css('margin-left', '0');
            window.console && window.console.log('NotifyBrowserOfAsyncUpdateTimeout');
        }, 100);
    }
</script>

I added in the setTimeout/clearTimeout with a nominal 100ms duration, but it probably is not necessary; given some very light testing, by the time the first callback hits, PerformancePoint has correctly calculated the width of its components.

Credit: http://stackoverflow.com/questions/3372565/performancepoint-sharepoint-2010-and-jquery

Add git branch to a bash prompt

Add the following code to ~/.bash_profile or ~/.bashrc.

function ps1_git_branch {
    git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/'
}

export PS1="\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\$(ps1_git_branch)\[\e[0m\]\n\$ "

When in a folder that contains a .git repository, the current branch will show up in parenthesis.

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$

Looking for something more complicated? Check out richardhansen’s https://github.com/git/…/git-prompt.sh contribution.

SharePoint 2010 Secure Store shared service is not responding

When trying to manage the Secure Store Service in SharePoint 2010 I ran into an error stating that the “secure store shared service is not responding…”

ULS logs dumped the following critical error message:

08/30/2013 12:27:50.80	w3wp.exe (0x1AEC)
0x16E8	Secure Store Service
Secure Store
7557
Critical
The Secure Store Service application Secure Store Service is not accessible. The 
full exception text is: The HTTP service located at 
http://localhost:32843/SecurityTokenServiceApplication/securitytoken.svc/actas 
is too busy.
68b1350d-de57-4ee8-922b-19a771c0b31b

After stumbling around google for a while, I came across the following article which suggested that the Security Token service needed to be reprovisioned: http://blogs.msdn.com/b/sowmyancs/archive/2010/07/16/sharepoint-2010-service-applications-bcs-metadata-access-service-are-not-working.aspx

PS C:\Users\uhleeka> Get-SPServiceApplication

DisplayName          TypeName             Id
-----------          --------             --
Secure Store Service Secure Store Serv... a785c55d-74fe-4c36-b3f0-ead5ce920fd0
State Service        State Service        da12d0c8-4455-4ff0-8d78-fafc17495f72
PerformancePoint ... PerformancePoint ... 287024db-317b-4157-b1cf-48fad7997e46
Visio Graphics Se... Visio Graphics Se... e67b7b0b-89c7-413e-97a3-3bdd2181c2e3
Managed Metadata ... Managed Metadata ... 9a407eef-f763-4f8a-a40e-13fcfc731372
Web Analytics Ser... Web Analytics Ser... 9a6bd1b0-3318-4018-b06f-e9bfcbeab042
Excel Services Ap... Excel Services Ap... ae2b3782-8434-4259-8941-de7f6a10e752
Security Token Se... Security Token Se... aea1b402-c567-414a-87ec-de78ef1c050d
Application Disco... Application Disco... aa7cd819-184e-4be3-97ce-bab1ddaa5ccb
Usage and Health ... Usage and Health ... 6c149bc0-1d6f-464a-a191-51afa27e9f89
Search Administra... Search Administra... 9f714436-729e-42ea-a8f0-94cc9f659d7d
Word Automation S... Word Automation S... 5849509b-27bb-4ea3-9377-77261832f58b
User Profile Serv... User Profile Serv... ad8c6f20-4f57-4c6b-82c1-2ff2e4c3894c
Business Data Con... Business Data Con... b352de0b-1bb4-4998-83c2-93d239abcabf
Search Service Ap... Search Service Ap... 14e512ae-59fa-4a21-9cfd-9cfbc7392293


PS C:\Users\uhleeka> $sts = Get-SPServiceApplication | ?{$_ -match "Security"}
PS C:\Users\uhleeka> $sts

DisplayName          TypeName             Id
-----------          --------             --
Security Token Se... Security Token Se... aea1b402-c567-414a-87ec-de78ef1c050d


PS C:\Users\uhleeka> $sts.Status
Online
PS C:\Users\uhleeka> $sts.Provision()

PowerShell to the rescue. Thankx sowmyancs!

Git Sparse Checkout

From the root of your local git repo:

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ git config core.sparsecheckout true

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ echo a_directory_i_want_to_include/ > .git/info/sparse-checkout

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ echo another_directory_i_want_to_include/ >> .git/info/sparse-checkout

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ git read-tree -m -u HEAD

Validate:

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ ls
a_directory_i_want_to_include/ another_directory_i_want_to_include/
Filed Under: Git | Tagged:

SharePoint 2010 SPSecurity.RunWithElevatedPrivileges HandleAccessDenied

The Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges method enables you to supply a delegate that runs a subset of code in the context of an account with higher privileges than the current user.

Using SharePoint context with an unauthenticated user does not actually elevate privileges:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    // do something with SPContext.Current.Web 
    // fails with a HandleAccessDenied Exception
    // because SPContext is loaded with the site,
    // not within this delegate block.
});

So to get actual elevated privileges, you have to reload the context:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    using (SPSite site = new SPSite(this.Page.Request.Url.ToString()))
    {
        using (SPWeb thisWeb = site.OpenWeb())
        {
            // do something with thisWeb
        }
    }
});

See here for a better explanation: http://www.danlarson.com/spsecurity-runwithelevatedpriveleges/

C# Hash String to Hexadecimal String

Outputs a 40 character hexadecimal hash string using the MD5 algorithm.

private string ToHash(string source)
{
    byte[] bytes;
    char[] c;
    byte b;
	
    //using (SHA1 m = new System.Security.Cryptography.SHA1Managed())
    using (MD5 m = System.Security.Cryptography.MD5.Create())
    {
        bytes = m.ComputeHash(System.Text.UTF8Encoding.UTF8.GetBytes(source));
        c = new char[bytes.Length * 2];
        for (int i = 0; i < bytes.Length; ++i)
        {
            b = ((byte)(bytes[i] >> 4));
            // replace 0x57 with 0x37 to output uppercase
            c[i * 2] = (char)(b > 9 ? b + 0x57 : b + 0x30);
            b = ((byte)(bytes[i] & 0xF));
            // replace 0x57 with 0x37 to output uppercase
            c[i * 2 + 1] = (char)(b > 9 ? b + 0x57 : b + 0x30);
        }
    }
    return new string(c);
}