Skip to content

Instantly share code, notes, and snippets.

@srkirkland
srkirkland / cascadepublishstatus.sql
Last active December 20, 2015 15:49
Change publish status on child records IF the parent status changes
-- Is this a new publish status for the given org chart?
DECLARE @matchingStatus INT
SET @matchingStatus = (SELECT count(Id)
FROM [doa].[OrgChart]
WHERE PublishedStatusId = @publishedStatusId
AND Id = @id)
IF (@matchingStatus = 0) -- If so, update child records
BEGIN
UPDATE [doa].[OrgChart] set PublishedStatusId = @publishedStatusId
@srkirkland
srkirkland / immediatechild.sql
Created August 5, 2013 16:32
find immediate children given a specific parent LFT value. no nested children returned
SELECT Child.Id, Child.LFT, Child.RGT
FROM [doa].[OrgChart] AS Parent, [doa].[OrgChart] AS Child
WHERE
Child.LFT BETWEEN Parent.LFT AND Parent.RGT
AND NOT EXISTS ( -- No Middle Node
SELECT *
FROM [doa].[OrgChart] AS Mid
WHERE Mid.LFT BETWEEN Parent.LFT AND Parent.RGT
AND Child.LFT BETWEEN Mid.LFT AND Mid.RGT
AND Mid.Id NOT IN (Parent.Id, Child.Id)
@srkirkland
srkirkland / CourseSectionQuery.sql
Created August 13, 2013 22:09
common student service queries
SELECT c.TermCode
, c.Crn
, c.Subject
, c.CourseNumb
, c.Sequence
, c.Name
, s.SectionType
, s.StartDate
, s.EndDate
, s.StartTime
@srkirkland
srkirkland / openevals2.sql
Last active December 21, 2015 01:18
find students with open, non-completed evaluations
select distinct s.Email from ClassTimeEvaluations cte
inner join students s on s.ClassTimeId = cte.ClassTimeId
left join CompletedEvaluations ce on (ce.ClassTimeEvaluationId = cte.id AND ce.StudentId = s.Id)
where [start] < GETUTCDATE()
AND [end] > GETUTCDATE()
AND ce.Completed is null
AND s.Email is not null
@srkirkland
srkirkland / saotservice.cs
Created August 19, 2013 22:53
Populate and integrate the SAOT student services header/footer. This basically gives a backup/default version of the SAOT stuff for the first visitor and then kicks off an async process to download from the SAOT webservice and upon returning will use that information for every visitor to follow.
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Web.Configuration;
using Ace.Resources;
using Ace.Services.Caching;
namespace Ace.Services
{
@srkirkland
srkirkland / web.config.xml
Created September 25, 2013 19:21
web.config static content and caching sections
<!-- GZip static file content. Overrides the server default which only compresses static files over 2700 bytes -->
<httpCompression directory="%SystemDrive%\websites\_compressed" minFileSizeForComp="1024">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/json" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
@srkirkland
srkirkland / gist:7205348
Created October 28, 2013 21:41
how to get an MD5 string hash
var md5 = System.Security.Cryptography.MD5.Create();
var hash = md5.ComputeHash(System.Text.Encoding.ASCII.GetBytes(test ?? "Something"));
var str = BitConverter.ToString(hash).Replace("-", "");
@srkirkland
srkirkland / sqlhexhash.sql
Created November 14, 2013 23:44
create an MD5 hash in SQL
select *, CONVERT(varchar(32), HASHBYTES('MD5', Prompt + ':' + QuestionType + ':' + ScaleTerms), 2) as hashs from archive.responses
@srkirkland
srkirkland / inlineedit.cshtml
Created March 31, 2014 21:48
ckeditor stuff
@model dynamic
@{
ViewBag.Title = "Inline Edit";
}
<script src="http://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.3.2/ckeditor.js"></script>
<h2>Inline Edit</h2>
@srkirkland
srkirkland / crazyasync.cs
Created May 15, 2014 18:12
crazy async stuff
var combinedTask = Task.WhenAll(instructorSummaries
.Select(instructorSummary =>
_instructorTable
.ExecuteAsync(TableOperation.InsertOrReplace(instructorSummary))))
.ConfigureAwait(false);
var evaluationTask = _evaluationTable.ExecuteAsync(TableOperation.InsertOrReplace(overallSummary)).ConfigureAwait(false);
var result = new EvaluationTableResult
{