Skip to content

Instantly share code, notes, and snippets.

Avatar
🏡
Working remote and staying safe

Jason N. Gaylord jasongaylord

🏡
Working remote and staying safe
View GitHub Profile
View MainForm.Designer.cs
namespace TestTaskFactory
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
@jasongaylord
jasongaylord / delete_tables_byprefix.sql
Created Nov 16, 2012
TSQL - Delete Tables with a Prefix
View delete_tables_byprefix.sql
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 Dec 14, 2015
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.
View GetBusinessDay.sql
-- 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
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-…
View Get-ADComputerCDRomInfo.ps1
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 Dec 17, 2015
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…
View Theme.cs
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 Dec 18, 2015
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.
View BrowserFeatures.js
// 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 Dec 30, 2015
A jQuery version of the capslock.html GIST found at https://gist.github.com/jasongaylord/7797819.
View capslock-jquery.html
<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 Jan 16, 2016
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.
View SecureStringHelper.cs
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 Jan 29, 2016
A partial IdentityConfig.cs snippet
View IdentityConfig.cs
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 Feb 3, 2016 — forked from anonymous/index.html
JS Bin canvas.getContext() Sample // source http://jsbin.com/vujasi
View index.html
<!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>