Skip to content

Instantly share code, notes, and snippets.

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

James Jackson-South JimBobSquarePants

💭
(•_•) ( •_•)>⌐■-■ (⌐■_■)
View GitHub Profile
@balupton
balupton / ajaxify-html4.js
Created March 7, 2011 04:58
Ajaxify a Website using the HTML4 HashChange Functionality
(function(window,undefined){
// Prepare our Variables
var
document = window.document,
$ = window.jQuery;
// Wait for Document
$(window).bind(function(){
// Prepare Variables
// Original code from http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
}
@tarnacious
tarnacious / search.cs
Created November 28, 2011 06:47
Searching for multiple terms using the Umbraco Examine API.
// This seems way too difficult for what you would expect to be a pretty common task;
// taking a search string from the user and finding documents which contain some or all of the terms
// in the search string.
// This function naively splits a search string into terms and finds documents
// which contain some or all of the terms. Does not handle quoted terms as or ignore case as it should.
public IEnumerable<SearchResult> Search(string searchString, string[] fields)
{
// Spit the search string and return an empty list if no search string was provided.
if (string.IsNullOrEmpty(searchString)) return new List<SearchResult>();
@joelpurra
joelpurra / InheritedClassModelBinder.cs
Created April 18, 2012 18:26
InheritedClassModelBinder: A ModelBinder for ASP.NET MVC3 that handles creating concrete class instances mapped to an abstract superclass. Based on code by Kelly.
namespace JoelPurra.Web.Binders
{
using System;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Web.Mvc;
using rDoing.Scraper.Web.Mvc.Controllers.ViewModels.Binder.Helpers;
/// <remarks>
/// Based on
@IcodeNet
IcodeNet / Umbraco Razor Script Retrieve CheckBox List Selected Values
Created May 1, 2012 10:13
Umbraco Razor Script Retrieve CheckBox List Selected Values
var optionList = DynamicModel.TypeOfRoom; // TypeOfRoom is the check-box List
//Multiple Checkboxes selected
if (DynamicModel.TypeOfRoom.GetType() == typeof(Umbraco.Framework.Dynamics.BendyObject)){
var options = DynamicModel.TypeOfRoom.__KeyedChildren;
foreach(var kv in options){
RoomType is -- > @kv.Value
}
}
@coderoshi
coderoshi / gist:3729593
Last active March 31, 2022 15:43
A Very Short Guide to Writing Guides

A Very Short Guide to Writing Guides

This is just a few thoughts on the topic of writing technical guides. This was intended for Basho's engineering team, but this may apply to open source projects in general.

Audience

It's commonly preached that the first step in writing is to identify your audience; to whom are you writing? This is the most well known, most repeated, and most overlooked step of writing in general and technical writing in particular. Take this document, for example. My audience is technical people who need to communicate technical information, and not teenagers, so I shy away from images of pop icons and memes. I use jargon and words like "identify" rather than "peep this".

Pronouns

@jandk
jandk / jpeg.cs
Created October 14, 2012 21:09
(Almost) JPEG Decoder in C#
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
namespace Jpeg
{
@justinbmeyer
justinbmeyer / jsmem.md
Last active August 19, 2022 04:50
JS Memory

JavaScript Code

var str = "hi";

Memory allocation:

Address Value Description
...... ...
@joeriks
joeriks / 404handlers.config
Last active December 17, 2015 15:19
Catching all requests to URLs beneath a node if it has umbracoCatchAll=1, or at the same level if it's named * Example 1: add a document named * wherever and it will catch all "sibling" url calls (for example /products/* will catch /products/foo and /products/bar) Example 2: add a property umbracoCatchAll to a document and set it to 1 and it wil…
<?xml version="1.0" encoding="utf-8" ?>
<NotFoundHandlers>
<notFound assembly="umbraco" type="SearchForAlias" />
<notFound assembly="umbraco" type="SearchForTemplate"/>
<notFound assembly="umbraco" type="SearchForProfile"/>
<notFound assembly="CatchAllRouteHandler" namespace="Our" type="CatchAll"/>
<notFound assembly="umbraco" type="handle404"/>
</NotFoundHandlers>
@leekelleher
leekelleher / MyApplication.cs
Last active December 19, 2015 13:59
Example of Umbraco 6.1's IContentFinder
using Umbraco.Core;
using Umbraco.Core.Services;
using Umbraco.Web.Mvc;
using Umbraco.Web.Routing;
namespace Our.Umbraco
{
public class MyApplication : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)