Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Rupp jorupp

  • Rightpoint Consulting
  • Chicago, IL
View GitHub Profile
@jorupp
jorupp / gitStatus.cs
Created May 19, 2017
Find all git repos under a directory and check what branches they have that aren't merged into origin/master
View gitStatus.cs
string target = ".git";
string[] ignored = new [] { "node_modules", "bower_components" };
void Main()
{
var start = @"c:\projects";
var maxDepth = 4;
var dirs = Scan(start, maxDepth).ToList();
var results = dirs.AsParallel().Select(i => new { dir = i, data = GitStatus(i) }).ToDictionary(i => i.dir, i => i.data);
results.Dump();
}
@jorupp
jorupp / MultiTenant.cs
Created Jul 5, 2016
ASP.Net AzureAD Authentication Startup.Auth.cs
View MultiTenant.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.IdentityModel.Claims;
using System.IdentityModel.Tokens;
using System.Threading.Tasks;
using System.Web;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
@jorupp
jorupp / debug.js
Created Jul 24, 2015
Dumps out some information about a passed angular scope and it's connectivity to parents up the tree to the root
View debug.js
function debugScope(scope) {
function isInParent(scope) {
var parent = scope.$parent;
if(!parent) return false;
var s = parent.$$childHead;
while(s) {
if(s == scope) return true;
s = s.$$nextSibling;
}
return false;
@jorupp
jorupp / dumpaccessibility.js
Created Jul 23, 2015
dumps out the name and heading of the accessibility test rules
View dumpaccessibility.js
$.getScript('https://rawgit.com/GoogleChrome/accessibility-developer-tools/master/dist/js/axs_testing.js', function() {
for (var k in axs.AuditRules.specs) { console.log(k, axs.AuditRules.specs[k].heading); }
});
@jorupp
jorupp / msdn.cs
Created May 27, 2015
Wander around MSDN downloads
View msdn.cs
void Main()
{
GetFilesForProduct(546).Result.Dump();
return;
var letters = "#ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
var allTasks = letters.Select(i => GetProductsFor(i.ToString())).ToArray();
Task.WaitAll(allTasks);
var allData = allTasks.SelectMany (t => t.Result).ToList();
allData.Dump();
@jorupp
jorupp / gist:b99522397504283c9ba1
Created Mar 4, 2015
Execute the JS tests from the Chrome Accessibility Developer Tools via the browser console
View gist:b99522397504283c9ba1
$.getScript('https://rawgit.com/GoogleChrome/accessibility-developer-tools/stable/dist/js/axs_testing.js', (function() { var r = axs.Audit.run(function() { var c = new axs.AuditConfiguration; c.scope = $("body")[0]; return c; }()); console.log(axs.Audit.createReport(r)); var rr = {}; for(var i in r) { rr[r[i].result] = (rr[r[i].result] || []); rr[r[i].result].push(r[i]); } console.log(rr); }));
@jorupp
jorupp / gist:2af4d8583bd592b8331f
Created Mar 4, 2015
Lock all media queries in their current state
View gist:2af4d8583bd592b8331f
function process(rule) {
if(rule.cssRules) {
for(var i=rule.cssRules.length-1; i>=0; i--) {
process(rule.cssRules[i]);
}
}
if(rule.type == CSSRule.MEDIA_RULE) {
if(window.matchMedia(rule.media.mediaText).matches) {
rule.media.mediaText = "all";
} else {
@jorupp
jorupp / gist:b09879f35858e9692461
Created Jan 10, 2015
Expression-to-avoid-reflection example
View gist:b09879f35858e9692461
/**
Simple example to show off a way of using expressions to avoid doing reflection for each item to process.
Example results:
TestSimple with 300000 items: 00:00:00.0003998 setup, 00:00:02.3790693 processing
TestCache1 with 300000 items: 00:00:00.0005534 setup, 00:00:02.4511439 processing
TestCache2 with 300000 items: 00:00:00.0048780 setup, 00:00:00.1950776 processing
**/
public class MyClass {