Skip to content

Instantly share code, notes, and snippets.

View brainwipe's full-sized avatar

Rob Lang brainwipe

View GitHub Profile
@brainwipe
brainwipe / gist:d72eb8cfe570eb002945
Created November 19, 2014 21:19
Heapsort implemented in javascript
<!DOCTYPE html><html><body>
An implementation of Heap sort in javascript using an array as an underlying structure.<br/>
Implemented to teach myself about heap sort and how it works, rather than a super fast implementation. Inspired by
<a href="http://www.algorist.com/">The Algorithm Design Manual</a>.
Use the browser console (F12) to see the output.
<script>
var test_american_history_dates = [1492, 1783, 1776, 1804, 1865, 1945, 1963, 1918, 2001, 1941];
@brainwipe
brainwipe / jquery-svg-animate-rectangle.html
Last active December 28, 2015 23:59
jQuery SVG 1.4.5 (jQuery 1.7) animating a simple rectangle as found on the jQuery SVG site.
<svg class="svg" version="1.1" xmlns="http://www.w3.org/2000/svg"></svg>
<script>
$(".svg").svg();
var svg = $(".svg").svg('get');
var myrect = svg.rect(25, 25, 150, '25%', 10, 10,
{fill: 'none', stroke: 'blue', strokeWidth: 3,
transform: 'rotate(0, 100, 75)'});
@brainwipe
brainwipe / raphaeljs-animate-rect.html
Created November 21, 2013 15:34
A simple Raphael.js SVG animation (fragment) where a rectangle moves 100 pixels horizontally and 50 pixels vertically.
<div id="container"></div>
<script>
var paper = new Raphael(document.getElementById('container'), 500, 400);
var rect = paper.rect(10, 20, 300, 200);
rect.animate({
x: 100,
y: 50
@brainwipe
brainwipe / snap-svg-animate-rectangle.html
Created November 21, 2013 16:29
Using Snap.svg to animate a rectangle
<svg id="svg" version="1.1" xmlns="http://www.w3.org/2000/svg"></svg>
<script>
var s = Snap("#svg");
var rect = s.rect(10, 10, 100, 100);
rect.animate({
x: 50,
y: 50
}, 1000);
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
var iframe = $('#frame');
$("#frame").ready(function(){
$("#frame").load(function () {
data = iframe[0].contentWindow.document.body.innerHTML;
if(data == "success"){
@brainwipe
brainwipe / snap.svg.dragasquare.html
Created November 27, 2013 10:44
Using snap.svg for creating a draggable square.
<!DOCTYPE html>
<html>
<head>
<script src="//cdn.jsdelivr.net/snap.svg/0.1.0/snap.svg-min.js"></script>
<script>
var s = Snap("#svg");
var block = s.rect(100, 100, 100, 100, 20, 20);
block.attr({
fill: "rgb(236, 240, 241)",
@brainwipe
brainwipe / snap.svg.howIwantdrag.js
Created November 27, 2013 11:26
How I would prefer drag() in Snap.svg to work, using a context with named parameters. This will not work in Snap.svg now!
// This is how I would like to use snap.svg's drag method:
var block = s.rect(x, y, 100, 100, 20, 20);
block.drag({
ondrag: function(dragContext, event) {
// drag method here
}
onstart: function(dragContext, event) {
// drag start here
}
@brainwipe
brainwipe / snag.svg.drag.transform.html
Created November 27, 2013 11:24
Snap.svg dragging override using the transform attribute method
<!DOCTYPE html>
<html>
<head>
<script src="//cdn.jsdelivr.net/snap.svg/0.1.0/snap.svg-min.js"></script>
<script>
var s = Snap("#svg");
var origTransform = {};
var block = s.rect(100, 100, 100, 100, 20, 20);
block.attr({
@brainwipe
brainwipe / Client.cs
Last active January 3, 2016 13:49
For S-O question: This method returns 204.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Http.Headers;
namespace Client
{
@brainwipe
brainwipe / findloadedtypes.cs
Created February 22, 2016 13:35
Find all loaded types in ASP.NET Core, C# snippet
// Prior to ASP.NET Core, you had access to the AppDomain and all the loaded assemblies.
using Microsoft.AspNet.Mvc.Infrastructure;
using Microsoft.Extensions.PlatformAbstractions;
// Snip...
var assemblyProvider = new DefaultAssemblyProvider(PlatformServices.Default.LibraryManager);
var resourceControllers = assemblyProvider.CandidateAssemblies