Skip to content

Instantly share code, notes, and snippets.

View jarrettv's full-sized avatar
🗽
Think bigger and build great things

Jarrett Vance jarrettv

🗽
Think bigger and build great things
  • First American Title
  • Birmingham, AL
  • X @jarrettv
View GitHub Profile
@jarrettv
jarrettv / crawl_south.yml
Created February 7, 2021 07:10
Wemos D1 Mini ESPHome Module
substitutions:
device_name: crawl_south
display_name: Crawl South
esphome:
name: $device_name
platform: ESP8266
board: d1_mini_lite
wifi:
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CSharp;
namespace BbbAsmTest
@jarrettv
jarrettv / ajaxError.js
Created September 21, 2012 18:52
Detect 401 and reload page when using AJAX
$(document).ajaxError(function (xhr, props) {
if (props.status === 401) {
location.reload();
}
});
@jarrettv
jarrettv / ApplicationEndRequest.cs
Created September 21, 2012 18:47
FormsAuthFix
protected void Application_EndRequest()
{
var context = new HttpContextWrapper(this.Context);
// If we're an ajax request and forms authentication caused a 302,
// then we actually need to do a 401
if (FormsAuthentication.IsEnabled && context.Response.StatusCode == 302
&& context.Request.IsAjaxRequest())
{
context.Response.Clear();
@jarrettv
jarrettv / BundleConfig.cs
Created September 6, 2012 16:34
Example BundleConfig
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
var less = new Bundle("~/bundles/less")
.Include("~/less/bootstrap.less")
.Include("~/less/datepicker.less")
less.Transforms.Add(new LessTransform());
less.Transforms.Add(new CssMinify());
bundles.Add(less);
@jarrettv
jarrettv / LessTransform.cs
Created September 6, 2012 16:33
Updated LessTransform Bundle Transform
public class LessTransform : IBundleTransform
{
public void Process(BundleContext context, BundleResponse response)
{
DotlessConfiguration config = new DotlessConfiguration();
config.MinifyOutput = false;
config.ImportAllFilesAsLess = true;
config.CacheEnabled = false;
config.LessSource = typeof(VirtualFileReader);
#if DEBUG
@jarrettv
jarrettv / VirtualFileReader.cs
Created September 6, 2012 16:31
VirtualFileReader for dotless
internal sealed class VirtualFileReader : IFileReader
{
public byte[] GetBinaryFileContents(string fileName)
{
fileName = GetFullPath(fileName);
return File.ReadAllBytes(fileName);
}
public string GetFileContents(string fileName)
{
@jarrettv
jarrettv / gist:3658174
Created September 6, 2012 16:28
ASP.NET Bundle Transform Example
using System.Web.Optimization;
public class LessTransform : IBundleTransform
{
public void Process(BundleContext context, BundleResponse response)
{
response.Content = dotless.Core.Less.Parse(response.Content);
response.ContentType = "text/css";
}
}