Skip to content

Instantly share code, notes, and snippets.

View brainwipe's full-sized avatar

Rob Lang brainwipe

View GitHub Profile
@brainwipe
brainwipe / README.md
Created June 10, 2016 23:05 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@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
@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 / 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 / snap.svg.text.in.a.box.html
Last active May 27, 2022 00:03
Using Snap.svg to create a box with text in it. The bounding "container" box expands to fit the width of the text.
<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(50, 50, 100, 100, 20, 20);
block.attr({
fill: "rgb(236, 240, 241)",
stroke: "#1f2c39",
@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 / 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.snapping.html
Created November 27, 2013 10:38
Using Snap.svg to create a draggable box that snaps to grid.
<!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 gridSize = 50;
var orig = {
x: 0,
y: 0
@brainwipe
brainwipe / ef6-sql-providerhack.cs
Created November 26, 2013 16:59
Entity Framework 6 is unable to locate the SqlProvider when running integration tests on a server. This is because it is not copied across to the bin/ folder (no matter what you do). This is the hack to ensure the DLL is moved over. Placed in your base domain context that wraps System.Data.Entity.DbContext.
public abstract class BaseDomainContext : DbContext
{
static BaseDomainContext()
{
// ROLA - This is a hack to ensure that Entity Framework SQL Provider is copied across to the output folder.
// As it is installed in the GAC, Copy Local does not work. It is required for probing.
// Fixed "Provider not loaded" error
var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
}
}