Skip to content

Instantly share code, notes, and snippets.

Avatar
😶

Derek Gray tuespetre

😶
View GitHub Profile
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>inline-or-nah</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@tuespetre
tuespetre / repro.html
Created Dec 7, 2016
Repro of a WebKit bug with iOS 10 Safari
View repro.html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
</head>
<body>
<style>
.hover-me:hover {
color: red;
}
@tuespetre
tuespetre / parent-node.js
Created Oct 24, 2016
A polyfill for the ParentNode interface
View parent-node.js
(function() {
var polyfill = function(prototype)
{
if (!('firstElementChild' in prototype)) {
Object.defineProperty(prototype, 'firstElementChild', {
get: function() {
var nodes = this.childNodes;
var length = nodes.length;
var current;
for (var i = 0; i < length; i++) {
@tuespetre
tuespetre / template-polyfill.js
Created Oct 21, 2016
Allows you to use templates for custom elements in IE11. Wrote this to be able to use webcomponents/shadycss
View template-polyfill.js
(function (document) {
if ('content' in document.createElement('template')) {
return;
}
Object.defineProperty(HTMLUnknownElement.prototype, 'content', {
enumerable: false,
configurable: true,
get: function() {
if (this.localName !== 'template') {
@tuespetre
tuespetre / example.sql
Last active Oct 4, 2018
An attempt at mimicking Postgresql's LISTEN/NOTIFY functionality in SQL Server, using Service Broker
View example.sql
// Worker process:
EXEC [notifications].[Listen] N'something-happened', 5000
// Some other process:
EXEC [notifications].[Notify] N'something-happened'
@tuespetre
tuespetre / Extensions.Tasks.cs
Last active Jun 27, 2016
Extensions for background tasks inside of a .NET core web app
View Extensions.Tasks.cs
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Builder
{
public static class WebApplicationBackgroundTaskExtensions
@tuespetre
tuespetre / README.md
Last active Mar 2, 2016
A snippet to use for AJAX; robustness in the face of 401 and other errors
View README.md

Handles 401 errors for OAuth users following the 'code flow' (redirects) and notifies the user if there is a fatal error. You wouldn't want the server giving your users 401s outright though -- only when the request is AJAX (X-Requested-With: XMLHttpRequest.)

Uses jQuery (obviously) as well as Bootstrap modals. I'm not using PJAX just yet but I will include it when I do.

In the following example, I've placed the following elements as the last children of the <body> element. Note the addition of the empty data-remote attribute on #dynamic-modal -- this prevents Bootstrap from performing a redundant load the first time the modal is used.

<div class="modal fade special" id="error-modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
@tuespetre
tuespetre / powershell-setup.md
Last active Nov 10, 2016
Setting up powershell properly :P
View powershell-setup.md
  1. Install Ps-Get:

(new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | iex

  1. Install posh-git:

Install-Module posh-git

  1. Edit or create %userprofile%/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1:
@tuespetre
tuespetre / Set-AppPoolEnvVariable.ps1
Last active Aug 9, 2018
A PowerShell cmdlet for setting environment variables for AppPoolIdentity users
View Set-AppPoolEnvVariable.ps1
function global:Set-AppPoolEnvVariable {
param (
[string]$appPool = $(Read-Host "Application Pool"),
[string]$varName = $(Read-Host "Variable name"),
[string]$varValue = $(Read-Host "Variable value")
)
$sec = "System.Security.Principal";
$acct = New-Object "$sec.NTAccount" -ArgumentList "IIS AppPool\$appPool";
$sid = $acct.Translate([System.Type]::GetType("$sec.SecurityIdentifier")).Value;