Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Macagare

  • Germany
View GitHub Profile
@Macagare
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"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Code source: http://www.devcurry.com/2009/08/limit-number-of-characters-in-textarea.html THANKS -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Limit Number of Characters in a TextArea</title>
<script type='text/javascript'
src='http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
@Macagare
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>
<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
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;
structAppend(arguments.base,paramStruct);
}
@Macagare
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
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
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) )
end
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
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.
http://www.forta.com/blog/index.cfm?mode=day&day=2&month=1&year=2006
--->
<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>
<html>
<head>
<meta charset="utf-8">
<title>Untitled</title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
@Macagare
Macagare / gist:6683332
Created Sep 24, 2013
HTML form google maps search submit
View gist:6683332
<form action="http://maps.google.com/maps" 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" />
</form>
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" />
</object>
</video>
You can’t perform that action at this time.