Skip to content

Instantly share code, notes, and snippets.

View atuttle's full-sized avatar

Adam Tuttle atuttle

View GitHub Profile

Replacing TinyMCE with WMD (Markdown) in your MangoBlog

Mango Blog future plans include a way to add custom editors in a manner that is simple and compartmentalized, but this is not yet realized. Therefore, in order to accomplish this goal today, we must edit a few files. Don't worry, it's not difficult and there aren't that many to do.

Of course there are two pieces to this puzzle. First, you have to put a Markdown editor in your blog (directions to follow); then you need a plugin to convert that Markdown into HTML at display-time. I've written a plugin called Salsa to do that.

Step 0: Add assets

Download wmd-Mango.zip. Unzip it into {Mango}/admin/assets/editors/ so that the directory structure follows:

<cfcomponent hint="A stack class that makes working with arrays as stacks clean and simple">
<cfscript>
//private data
variables.data = arrayNew(1);
function init(){
if (!structIsEmpty(arguments)){
if (isArray(arguments[1])){//handle array source data
variables.data = arguments[1];
CREATE PROCEDURE [dbo].[usp_PartsOfSpeech_wordEssayCount]
(
@wordlistInput varchar(max)
)
AS
--table to hold results
declare @rtn table (
word varchar(50),
recCount int
//update-form handler
$("##update").submit(function(e){
e.preventDefault();
var frm = $(this);
$.ajax({
url: frm.attr('action'),
data:{
firstname: $("##update input[name=firstname]").val(),
lastname: $("##update input[name=lastname]").val(),
address: $("##update input[name=address]").val(),
var values = {};
values.probablyOctal = 000010;
values.whoKnows2 = 00000020;
values.whoKnows3 = 000000030;
values.whoKnows4 = 0000000040;
values.whoKnows5 = 00000000050;
values.whoKnows6 = 000000000060;
values.whoKnows7 = 0000000000070;
values.whoKnows8 = 00000000000080;
values.whoKnows9 = 000090;
<cfscript>
numeric function getPeriods(required numeric initBalance, required numeric intRate, required numeric desiredTotal) output="false" {
//assume interest rate is of format .5 = 50%
var periods = (log(arguments.desiredTotal) - log(arguments.initBalance))/log(1+arguments.intRate);
return (ceiling(periods));
}
</cfscript>
@atuttle
atuttle / cache.cfc
Created December 3, 2010 14:44
Simple cache manager for ColdFusion. Relies on the user to store the component instance in a persistent scope (eg Application, Server, or Session)
component output="false" {
public function init(){
variables.cache={};
return this;
}
public void function put(key, data, timeout){
variables.cache[key] = { timeout=arguments.timeout, data=arguments.data };
}
public boolean function has(key){
return (structKeyExists(variables.cache, arguments.key) && dateCompare(now(),variables.cache[arguments.key].timeout) == -1);
@atuttle
atuttle / deliciousBackupParser.cfc
Created February 24, 2011 04:19
Parses the HTML export from Delicious.com and returns an array of structures representing the links from delicious.
component {
public function init() output="false" {
return this;
}
public function parse(data) output="false" {
local.links = [];
//loop over each line in the file
@atuttle
atuttle / artist.cfm
Created March 25, 2011 20:55
An example of writing REST web services in ColdFusion, without a framework. This code is provided as an example of a simple implementation, but should not be considered a best practice or something I am promoting. I use this in one of my presentations as
<!---
An example of writing REST web services in ColdFusion, without a framework (and why you should use one).
Provided as an example of a simple implementation, but should not be considered a best practice or something
I am promoting. Not thoroughly tested, not very maintainable, not even that reusable.
--->
<cfsetting enablecfoutputonly="true" showdebugoutput="false" />
<cffunction name="StructKeyRequire" output="false">
<cfargument name="s" type="struct" />