Skip to content

Instantly share code, notes, and snippets.

View BenCoding's full-sized avatar

Ben Cassani BenCoding

View GitHub Profile
@BenCoding
BenCoding / mySnippets
Created May 13, 2013 15:49
mySnippets
New Code Test 1
@BenCoding
BenCoding / HideSideBar.htm
Created July 17, 2013 22:01
Hide Sharepoint SideBar
<!-- Hides Sharepoint SideBar -->
<style type="text/css">
#s4-leftpanel {
display:none;
}
.s4-ca {
margin-left:0px!important;
}
#MSO_ContentTable{
height:800px !important;
@BenCoding
BenCoding / If Prop Empty.js
Created January 21, 2014 18:57
Test for Empty Obj
function isEmpty(obj) {
for(var prop in obj) {
if(obj.hasOwnProperty(prop))
return false;
}
return true;
}
@BenCoding
BenCoding / AuthenticateAspClassic.asp
Last active August 29, 2015 14:06
AuthenticateUser ASP
<%@ language="VBScript" %>
<object runat="server" id="conn" progid="adoDB.Connection"></object>
<%
function AuthenticateUser(Username,Password,Domain)
dim strUser,strPass,strQuery,oConn,cmd,oRS
AuthenticateUser = false
strQuery = "SELECT $memberOf FROM 'OU=Salt Lake City,OU=Rocky Mountain,OU=Regional Business Units,DC=Tesoropetroleum,DC=com' WHERE $objectClass='user' AND $objectCategory='Person' AND $sAMAccountName='1CassaBD'"
set oConn = server.CreateObject("ADODB.Connection")
@BenCoding
BenCoding / PIML_Reports_SQL.sql
Created October 24, 2016 22:41
PIML Reports SQL Queries
/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP 1000 [TourID]
,[TourRunID]
,[TourRunTimeStamp]
,[TourRunDeviceID]
,[TourRunUserID]
,[TourRunUserName]
,[TourRunStatus]
,[TourRunComment]
,[TourRunCommentIndex]
@BenCoding
BenCoding / SQL Total CPU.sql
Created December 15, 2016 16:14
SQL Total CPU.sql
SELECT total_worker_time/execution_count AS AvgCPU
, total_worker_time AS TotalCPU
, total_elapsed_time/execution_count AS AvgDuration
, total_elapsed_time AS TotalDuration
, (total_logical_reads+total_physical_reads)/execution_count AS AvgReads
, (total_logical_reads+total_physical_reads) AS TotalReads
, execution_count
, SUBSTRING(st.TEXT, (qs.statement_start_offset/2)+1
, ((CASE qs.statement_end_offset WHEN -1 THEN datalength(st.TEXT)
ELSE qs.statement_end_offset
@BenCoding
BenCoding / YearlyMaint-Check-Tags.ps1
Created June 22, 2017 17:45
Change PI Tag InstrumentTag
#Find all HDA1 Tags
#June 2017
$myPiServer = "SLCUDS2"
$myPointSource = "HDA2" #MODIFY CAREFULLY
$serverPrefix = "SLCESVT02:" #MODIFY CAREFULLY
$counter = 0
$counterAll = 0
$tagsChanged = @()
@BenCoding
BenCoding / Export all Tables to CSV.sql
Last active October 27, 2020 21:30
Export all MSSQL Tables to CSV
-- Added Readme line
$server = "SERVERNAME\SQLEXPRESS"
$database = "JSP"
$tablequery = "SELECT schemas.name as schemaName, tables.name as tableName from sys.tables inner join sys.schemas ON tables.schema_id = schemas.schema_id"
#Delcare Connection Variables
$connectionTemplate = "Data Source={0};Integrated Security=SSPI;Initial Catalog={1};"
$connectionString = [string]::Format($connectionTemplate, $server, $database)
$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connectionString
@BenCoding
BenCoding / GrantSecurityNETFolder.vbs
Created October 30, 2020 08:03
Change .NET folder security
Dim objShell
Set objShell = CREATEOBJECT("Wscript.Shell")
'Created by BenCoding 2011
'Change .NET Security Permissions to All Network path to FullTrust
'http://msdn.microsoft.com/en-us/library/cb6t8dtz(v=vs.80).aspx
'THE TRUSTED FOLDER IS SET HERE 'K:/SFARSTDS/Acad_Support/VB.NET/
objShell.run("C:\WINNT\Microsoft.NET\Framework\v2.0.50727\CasPol.exe -pp off -m -ag 1.2 -url file://T:/Visual Studio* FullTrust")
objShell.run("C:\WINNT\Microsoft.NET\Framework\v2.0.50727\CasPol.exe -pp off -m -ag 1.2 -url file://M:/ACADLIB/0DSADMIN/Visual Studio* FullTrust")
@BenCoding
BenCoding / CleanEmptyFolders.ps1
Last active September 3, 2021 15:54
Remove Empty Directories
# Set to true to test the script
$whatIf = $true
# Remove hidden files, like thumbs.db
$removeHiddenFiles = $false
# Get hidden files or not. Depending on removeHiddenFiles setting
$getHiddelFiles = !$removeHiddenFiles
# Remove empty directories locally