Skip to content

Instantly share code, notes, and snippets.

View jasongaylord's full-sized avatar
⏲️
Trying to find time to code.

Jason N. Gaylord jasongaylord

⏲️
Trying to find time to code.
View GitHub Profile
@jasongaylord
jasongaylord / MainForm.Designer.cs
Created June 19, 2012 03:33 — forked from anonymous/MainForm.Designer.cs
TaskFactoryWithUIUpdates
namespace TestTaskFactory
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
@jasongaylord
jasongaylord / delete_tables_byprefix.sql
Created November 16, 2012 22:49
TSQL - Delete Tables with a Prefix
declare @cmd varchar(4000)
declare cmds cursor for
Select 'drop table [' + Table_Name + ']'
From INFORMATION_SCHEMA.TABLES
Where Table_Name like 'prefix%'
open cmds
while 1=1
begin
@jasongaylord
jasongaylord / GetBusinessDay.sql
Last active December 14, 2015 13:48
I had a request to show the calendar for the last 7 business days a part time employee worked. However, to ensure that I have the correct start date to show a 2 week calendar, I needed to omit any day the person was off. It's a strange request, but this is interesting.
-- Assume that we have a table that tracks the days off. We'll define it here
-- when actually we'd be pulling this from our connection.
declare @myDaysOff table
(
dayOff datetime
)
-- Let's seed this table
insert into @myDaysOff (dayOff)
values ('2/20/2013'), ('2/27/2013'), ('3/2/2013'), ('3/3/2013')
@jasongaylord
jasongaylord / Get-ADComputerCDRomInfo.ps1
Created May 29, 2013 17:56
We have CD-Roms that float around and for some reason, we can never find it. This PowerShell script will connect to Active Directory, pull all of the computers, and check each for a CD-Rom. It will populate the machine name, drive letter, disk name (if available), and any errors that result. Keep in mind that a Windows XP machine reports the CD-…
Function Get-ADComputerCDRomInfo
{
# Search Active Directory for computers
([adsisearcher]"objectcategory=computer").findall() | ForEach-Object {
# Set computer name
$c = ([adsi]$_.path).Name;
# Function variables
$deviceId = ""
$volumeName = ""
@jasongaylord
jasongaylord / Theme.cs
Last active December 17, 2015 22:09
This class can be copied into any of your phone applications. I usually create a file called Theme.cs and paste it in there. In the App.xaml.cs file, update Application_Launching and Application_Activeated to call Theme.Detect(). This will call the static method called Detect which will, in turn, populate the properties listed. I've blogged abou…
public static class Theme
{
public static SolidColorBrush Foreground { get; private set; }
public static ThemeColor CurrentTheme { get; private set; }
public static bool IsLightTheme { get { return CurrentTheme == ThemeColor.Light; } }
public static bool IsDarkTheme { get { return CurrentTheme == ThemeColor.Dark; } }
public enum ThemeColor
{
Light,
@jasongaylord
jasongaylord / BrowserFeatures.js
Last active December 18, 2015 05:38
This is an example snippet that demonstrates how to check for a feature and perform an action based on that detection. In this example, we are checking for the new getUserMedia() method. This method is not fully implemented as of the post date. Therefore, the HTML file is grabbing the feature specifically for the WebKit browsers.
// Check to see if jQuery is loaded. If not, load it from the public jQuery CDN.
if (typeof jQuery == 'undefined') {
// Load the latest jQuery library from jQuery
document.write("\<script src='http://code.jquery.com/jquery-latest.min.js' type='text/javascript'>\<\/script>");
}
// Create new BrowserFeatures object
var BrowserFeatures = {
init: function () {
// GetUserMedia
@jasongaylord
jasongaylord / capslock-jquery.html
Last active December 30, 2015 09:39
A jQuery version of the capslock.html GIST found at https://gist.github.com/jasongaylord/7797819.
<html>
<head>
<title>Test Caps Lock</title>
</head>
<body>
<div id="capsLockWarning" style="font-weight: bold; color: maroon; margin: 0 0 10px 0; display: none;">Caps Lock is on.</div>
Username: <input type="text" id="username" /><br/>
Password: <input type="password" id="password" />
</body>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
@jasongaylord
jasongaylord / SecureStringHelper.cs
Last active January 16, 2016 02:06
A Helper method to convert a string value to a SecureString value. This is most useful when needing to pass a sensitive value, such as a social security number or password, around as a string on the server side. The SecureString class has a Dispose method for GC.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Web;
namespace Gaylord.Helpers
{
public static class SecureStringHelper
{
@jasongaylord
jasongaylord / IdentityConfig.cs
Created January 29, 2016 02:28
A partial IdentityConfig.cs snippet
public class ApplicationSignInManager : SignInManager<ApplicationUser, string>
{
public ApplicationSignInManager(ApplicationUserManager userManager, IAuthenticationManager authenticationManager)
: base(userManager, authenticationManager)
{ }
public override Task SignInAsync(ApplicationUser user, bool isPersistent, bool rememberBrowser)
{
if (!user.EmailConfirmed)
{
@jasongaylord
jasongaylord / index.html
Created February 3, 2016 05:09 — forked from anonymous/index.html
JS Bin canvas.getContext() Sample // source http://jsbin.com/vujasi
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<meta name="description" content="canvas.getContext() Sample">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>