Skip to content

Instantly share code, notes, and snippets.

@vaderj
vaderj / enable_disable_site_collection_feature.js
Last active June 12, 2018 16:55
Enable / Disable Site Collection Feature via JavaScript / ECMAScript #Javascript #SharePoint #SOAP
function OnSuccess(sender, args) {
alert("Success!");
}
function OnFail(sender, args) {
alert("Fail: " + args.get_message() + "\n" + args.get_stackTrace());
}
function ActivateFeature(url,guid)
{
@vaderj
vaderj / disable_site_collection_feature.cs
Last active June 12, 2018 15:01
Enable a Site Collection feature via CSOM #C# SharePoint #SOAP #CSOM
protected void removeMasterPage(object sender, EventArgs e)
{
var url = "<URL to site>"
using (ClientContext clientContext = new ClientContext(url))
{
Site spsite = clientContext.Site;
FeatureCollection siteFeatures = spsite.Features;
clientContext.Load(siteFeatures);
Guid masterPageFeatureGuid = new Guid("efcd0dac-835c-40ca-af13-c868d6cc13db");
siteFeatures.Remove(masterPageFeatureGuid, true);
# Win7 Powershell script to resize Minecraft to 1280x720 (HD for fraps youtube capture)
# use by typing the following at a command prompt:
# > PowerShell -ExecutionPolicy Bypass -File minecraft-sethd.ps1
# refs:
# http://stackoverflow.com/questions/2556872/how-to-set-foreground-window-from-powershell-event-subscriber-action
# http://richardspowershellblog.wordpress.com/2011/07/23/moving-windows/
# http://www.suite101.com/content/client-area-size-with-movewindow-a17846
@vaderj
vaderj / Blind-jQyery-Select.js
Last active June 12, 2018 17:06
Insert a parameter for flash "blind" (unable to use standard jQuery / DOM selectors due to encapsulation within nested <HTML><body></body></HTML>) #Javascript #SharePoint
$("<param name="wmode" value="transparent" />").insertBefore($(".ctl00_ctl50_g_d370373b_d026_4d10_95e6_b036fd690c31").contents().find('param.name:contains("allowFullScreen")'))
@vaderj
vaderj / solution-deployment status while loop.ps1
Last active June 12, 2018 17:06
Status of Solution Deployment timer job #PowerShell #SharePoint
While ((Get-SPTimerJob | ?{ $_.Name -like "*solution-deployment*" }) -ne $null) {Write-Host -NoNewLine .;Start-Sleep -s 2}
@vaderj
vaderj / mass-checking-splistItems.ps1
Last active June 12, 2018 17:06
Check-in / Publish / Approve all docs in a given lib #PowerShell #SharePoint #SSOM
$web = Get-SPWeb http://demo2010a:20905
$pages = "http://demo2010a:20905/Pages/TvAndRadioAlerts.aspx","http://demo2010a:20905/Pages/Systems.aspx"
$pages | ForEach-Object {
$item = $web.GetListItem($_)
if ($item.File.CheckOutType -ne "None")
{
$item.File.CheckIn("Automatically checked in by Powershell", "MajorCheckIn");
}
if ($item.Versions[0].Level -ne "Published")
{
@vaderj
vaderj / SPModalDialog.js
Last active June 12, 2018 17:07
Create a new SPModal instance, then do something on 'Cancel' or 'OK' #Javascript #SharePoint
function CloseCallback(result, target)
{
if(result === SP.UI.DialogResult.OK)
{
$('#canceledDiv').hide();
$('#displayDiv').hide();
$('#thankYouDiv').show();
//window.location.replace("http://stackoverflow.com");
}
if(result === SP.UI.DialogResult.cancel)
@vaderj
vaderj / SP-jQuery select list item element.js
Last active June 12, 2018 15:12
jQuery selector for SharePoint form.each TR has two TD's - one with 'ms-formlabel' class and one with 'ms-formbody' class #Javascript #SharePoint
IF IN A MODAL DIALOG
$(".ms-dlgFrame").contents().find('td.ms-formlabel:contains("Hospital")').siblings('.ms-formbody').text().length;
OTHERWISE:
@vaderj
vaderj / UserToken-PowerShell-SPSite.ps1
Last active February 27, 2020 19:15
#PowerShell #SharePoint #SSOM Instanciate SPSite object using a user token.From: http://w3foverflow.com/question/access-personal-views-in-a-list-with-powershell/This method allows for access to a users "Personal Views"
#Create a standard SPWeb object with admin credentials
$spweb = get-spweb http://url
#grab the user you want to instanciate under
$usr = $spweb.allusers | ? {$_.displayname -like "User Name"}
#make the user token accessable
$token = $usr.UserToken
@vaderj
vaderj / NodeJS-HTTP.js
Last active June 12, 2018 16:52
Quick HTTP server for Node.JS #Javascript #Node.JS
var http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);