Skip to content

Instantly share code, notes, and snippets.

View brainwipe's full-sized avatar

Rob Lang brainwipe

View GitHub Profile
@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 / 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;
}
}
@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 / 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 / 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.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 / 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",