Skip to content

Instantly share code, notes, and snippets.

View JimBobSquarePants's full-sized avatar
💭
(•_•) ( •_•)>⌐■-■ (⌐■_■)

James Jackson-South JimBobSquarePants

💭
(•_•) ( •_•)>⌐■-■ (⌐■_■)
View GitHub Profile
@JimBobSquarePants
JimBobSquarePants / break-word.css
Created August 14, 2012 12:57
Cross browser wrapping css to contain long words.
.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;
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;
@JimBobSquarePants
JimBobSquarePants / pre-wrap.css
Created November 20, 2012 17:15
Browser specific (not valid) styles to make preformatted text wrap
/* Browser specific (not valid) styles to make preformatted text wrap */
pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
@JimBobSquarePants
JimBobSquarePants / jQuery.MultiGetScript.js
Last active December 12, 2015 01:19
jQuery plugins to get multiple scripts in a single call. In cached and un-cached flavours.
(function ($) {
/**
* Multiple parallel getScript with caching.
*
* @param {Array|String} url (one or more URLs)
* @param callback fn (oncomplete, optional)
* @returns {function}
*/
$.getCachedScript = function (url, callback) {
// License: CPOL at http://www.codeproject.com/info/cpol10.aspx
using System.Collections.Generic;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
namespace System.IO
{
public static class AsyncIoExtensions
{
@JimBobSquarePants
JimBobSquarePants / CamelCase.cs
Last active January 5, 2019 09:55
Maps an instance of IPublishedContent to a strong typed Model. This would allow you to use models in your views and save logic. In your controller you should be able to use var MyModel = ModelMapper.Map<Type>(renderModel.Content); This could easily be turned into an extension method IPublishedContent. Based on the MVC separation article by Nick …
namespace UmbracoBootstrap.Infrastructure.Extensions
{
#region Using
using System.Diagnostics.CodeAnalysis;
#endregion
/// <summary>
/// Encapsulates a series of time saving extension methods to <see cref="T:System.String">String</see>s.
/// </summary>
public static class StringExtensions
@JimBobSquarePants
JimBobSquarePants / getVendorPropertyName.js
Last active December 23, 2015 02:59
Gets the correct vendor property name for the current browser. ("transition" => "MozTransition")
getVendorPropertyName = function (prop) {
/// <summary>Gets the correct vendor property name for the current browser.</summary>
/// <param name="prop" type="String">The property to return the name for.</param>
/// <returns type="String">The correct vendor property name.</returns>
var el = document.createElement("div");
if (prop in el.style) {
return prop;
}
@JimBobSquarePants
JimBobSquarePants / centered-image.css
Last active December 23, 2015 09:49
Dimension Independent Centred Images - This allows an image to be centered within a parent container of a fixed height no matter what height or width the child image is. http://jsfiddle.net/jamessouth/JpCXX/
/*
* 1: Arbitrary width.
*/
.parent {
position: relative;
height: 250px;
max-width: 400px; /* 1 */
overflow: hidden;
}
@JimBobSquarePants
JimBobSquarePants / gulpfile.js
Created March 14, 2014 19:15
Gulp-svgmin sample
// 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
// 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);