Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
(•_•) ( •_•)>⌐■-■ (⌐■_■)

James Jackson-South JimBobSquarePants

💭
(•_•) ( •_•)>⌐■-■ (⌐■_■)
View GitHub Profile
@JimBobSquarePants
JimBobSquarePants / gulpfile.js
Created March 14, 2014 19:15
Gulp-svgmin sample
View gulpfile.js
// The aim is to get a folder of svg files and somehow package them in a single file as data uri
var gulp = require('gulp');
var svgmin = require('gulp-svgmin');
gulp.task('default', function() {
return gulp.src('.in/*.svg')
.pipe(svgmin())
.pipe(gulp.dest('./out'));
});
@JimBobSquarePants
JimBobSquarePants / domchanged.js
Last active August 29, 2015 14:05
Load jQuery plugins on dom change in Responsive
View domchanged.js
// The idea. Ensure that widgets are initialized when they are dynamically loaded into a page.
// First override the core html method in the jQuery object to allow us to trigger a custom event.
(function($, old){
$.fn.html = function(){
// Execute the original HTML method using the
// augmented arguments collection.
var result = old.apply(this, arguments);
@JimBobSquarePants
JimBobSquarePants / Complex QueryStrings.markdown
Last active August 29, 2015 14:09
Conversation on best api design for complex objects in querystring parameters
View Complex QueryStrings.markdown

What would be the best way to work with complex objects, prevent collision and make them easy to parse.

?watermark={text:"I am the copy",position:[0,0]}&overlay={image:"overlay.jpg",position:[50,50]}

or

?watermark="I am the copy"&watermark.position=0,0&overlay=overlay.jpg&overlay.position:50,50
@JimBobSquarePants
JimBobSquarePants / TestImageService.cs
Created November 18, 2014 21:20
Example IImageService implementation
View TestImageService.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System.Web;
using System.Web.Hosting;
using ImageProcessor.Web.Services;
/// <summary>
@JimBobSquarePants
JimBobSquarePants / Descendents.cs
Created February 4, 2015 12:38
Possible performance improvement in descendents.
View Descendents.cs
internal static IEnumerable<IPublishedContent> EnumerateDescendants(this IPublishedContent content, bool orSelf)
{
if (orSelf) yield return content;
Stack<IPublishedContent> nodes = new Stack<IPublishedContent>(new[] { content });
while (nodes.Any())
{
IPublishedContent node = nodes.Pop();
yield return node;
@JimBobSquarePants
JimBobSquarePants / EnumerableInvocations.cs
Last active August 29, 2015 14:17
Enabling invocation of Enumerable methods without knowing the type at compile time.
View EnumerableInvocations.cs
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
/// <summary>
View smoothscroll.js
if (window.jQuery) {
(function ($, w, d) {
var $d = $(d);
$d.ready(function () {
$d.on("click", "a[data-smooth-scroll]", function (event) {
var $this = $(this),
href = $this.attr("href");
if (href.indexOf("#") === 0) {
@JimBobSquarePants
JimBobSquarePants / button.html
Created June 10, 2015 21:48
This is a button?
View button.html
<a href="#" class="button create-new-thread" data-controller="topic">
<div class="ink animate" style="height: 115px; width: 115px; top: -43.5px; left: 21px;"></div>
<i class="icon-Add"></i>
<span>Create new</span>
</a>
@JimBobSquarePants
JimBobSquarePants / break-word.css
Created August 14, 2012 12:57
Cross browser wrapping css to contain long words.
View break-word.css
.break-word{
-ms-word-break: break-all;
word-break: break-all;
/*Non standard for webkit*/
word-break: break-word;
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
View EnumDropDownList.cs
namespace System.Web.Mvc
{
#region Using
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc.Html;
using System.ComponentModel;
using System.Linq.Expressions;