Skip to content

Instantly share code, notes, and snippets.

@vaderj
vaderj / arduino i2c scanner
Last active February 27, 2020 19:16
#Arduino i2c scanner
// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011
#include <Wire.h>
void setup() {
Serial.begin (115200);
Serial.println ();
@vaderj
vaderj / CAML Query 1.xml
Last active June 12, 2018 17:05
Generic CAML query by title #CAML #SharePoint
// assuming that sTitle = a string of the title
'<Where><Eq><FieldRef Name="Title" /><Value Type="Text">' + sTitle + '</Value></Eq></Where>';
@vaderj
vaderj / SCRAPcopySomeFilesWithVersions.cs
Last active June 11, 2018 20:36
(Not working) Copy file with versions & metadata #c# #SharePoint
static void SCRAPcopySomeFilesWithVersions(SPListItem srcItem, SPList destList)
{
SPFile oFileSrc = srcItem.File;
//Console.WriteLine(oFileSrc.Title.ToString());
byte[] srcByteArray = null;
SPFile SPFileDestination = null;
SPFileCollection collFilesDest = destList.RootFolder.Files;
SPTimeZone timezone = destList.ParentWeb.RegionalSettings.TimeZone;
@vaderj
vaderj / SharePoint-SSOM-CopyFilesWithVersions.cs
Last active June 12, 2018 16:52
Simple Copy file #C# SharePoint #SSOM
static void copySomeFilesWithNoVersion(SPListItem srcItem, SPList destList) // Leaving this here to reference in the future
{
SPFile oFileSrc = srcItem.File;
Console.WriteLine(oFileSrc.Title.ToString());
Stream srcStream = oFileSrc.OpenBinaryStream();
SPFileCollection collFilesDest = destList.RootFolder.Files;
try
{
@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);
@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 / 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 / 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 / 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 / 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}