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 / RazorComment.cshtml
Created January 29, 2016 19:34
Razor xml comment format. Add descriptive comment to method
@functions{
/// <summary>
/// Prints a random number followed by name
/// </summary>
/// <param name="name">The name to be printed</param>
}
@helper SayHello(string name) {
int randomNumber = 4; // A random number
@randomNumber @name
}
@dannylloyd
dannylloyd / CustomAuthorizationAttribute.cs
Last active January 8, 2016 16:16
Custom attribute in MVC
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Web.Core.Common
{
public class AuthorizeForEnvironmentsAttribute : AuthorizeAttribute
{
@dannylloyd
dannylloyd / jquery.alerts.js
Created November 17, 2015 20:09
Javascript alerts using bootstrap and jquery
//Name: Alerts
//Author: Danny Lloyd 1.0
var Alerts = (function () {
var internalAlert = function (type, message) {
var li = $('<li class="alert alert-' + type + '">'
+ '<span class="glyphicon glyphicon-' + getIcon(type) + '" style="padding-right:5px;"></span> ' +
message +
'</li>');
$('#alerts').append(li);
};
@dannylloyd
dannylloyd / MVC Checkboxlist.cshtml
Last active October 29, 2015 22:26
Checkbox list for MVC. Get data at the top of the view, then select the values you want selected from a list of integers #mvc
@{
ViewBag.Title = "Edit";
Layout = "~/Views/Shared/_Layout.cshtml";
//Get list of objects (users) from database
var users = new Web.Core.Data.Account().GetUsers();
}
<div class="form-group">
<div class="col-md-2">
<label>Approvers</label>
@dannylloyd
dannylloyd / Calendar.aspx
Created August 4, 2015 18:20
Aspx for calendar
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Calendar.aspx.vb" Inherits="Calendar" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style>
div.calendar {
font-family: sans-serif;
@dannylloyd
dannylloyd / Diy html calendar.vb
Last active August 29, 2015 14:26
Html calendar
Partial Class Calendar
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
RenderCalendar()
End If
End Sub
@dannylloyd
dannylloyd / DropAllObject.sql
Created June 5, 2015 16:25
Deletes all objects in database
/* Drop all non-system stored procs */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name])
WHILE @name is not null
BEGIN
SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
@dannylloyd
dannylloyd / ComputerName.bat
Created April 24, 2015 15:29
Get Compuer name from IP address
PING -A xxx.xxx.xxx.xxx
@dannylloyd
dannylloyd / EmptyDataText.vb.aspx
Created April 10, 2015 20:56
Empty data text for repeater
<asp:Repeater ID="rpt" runat="server">
<ItemTemplate>
Item template
</ItemTemplate>
<FooterTemplate>
<asp:PlaceHolder runat="server" Visible="<%# rptSubmissions.Items.Count = 0%>">
<div class="row" style="border-top: solid 3px #E9E9E9; padding-bottom: 10px;">
<span style="font-style:italic; font-weight: bold;">No data</span>
</div>
</asp:PlaceHolder>
@dannylloyd
dannylloyd / LargestTables.sql
Created April 7, 2015 12:43
Displays tables with most rows in database
--Copied from here http://stackoverflow.com/questions/2094436/how-to-find-largest-objects-in-a-sql-server-database
SELECT t.NAME AS TableName,
i.name AS indexName,
SUM(p.rows) AS RowCounts,
SUM(a.total_pages) AS TotalPages,
SUM(a.used_pages) AS UsedPages,
SUM(a.data_pages) AS DataPages,
(SUM(a.total_pages) * 8) / 1024 AS TotalSpaceMB,
(SUM(a.used_pages) * 8) / 1024 AS UsedSpaceMB,
(SUM(a.data_pages) * 8) / 1024 AS DataSpaceMB