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 / gist:959038
Created May 6, 2011 14:23
A shell script for getting stats about your git repo (lines committed in HEAD by comitter)
#!/bin/sh
# this script requires GNU-SED for the "-r" option.
# Get it via: sudo brew install gnu-sed
# command found at: http://stackoverflow.com/questions/4589731/git-blame-statistics/4590487#4590487
echo "Lines in HEAD by Committer:"
git ls-tree -r HEAD|sed -re 's/^.{53}//'|while read filename; do file "$filename"; done|grep -E ': .*text'|sed -r -e 's/: .*//'|while read filename; do git blame "$filename"; done|sed -r -e 's/.*\((.*)[0-9]{4}-[0-9]{2}-[0-9]{2} .*/\1/' -e 's/ +$//'|sort|uniq -c