Monday, February 13, 2017

spviewscope

$site=Get-SPSite $siteURL $web=$site.RootWeb $list=$web.Lists.TryGetList($listName) if($list -ne $null) { write-host -f green $listName "exists in the site" } else { write-host -f yellow $listName "does not exist in the site"

Friday, January 27, 2017

json

https://gist.github.com/chrisobriensp/7685240 \\sdctwp0253\LivraisonIC\TopAppsMasterDataRepository-dev\2017-02-08_17-11-24_TopAppsMasterDataRepository-dev_1.0.2.44655\APPS\SPDeploy Add-PSSnapin Microsoft.Sharepoint.Powershell $site = Get-SPSite "SiteURL" $sitelists = foreach ($web in $site.AllWebs) { foreach($list in $web.lists){ $list }} $sitelists |select Title | Export-CSV C:\liststitles.csv Remove-PsSnapin Microsoft.SharePoint.PowerShell
http://topshare.corp.ponet/sites/cs1369-ResearchProjectTool/_layouts/15/WopiFrame.aspx?sourcedoc=/sites/cs1369-ResearchProjectTool/Shared%20Documents/Detailed%20Description%20of%20Business%20Need.docx&action=default
http://topshare.corp.ponet/sites/cs1369-ResearchProjectTool/_layouts/15/WopiFrame.aspx?sourcedoc=/sites/cs1369-ResearchProjectTool/Shared%20Documents/Specifications%20-%20Research%20Project%20Tool%20-%20Phase%202.docx&action=default # declare an array to store results $results = @() # fetch databases (only configuration and content DBs are needed) $databasesToQuery = Get-SPDatabase | Where-Object {$_.Type -eq 'Configuration Database' -or $_.Type -eq 'Content Database'} | Sort-Object –Property Name # for each database get spshelladmins and add db name and username to result $databasesToQuery | ForEach-Object {$dbName = $_.Name; Get-SPShellAdmin -database $_.id | Sort-Object $_.username | ForEach-Object {$results += @{$dbName=$($_.username)}}} # sort results by db name and pipe to table with auto sizing of col width $results.GetEnumerator() | ft -AutoSize

Thursday, April 7, 2016

$(function() { var isCustomerNominated = $("#IsCustomerNominated"); hideAirline.call(isCustomerNominated); isCustomerNominated.on("change", function (e) { hideAirline.call($(this)); }) }); function hideAirline() { var contractedAirline = $("#contractedAirline"); if (this.is(":checked")) { contractedAirline.css("visibility", "visible"); } else { contractedAirline.css("visibility", "hidden"); } }

Tuesday, May 13, 2014

Initializing xslt variable with static content

I had to use a variable in an xslt template. The value for that variable would be returned by a stored procedure at a SQL Server DB. So, I decided to populate the variable with static content:

    <xsl:variable name="hideColumns" select ="'ISBN,author_id,vendor_id'" />

Populated with the static content, the variable proved to be a good replacement for the real-life data. So, as soon as the stored procedure was deployed, my xslt template was readily updated with the appropriate select statement in the hideColumns variable declaration.

Tuesday, April 29, 2014

T-SQL: COALESCE returns int for integer operations


DECLARE @can_import BIT

PRINT CAST (SQL_VARIANT_PROPERTY(COALESCE(@can_import, 0), 'BaseType') AS VARCHAR(20))

Result:
int

Thursday, April 17, 2014

jQuery | remove inline style

Summary: The jQuery.UI dialog widget can be called on a dynamically created <div />. In this case, the element will have its height set to 30px. A possible solution could be setting height to the empty string using the css() method.

Normally the jQuery.UI dialog is called on an existing element. But it can also be bound to a dynamically created element:
var confirmText = Would you like to edit this task as the administrator user?';

// dynamically create <div /> to call the dialog on
$('<div />').appendTo(document.forms[0])
 .attr('id', 'div1')
 .attr('title', 'Dialog Title')
 .text(confirmText);

// initialize the dialog
$('#div1').dialog();
The resulting dialog assigns div1 to the message pane. But it also adds inline styling that squeezes div1 to the height of 30px, like this:
To fix this issue just remove the height style from div1:
$('#div1').dialog().css('height', '');
This seems to be a sensible solution as the docs (http://api.jquery.com/css/#css2) are saying:
Setting the value of a style property to an empty string — e.g. $('#mydiv').css('color', '') — removes that property from an element if it has already been directly applied, whether in the HTML style attribute, through jQuery's .css() method, or through direct DOM manipulation of the style property. It does not, however, remove a style that has been applied with a CSS rule in a stylesheet or

Tuesday, October 16, 2012

Enable the full .NET Framework in Console Application

Console Projects created by Visual Studio 2010 support only a limited subset of the .NET Framework (read more about this on MSDN). This means that for such projects some libraries will be filtered away by VS2010 from the Add a Reference dialog.
To gain access to all .NET libraries available on your PC, you may want to tweak the element called TargetFrameworkProfile in the project file (=<your-project-name>.csproj). Follow the steps below:
  1. Open that file in a code editor of your choice (for example, in Notepad++),
  2. Find the TargetFrameworkProfile element. Notice that it is set to Client like below:
    <TargetFrameworkProfile>Client</TargetFrameworkProfile>.
  3. Change it to <TargetFrameworkProfile  />.
  4. Then restart the project and enjoy the full version of the .NET Framework!
Note: As of .NET 4.5, the TargetFrameworkProfile property is discontinued (for more details see here).

Friday, October 5, 2012

Enable JSON serialization in your Visual Studio 2010 project

As far as I know, the project templates shipped with Visual Studio 2010 do not support JSON serialization out of the box. An additional library should be referenced by the project in order for the JSON serialization to be enabled. To add it, right-click on the References section, select Add Reference, go to the .NET tab and proceed to System.Runtime.Serialization:

Now you are ready to import the System.Runtime.Serialization.Json namespace to your source code!

Saturday, April 21, 2012

Unhide a table row – a cross browser solution

When you need to hide an element on a web page, you would probably make use of the display: none style. But what if you have a table row hidden with display: none and you need to unhide it? Probably you would change its display property to table-row.
Regrettably, this solution may break down a table in IE7 or IE8. IE will show a table row in a proper manner with display: inline-block only. To make the layout compatible across multiple browsers, you may either opt for conditional comments or rely on style overriding:

Conditional Comments

Create two sets of styles – one tuned for IE and another for the rest of browsers, and load them according to the user agent, like below:
<!--[if IE]>
<style type="text/css">.ticker-row { display: inline-block; }
</style>
<![endif]-->
<!--[if !IE]> -->
<style type="text/css">.ticker-row { display: table-row; }
</style>
<![endif]-->
The style declared first works in IE, whereas the second works in the rest of the browsers. Please note conditional comments are not understood by the style sheet processor, so you are allowed to include them in HTML markup only.

Style Overriding

Browsers like Fire Fox, Chrome or Opera, unlike IE, all understand display: table-row, and will readily override display: inline-block in the following declaration:
.ticker-row { display: inline-block; display: table-row; }
IE is blissfully unaware that display may have table-row value so will ignore it.

Friday, June 17, 2011

Effective usage of the value parameter in setters: an example with WebHeaderCollection

A couple of days ago I had to implement a read/write property that would store a WebHeaderCollection associated with a web response. My first take on that was to create an automatic property that would handle getting and setting the values. So far, so good.
Yet, when I tried to assign the value wrapped by that property to a Header collection associated with a Request object, the application threw an exception. After googling awhile I found out that ASP.NET prevents the code from setting some HTTP headers for the request. So, if I were to set the property appropriately, only “eligible” headers would be copied from the response. I decided to stash the filtering in the setter:

private static WebHeaderCollection _WikiHeaders;
public static WebHeaderCollection WikiHeaders
{
  get
  {
    return _WikiHeaders;
  }
  set
  {
    if (null != value as WebHeaderCollection)
    {
      _WikiHeaders.Clear();
      // the value parameter is implicitly typed as WebHeaderCollection
      foreach (string webHeader in value.Keys)
      {
        // check if the current header can be set for the request
        if (!WebHeaderCollection.IsRestricted(webHeader))
            _WikiHeaders.Add(webHeader, value[webHeader]);
      }
    }
  }
}

To my mind, there are two important points about the property described above:
  1. The value parameter is implicitly typed as the property itself – the JIT compiler enforces that. So, you can safely assume that if the property is of the WebHeaderCollection type, then the value parameter is of the same type, too. By implication, you can treat the value parameter as a variable of the respective type (call its methods, get or set properties, etc.)
  2. The WebHeaderCollection.IsRestricted() static method is useful for testing if an HTTP header can be set for the request. It saves programmers from having to author such a checker from scratch and helps them focus on business logic.
BTW, the property I was talking about in this post could be used like below:
Response.Headers = WikiHeaders;