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
@jasongaylord
jasongaylord / capslock.html
Last active Mar 22, 2021
A few JavaScript functions to detect if caps lock is on or not. More can be read about this at:
View capslock.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 language="javascript">
@jasongaylord
jasongaylord / IEUserAgentTest.html
Last active Jan 1, 2021
A sample JavaScript file to detect IE compatibility mode and version. This is not recommended unless absolutely needed as features should be detected instead.
View IEUserAgentTest.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Testing IE Compatibility Mode</title>
<script src="ieUserAgent.js" type="text/javascript"></script>
</head>
<body>
<div id="results">Results:</div>
<script type="text/javascript">
var val = "IE" + ieUserAgent.version;
@jasongaylord
jasongaylord / pr-webhook-schema.json
Created Sep 23, 2020
GitHub WebHook API Pull Request Schema
View pr-webhook-schema.json
{
"type": "object",
"properties": {
"action": {
"type": "string"
},
"number": {
"type": "integer"
},
"pull_request": {
@jasongaylord
jasongaylord / beacon.html
Created Aug 27, 2020
Beacon CSS - An example using CSS animations to create a beacon for use on something like a map or to call attention visually.
View beacon.html
<!DOCTYPE HTML>
<html lang="en">
<head>
<style>
.dot {
background-color: red;
border-radius: 50%;
width: 20px;
height: 20px;
display: block;
@jasongaylord
jasongaylord / New-CName.ps1
Created Apr 29, 2019
A script to create a new CName on an existing zone in Azure. You can use this script in an Azure DevOps pipeline using a service account with the proper permissions.
View New-CName.ps1
param(
[CmdletBinding()]
# Subscription ID
[Parameter(Position=0, Mandatory=$true)]
[string]$subId,
# DNS Resource Group Name
[Parameter(Position=1, Mandatory=$true)]
[string]$resourceGroup,
@jasongaylord
jasongaylord / azure-pipelines.yml
Created Apr 11, 2019
Azure Pipelines - Build YAML file for HTML Copying
View azure-pipelines.yml
trigger:
- master
name: $(Date:yyyyMMdd)$(Rev:.r)
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: CopyFiles@2
@jasongaylord
jasongaylord / youtube.cs
Created Feb 20, 2019
YouTube API Connection
View youtube.cs
public List<Google.Apis.YouTube.v3.Data.SearchResult> LatestVideos()
{
var youTubeService = new YouTubeService(
new BaseClientService.Initializer() {
ApplicationName = "{Project}",
ApiKey = "{API_key}"
}
);
var listRequest = youTubeService.Search.List("snippet");
@jasongaylord
jasongaylord / DateTimeExtensions.cs
Created Nov 5, 2018
A DateTime extension to show a friendly date based on the value passed in and DateTime.Now
View DateTimeExtensions.cs
public static class DateTimeExtensions
{
public static string ToFriendlyDate(this DateTime date)
{
// Calculate the elapsed time
TimeSpan s = DateTime.UtcNow.Subtract(date);
// Get total number of days elapsed.
int dayDiff = (int)s.TotalDays;
@jasongaylord
jasongaylord / droptables.sql
Created Nov 12, 2018
Drop All Cloudscribe Tables
View droptables.sql
drop table dbo.cs_UserToken;
drop table dbo.cs_UserRole;
drop table dbo.cs_UserLogin;
drop table dbo.cs_UserLocation;
drop table dbo.cs_UserClaim;
drop table dbo.cs_User;
drop table dbo.cs_SystemLog;
drop table dbo.cs_SiteHost;
drop table dbo.cs_Site;
drop table dbo.cs_Role;
View TwitterService.cs
public class TwitterService : ITwitterService
{
public string ObtainBearerToken(string consumerKey, string consumerSecret)
{
var applicationAuthorization = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", Uri.EscapeDataString(consumerKey), Uri.EscapeDataString(consumerSecret))));
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.twitter.com/oauth2/token");
request.Headers.Add("Authorization", "Basic " + applicationAuthorization);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";