Skip to content

Instantly share code, notes, and snippets.

View tuespetre's full-sized avatar
😶

Derek Gray tuespetre

😶
View GitHub Profile
<!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 December 7, 2016 17:56
Repro of a WebKit bug with iOS 10 Safari
<!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 October 24, 2016 19:56
A polyfill for the ParentNode interface
(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 October 21, 2016 19:19
Allows you to use templates for custom elements in IE11. Wrote this to be able to use webcomponents/shadycss
(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 January 29, 2023 15:20
An attempt at mimicking Postgresql's LISTEN/NOTIFY functionality in SQL Server, using Service Broker
// 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 June 27, 2016 16:44
Extensions for background tasks inside of a .NET core web app
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 March 2, 2016 14:53
A snippet to use for AJAX; robustness in the face of 401 and other errors

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 November 10, 2016 13:25
Setting up powershell properly :P
  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 August 9, 2018 14:32
A PowerShell cmdlet for setting environment variables for AppPoolIdentity users
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;