Skip to content

Instantly share code, notes, and snippets.

@Macagare
Macagare / gist:6883249
Created October 8, 2013 11:23
cfscript implementation convert query to structs array. created in railo
/**
* 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 October 6, 2013 13:39
load xml via ruby Net:HTTP and write into local file
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 December 24, 2015 07:39
cfhttp head - Check if url is returning any response. Prevent freezing of website. like ping in coldfusion
<!---
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 --->
@Macagare
Macagare / gist:6683334
Created September 24, 2013 11:20
HTML5 video tag with fallback source: http://camendesign.com/code/video_for_everybody
<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>
@Macagare
Macagare / gist:6683332
Created September 24, 2013 11:19
HTML form google maps search submit
<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>
@Macagare
Macagare / gist:6683323
Created September 24, 2013 11:18
HTML Template
<!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 / select.html
Created September 24, 2013 11:17
country list html dropdown
<select>
<option value=" " selected>(please select a country)</option>
<option value="--">none</option>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
@Macagare
Macagare / gist:6404224
Created September 1, 2013 12:43
extract tag attributes regex
(?:[\w]*) *= *"(?:(?:(?:(?:(?:\\\W)*\\\W)*[^"]*)\\\W)*[^"]*")
@Macagare
Macagare / gist:6403856
Created September 1, 2013 11:24
create mysql connection and do query
package main
import (
"fmt"
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func main() {
loadData()
@Macagare
Macagare / gist:6079196
Created July 25, 2013 12:36
create CF Date from UNIX timestamp
createObject('java','coldfusion.runtime.OleDateTime').init(javaCast('long',timestamp * 1000))