Skip to content

Instantly share code, notes, and snippets.

View dannylloyd's full-sized avatar

Danny Lloyd dannylloyd

  • University of Arkansas for Medical Sciences
  • Cabot, Arkansas
View GitHub Profile
@dannylloyd
dannylloyd / Output.vb
Created March 30, 2012 14:59
Write file to output stream
Context.Response.ContentType = "application/pdf; name=" & filename
Context.Response.AddHeader("content-disposition", "inline; filename=" & filename)
Context.Response.AddHeader("content-length", pdfBytes.Length.ToString())
Context.Response.BinaryWrite(pdfBytes)
Context.Response.End()
@dannylloyd
dannylloyd / GetColumns.sql
Last active December 15, 2015 00:09
Gets column name, type, and nullable from table definition
DECLARE @tableName varchar(50);
SET @tableName = '';
SELECT
COLUMN_NAME,
DATA_TYPE,
IS_NULLABLE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = @tableName
@dannylloyd
dannylloyd / SQL Table to VB Class.sql
Last active December 15, 2015 02:58
Converts SQL table to VB class
declare @TableName sysname
set @TableName = 'TableName'
declare @Namespace varchar(50)
set @Namespace = 'Namespace'
declare @prop varchar(max)
PRINT 'Imports PetaPoco '
PRINT ''
PRINT 'Namespace ' + @Namespace
PRINT '<TableName("' + @TableName + '")>'
@dannylloyd
dannylloyd / PagedRepeater
Created April 23, 2013 19:45
A repeater using bootstrap and pass a generic type
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="PagedRepeater.ascx.vb" Inherits="Website.PagedRepeater" %>
<div>
<table class='<%= Classes %>'>
<thead <%= If(rptData.Items.Count = 0, "style=""display: none;""", "")%>>
<%= HeaderTemplate%>
</thead>
<tbody>
<asp:ListView ID="rptData" runat="server">
<ItemTemplate></ItemTemplate>
</asp:ListView>
@dannylloyd
dannylloyd / PageRepeater.ascx.vb
Created April 23, 2013 19:46
Paged repeater code to populate data from generic object
Option Strict Off
Imports Extendo
Imports System.ComponentModel
Imports System.Reflection
<ParseChildren(True)>
Public Class PagedRepeater
Inherits System.Web.UI.UserControl
Public Property PageSize As Integer
Namespace Controls.Bootstrap
Public Class GridView
Inherits WebControls.GridView
Public Sub New()
UseAccessibleHeader = True
AddHandler DataBound, AddressOf UseTableHeaderTag
End Sub
@dannylloyd
dannylloyd / Audit.sql
Created May 21, 2013 17:41
Auditing for SQL server
UPDATE [dbo].person
SET FirstName = 'carl'
,LastName = 'smith'
,Updated = GETDATE()
OUTPUT 'UPDATE'
,DELETED.*
,INSERTED.*
INTO dbo.Person_History
WHERE person.id = 1
@dannylloyd
dannylloyd / SQL Table to CSharp.sql
Last active September 30, 2021 19:14
SQL Table to VB Class (SQL 2000)
declare @TableName sysname;
set @TableName = 'TABLENAME';
declare @Namespace varchar(50);
set @Namespace = 'NAMESPACE';
declare @prop varchar(8000);
DECLARE @NewLineChar AS CHAR(2) = CHAR(13) + CHAR(10)
PRINT 'using System; '
PRINT 'using NPoco; '
PRINT ''
PRINT 'namespace ' + @Namespace + ' {'
@dannylloyd
dannylloyd / TraceFormatter.js
Created August 8, 2013 14:53
Formats asp.net trace information into manageable blocks. Use it like this: formatTraceInformation('Trace-Information');. Where the preferedPane is the ID of the table of information you want to see first opened.
function formatTraceInformation(preferedPane) {
var tracer = $('#__asptrace');
var traceContent = $('span.tracecontent');
//$('*', tracer).removeAttr('style');
//Removes style from trace block
//$('*', tracer).remove('style');
if (tracer.length > 0 && $('#tracer_Show').length == 0) {
$('span.tracecontent > table', tracer).each(function (index, element) {
$(element).addClass('trace-table');
@dannylloyd
dannylloyd / Presence.vb
Created August 19, 2013 18:43
Get Lync Presence
Imports Microsoft.Lync.Model
Imports System.Threading
Public Class PresenceChecker
Private _contact As Contact
Dim waithandle As AutoResetEvent = New Threading.AutoResetEvent(False)
Dim state As ContactAvailability
Public Function GetUsersPresence(user As String) As ContactAvailability