Skip to content

Instantly share code, notes, and snippets.

View kitmenke's full-sized avatar

Kit Menke kitmenke

View GitHub Profile
@kitmenke
kitmenke / gist:9782966
Created March 26, 2014 13:20
Update a report's shared data source
string itemPath = "http://servername/sites/reporting/Report Library/My_Report.rdl";
string dataSourceName = "Datasource1";
DataSource[] dsarray = new DataSource[1];
DataSourceReference reference = new DataSourceReference();
reference.Reference = "http://servername/sites/reporting/Data Sources/DATA_SOURCE_NET.rsds";
dsarray[0] = new DataSource();
dsarray[0].Name = dataSourceName;
dsarray[0].Item = reference;
@kitmenke
kitmenke / changeSubscriptionOwner.ps1
Created November 25, 2014 19:04
Powershell script to change the owner of a subscription to another user
Write-Host '*************************************'
Write-Host 'Change Subscription Owner starting...'
Write-Host '*************************************'
$oldOwner = "domain\user1"
Write-Host "Old Owner = $oldOwner"
$newOwner = "domain\user2"
Write-Host "New Owner = $newOwner"
$itemPathOrSiteURL = "http://servername/sites/subsite"
Write-Host "Item Path or Site URL = $itemPathOrSiteURL"
$reportServerUri = "http://servername/_vti_bin/ReportServer/ReportService2010.asmx?wsdl"
@kitmenke
kitmenke / setfromurl.html
Last active September 24, 2015 02:48
Auto-populate a SharePoint field using a URL Parameter
<script src="/kitsite/Files/jquery-1.11.0.min.js"></script>
<script src="/kitsite/Files/sputility.min.js"></script>
<script>
// url parsing from http://stackoverflow.com/a/2880929/98933
var urlParams;
(window.onpopstate = function () {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
@kitmenke
kitmenke / GivePrincipalRoleToItem.cs
Created April 9, 2012 14:50
Code to give one role (Read, Contribute, etc) to an SPPrincipal
public static void GivePrincipalRoleToItem(SPWeb web, SPListItem item, SPPrincipal principal, string roleDefinitionName)
{
if (null == principal)
{
throw new ArgumentException(string.Format("Unable to give role '{0}'; passed principal is null.", roleDefinitionName));
}
bool exists = false;
SPRoleAssignment roleAssignment = null;
try
@kitmenke
kitmenke / GetCurrentUser.js
Created July 5, 2012 21:59
Example AJAX call
$.ajax({
'url': '/_vti_bin/EHI/Users.svc/json/GetCurrentUser',
'dataType': 'json',
'type': 'GET',
'success': function(data) {
self.currentUser(new Employee(data.d));
},
'error': function() {
console.log("Error getting current user.");
}
@kitmenke
kitmenke / mysite
Last active October 9, 2015 11:08
Apache2 Virtualhost Example configuration
<VirtualHost *>
ServerAdmin webmaster@localhost
ServerName mysite
DocumentRoot /home/kit/code/public_html/mysite
<Directory /home/kit/code/public_html/mysite>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
@kitmenke
kitmenke / gist:4953860
Last active December 13, 2015 18:18
Custom JsRender debug tag
/**
* Custom JsRender debug tag
* Log a message and an object to the console.
* Usage: {{debug #parent message='Inside the for loop'/}}
**/
$.views.tags({
debug: function(obj) {
var props = this.props;
// output a default message if the user didn't specify a message
var msg = props.message || 'Debug:';
@kitmenke
kitmenke / ajax.js
Last active December 17, 2015 01:19
JsRender templates for creating SOAP messages to call the QueryEx Search.asmx service
function encodeHTML(str) {
return str.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&apos;');
}
var queryXml = $('#tmplQueryXml').render({
'QueryText': $('#txtQueryText').val(),
'Count': 100,
'StartAt': 1
});
@kitmenke
kitmenke / HandySafeXmlToSkyWalletCsv.py
Created July 31, 2013 04:14
Convert a HandySafe exported XML file to a CSV file for Sky Wallet to import.
# HandySafeXmlToSkyWalletCsv.py
# Convert HandySafe XML to Sky Wallet CSV
# Save the HandySafe export as test1.xml (hard coded below)
# Then, run: python HandySafeXmlToSkyWalletCsv.py > output.txt
# Tested using Python 2.7.4
# Author: Kit Menke (@kitmenke) on 7/30/2013
import csv, xml.etree.ElementTree as ET
# CHANGE ME: change HANDY_SAFE_XML with the name of your exported HandySafe XML file
@kitmenke
kitmenke / WebForm1.aspx.cs
Created August 27, 2013 18:31
Example for calling the Microsoft Translator AJAX API using jQuery
private static AdmAuthentication _admAuth = new AdmAuthentication(AdmConstants.CLIENT_ID, AdmConstants.CLIENT_SECRET);
protected void Page_Load(object sender, EventArgs e)
{
txtAuthToken.Text = _admAuth.GetAccessToken().access_token;
txtAuthExpires.Text = _admAuth.GetAccessToken().expires_in;
}