Skip to content

Instantly share code, notes, and snippets.

View radleta's full-sized avatar

Richard Adleta radleta

View GitHub Profile
@radleta
radleta / TrimmedList.aspnet-mvc-4.razor
Created September 11, 2012 12:33
MVC 4 Razor Helper: TrimmedList
@helper TrimmedList(IEnumerable<string> list)
{
var fullList = list.ToListOrDefault();
if (fullList.Count > 0)
{<text>@fullList[0]</text>}
if (fullList.Count > 1)
{<text>, <a rel="expand" href="javascript:;" title="@fullList.Skip(1).Join(", ")">...</a></text>}
}
@radleta
radleta / TrimmedText.aspnet-mvc-4.razor
Created September 11, 2012 12:33
MVC 4 Razor Helper: TrimmedText
@helper TrimmedText(string text, int length)
{
if (text.IsNullOrWhiteSpace())
{ }
if (text.Length <= length)
{<text>@text</text>}
else
{<text>@text.Substring(0, length)<a rel="expand" href="javascript:;" title="@text.Substring(length)">...</a></text>}
}
@radleta
radleta / DateTimeConvert.asp
Created December 10, 2012 12:58
Date and Time conversion local to and from UTC for ASP.
<%
' ****************************************************************************
' Sub: GetUtcOffsetMinutes
' Description: Gets the number of minutes between local time and UTC.
'
' Params: None
' ****************************************************************************
Function GetUtcOffsetMinutes()
@radleta
radleta / SystemCenter.cs
Created December 12, 2012 13:57
A snippet to start and stop maintenance mode on a machine in System Center 2013.
/*
You need references to System Center 2013 assemblies:
* Microsoft.EnterpriseManagement.Runtime
* Microsoft.EnterpriseManagement.OperationsManager
* Microsoft.EnterpriseManagement.Core
*/
namespace SystemCenter.Utils
@radleta
radleta / List-Inline-Bullet-Seperated.less
Created February 27, 2013 12:59
Less Styles for an unordered inline list with the items seperated by bullets.
// Inline unordered list seperated by bullets
ul.list-inline-bullet-seperated
{
list-style-type: none;
li
{
display: inline-block;
}
li:before
{
@radleta
radleta / NearestMinute.sql
Created December 24, 2013 13:23
Round DateTime to Nearest Minute. Useful when grouping by DateTime to round to the nearest minute.
SELECT DATEADD(MINUTE, 1+DATEDIFF(MINUTE, 0, GETDATE()), 0) NearestMinute
@radleta
radleta / NearestHour.sql
Created December 24, 2013 13:25
Round DateTime to nearest hour. Useful when grouping by DateTime to round to the nearest hour.
SELECT dateadd(hour, datediff(hour, 0, GETDATE()), 0) NearestHour
@radleta
radleta / ElevatorSagaChallenge1.js
Created January 23, 2015 12:17
Elevator Saga Challenge #1
{
init: function(elevators, floors) {
var elevator = elevators[0]; // Let's use the first elevator
elevator.on("idle", function() {
// The elevator is idle, so let's go to all the floors (or did we forget one?)
elevator.goToFloor(0);
});
elevator.on("floor_button_pressed", function(floorNum) {
elevator.goToFloor(floorNum, true);
});
@radleta
radleta / ElevatorSagaChallenge2.js
Created January 23, 2015 12:30
Elevator Saga Challenge #2
{
init: function(elevators, floors) {
var elevator = elevators[0]; // Let's use the first elevator
elevator.on("idle", function() {
// The elevator is idle, so let's go to all the floors (or did we forget one?)
elevator.goToFloor(2);
});
elevator.on("floor_button_pressed", function(floorNum) {
elevator.goToFloor(floorNum, true);
});
@radleta
radleta / ElevatorSagaChallenge3.js
Created January 23, 2015 13:05
Elevator Saga Challenge #3
// URL: http://play.elevatorsaga.com/#challenge=3
{
init: function(elevators, floors) {
function initElevator(elevator) {
elevator.on("idle", function() {});
elevator.on("floor_button_pressed", function(floorNum) {
elevator.goToFloor(floorNum, true);
});
elevator.on("passing_floor", function(floorNum, direction) {