Skip to content

Instantly share code, notes, and snippets.


Chris Macagare

  • Germany
View GitHub Profile
Macagare / gist:4502095
Created Jan 10, 2013
JavaScript: Limit the number of characters in a textarea
View gist:4502095
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<!-- Code source: THANKS -->
<html xmlns="">
<title>Limit Number of Characters in a TextArea</title>
<script type='text/javascript'
<script type='text/javascript'>
$(document).ready(function() {
Macagare / normalize.cfm
Last active Dec 25, 2015
normalize query string for query of queries
View normalize.cfm
<cffunction name="normalizeChar" returntype="string" hint="Replaces characters with their non accented closest equivalents" output="true">
<cfargument name="str" type="string" required="true" />
<cfreturn ReplaceList( str,"á,é,í,ó,ú,ý,à,è,ì,ò,ù,â,ê,î,ô,û,ã,ñ,õ,ä,ë,ï,ö,ü,ÿ,À,È,Ì,Ò,Ù,Á,É,Í,Ó,Ú,Ý,Â,Ê,Î,Ô,Û,Ã,Ñ,Õ,Ä,Ë,Ï,Ö,Ü",
"a,e,i,o,y,u,a,e,i,o,u,a,e,i,o,u,a,n,o,a,e,i,o,u,y,A,E,I,O,U,A,E,I,O,U,Y,A,E,I,O,U,A,N,O,A,E,I,O,U") />
<cffunction name="normalizeColumn" returntype="query" output="true" hint="normalize single column and add new column [column]_norm">
<cfargument name="qSource" type="query" required="true" />
<cfargument name="column" type="string" required="true" />
<cfset var normColumn = arguments.column & "_norm" />
Macagare / gist:6884565
Created Oct 8, 2013
coldfusion structAppend2, adds value to a new created key
View gist:6884565
void function structAppend2(required struct base, required string key, required any value) {
var paramStruct = {};
paramStruct[arguments.key] = arguments.value;
Macagare / gist:6883387
Last active Dec 24, 2015
cfscript version of query to map conversion made for railo
View gist:6883387
* converts query to sturct map
* @param query source query to convert
* @param string key key for the main subkeys, when empty first column taken
* @return struct converted map
struct function toMap( required query source, required string key, string ignore="" ) {
var map = {};
Macagare / gist:6883249
Created Oct 8, 2013
cfscript implementation convert query to structs array. created in railo
View gist:6883249
* Converts a coldfusion query into a coldfusion struct
* @param required query source query to convert
* @return struct converted query as a array with structs
array function toStruct( required query source) output="true" {
var arrResult = arraynew(1);
var cols = ListtoArray(arguments.source.columnlist);
var row = 1;
Macagare / gist:6854209
Created Oct 6, 2013
load xml via ruby Net:HTTP and write into local file
View gist:6854209
require 'net/http'
def load_file(f_url)
load_content( URI.parse(f_url) )
def load_content(uri)
resp = Net::HTTP.get_response(uri)
raise unless resp.code == "200"
write_file( get_filename(uri.to_s), resp.body)
Macagare / gist:6765315
Last active Dec 24, 2015
cfhttp head - Check if url is returning any response. Prevent freezing of website. like ping in coldfusion
View gist:6765315
Does a URL exist? Checks that host exists and for
404 status code.
<cffunction name="urlExists" output="no" returntype="boolean">
<!--- Accepts a URL --->
<cfargument name="u" type="string" required="yes">
<!--- Attempt to retrieve the URL --->
View gist:6683323
<!DOCTYPE html>
<meta charset="utf-8">
<!--[if lt IE 9]>
<script src=""></script>
Macagare / gist:6683332
Created Sep 24, 2013
HTML form google maps search submit
View gist:6683332
<form action="" method="get" target="_blank">
<label for="saddr">Enter your location</label>
<input type="text" name="saddr" />
<input type="hidden" name="daddr" value="350 5th Ave New York, NY 10018 (Empire State Building)" />
<input type="submit" value="Get directions" />
View gist:6683334
<video width="640" height="360" controls>
<source src="__VIDEO__.MP4" type="video/mp4" />
<source src="__VIDEO__.OGV" type="video/ogg" />
<object width="640" height="360" type="application/x-shockwave-flash" data="__FLASH__.SWF">
<param name="movie" value="__FLASH__.SWF" />
<param name="flashvars" value="controlbar=over&amp;image=__POSTER__.JPG&amp;file=__VIDEO__.MP4" />
<img src="__VIDEO__.JPG" width="640" height="360" alt="__TITLE__"
title="No video playback capabilities, please download the video below" />
You can’t perform that action at this time.