Skip to content

Instantly share code, notes, and snippets.

@vaderj
vaderj / Direwold_ScreenStartup
Last active June 12, 2018 17:03
Direwolf Raspberry Pi RasPi startup with Screen rtl sdr #BASH #Linux #pi
#In the dw-start.sh script, change the DWCMD definition to read:
#
#DWCMD="screen -dm -S direwolf bash -c 'rtl_fm -f 144.39M - | direwolf -c sdr.conf -r 24000 -D 1 -'"
#
#
# And then, as that command is ran via cron, you can access that screen via:
#
# screen -r direwolf
#
@vaderj
vaderj / Add-webpart-to-pubPage.ps1
Last active June 12, 2018 17:00
Add a web part to a publishing page #PowerShell #SharePoint
############
#
# From:
# http://www.sharepointpals.com/post/How-to-Add-WebPart-to-the-Publishing-Page-using-PowerShell-in-SharePoint-2013
#
#
############
# Add PowerShell Snapin
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
@vaderj
vaderj / rejectSPdoc.js
Last active June 12, 2018 15:00
reject a SP document #Javascript #REST #SharePoint
function rejectDocument(docId)
{
jQuery.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Resource Library')/items(" + docId + ")/file/deny('Rejected')",
type: "POST",
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
},
@vaderj
vaderj / updateSharePoint_ScreenWithoutRefresh.js
Last active June 12, 2018 17:03
screen update without refresh (with SP) #Javascript #SharePoint
function clearPostBack() {
$get('__EVENTTARGET').value = $get('__EVENTARGUMENT').value = '';
Sys.WebForms.PageRequestManager.getInstance().remove_endRequest(clearPostBack);
// TODO: anything you want after __doPostBack
iterateList(jQuery("#scriptWPQ2 > table[summary='Resource Library'] > tbody > tr")) ;
}
function myPostBack(eventTargetClientId, eventArgument) {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(clearPostBack);
@vaderj
vaderj / checkoutSPdocumentViaREST.js
Last active June 12, 2018 15:01
Check out a document #Javascript #REST #SharePoint
function checkOutDocument(docId)
{
jQuery.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Resource Library')/items(" + docId + ")/file/CheckOut()",
type: "POST",
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": jQuery("#__REQUESTDIGEST").val(),
},
success: function(){
@vaderj
vaderj / SPList-REST.html
Last active June 11, 2018 20:40
Utilize a SPList as a lookup.Script includes HTML and JS. List is populated by PowerShell script Field-Org-SQL-TO-SPList.ps1 #Javascript #SharePoint
<style>
</style>
<div class="container-fluid" id="main">
<div id="target">
<span>Select the columns you would like returned: </span> <br>
@vaderj
vaderj / new_gist_file_0
Last active June 12, 2018 17:00
PowerShell => MS SQL - just to verify that a connection is correctly setup.This is equivalent to "The UDL trick" #PowerShell #SQL #Windows
# Open a connection to the SQL Server Database Engine
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection
$sqlConnection.ConnectionString = "Server=SQLDB2016\SHAREPOINT;Database=master;Integrated Security=True"
$sqlConnection.Open()
# Query the master database
$sqlCommand = New-Object System.Data.SqlClient.SqlCommand
$sqlCommand.CommandText = "SELECT name FROM [master].[sys].[databases]"
$sqlCommand.Connection = $sqlConnection
@vaderj
vaderj / Alternative_Excel_Unlock
Last active June 8, 2021 02:32
#VBA Two methods of unlocking a locked excel sheet:VBA macro for Excel that should unprotect a password protected sheet,Opening the spreadsheet as XML and removing the specific piece
Step 1. Make a copy of the spreadsheet in an empty directory. Rename the extension to .zip
Step 2. Extract the zip file.
Step 3. In the extracted contents, goto the folder \xl\worksheets\
Step 4. There should be one xml file per sheet? I editing "sheet1.xml" with NotePad++. From nearly the very end of the file, remove the tag that starts with:
<sheetProtection
My entire tag was as follows:
<sheetProtection algorithmName="SHA-512" hashValue="ALciNBSIqRcjDiFbCuyWoGk4iOcC/ZRKnEjwEVi1skb6G5JbHhp+QVZ9+rlPVbGILOS7lYiCvJmR4Q7IuSphXA==" saltValue="8OVKXrG0VacLOLVztUpEYw==" spinCount="100000" sheet="1" objects="1" scenarios="1" selectLockedCells="1"/>
Step 5. Save the file. Open the ZIP file in 7zip, find the same file, drag and drop, save, exit, rename the file back to (xlsx) and open
@vaderj
vaderj / new_gist_file_0
Last active June 12, 2018 17:01
RegEx used for SharePoint search query rulesquery terms must contain all three words: hospital, marketing, guide(?i: = case insensitive #RegEx #SharePoint
^(?i:(?=.*\bhospital\b)(?=.*\bmarketing\b)(?=.*\bguide\b)).+
@vaderj
vaderj / enable-numberedList-in-RichTxtEditor.js
Last active June 12, 2018 16:56
This will enable the numbered list box based on the click event of the specific rich text box, if there is a 'p' tag #Javascript #SharePoint
$(".ms-rtestate-write[id*='Steps']").click(function (){
if ($(".ms-rtestate-write[id*='Steps'] ol").legth > 0)
{
return;
}
else if ($(".ms-rtestate-write[id*='Steps'] p").length > 0)
{
RTE.RichTextEditor.numberedList();
}
});