Skip to content

Instantly share code, notes, and snippets.

var dmp = new diff_match_patch();
var text1 = "your input text source";
var text2 = "your input text destination";
var current_unicode = parseInt('2000',16);
var charmap = {};
var replaceFirstTag = function(str,code) {
var nu = code+1;
@dustMason
dustMason / SpecifyAPI.rb
Created February 25, 2011 22:35
Simple API wrapper for Specify using HTTParty and HTTMultiParty
require 'rubygems'
require 'httparty'
require 'HTTMultiParty'
require 'base64'
# This is a quick example to demonstrate the use of ruby to interact with the Specify API.
# I am a beginner rubyist, so please excuse my rudimentary code!
# Depends on httparty for clean and simple API wrapper code https://github.com/jnunemaker/httparty
# Depends on httpmultiparty to allow image and file uploads https://github.com/jwagener/httmultiparty
@dustMason
dustMason / Validate.cfc
Created September 20, 2010 19:48
Measurement Parsing and Display in cfscript
<cfcomponent extends="Controller" output="false" hint="A set of functions to interface with the jQuery validator plugin">
<cfscript>
function measurement() {
// gets either params.w, params.d or params.h
// m = params.w OR params.d OR params.h;
if (isDefined("params.w")) { m = params.w; }
if (isDefined("params.d")) { m = params.d; }
if (isDefined("params.h")) { m = params.h; }
@dustMason
dustMason / ajaxOverride.js
Created September 13, 2010 17:50
Custom error handling with jQuery.ajax()
// CUSTOM AJAX FUNCTION FOR STRUCTURED ERROR HANDLING
(function(){
// Store a reference to the original ajax method.
var originalAjaxMethod = jQuery.ajax;
var EF = function(){};
// override the default $.ajax to include special handlers for error and success
// to utilize new custom error box. existing success and error callbacks are
// left intact and given the expected params.
jQuery.ajax = function(options) {
var thisSuccess = (typeof options.success == 'function') ? options.success : EF;