Skip to content

Instantly share code, notes, and snippets.

@Macagare
Macagare / snippet.cfm
Created July 11, 2013 14:04
Coldfusion: call query column
<cfset var qQuery = getQuery( arguments.filter ) />
<cfif qQuery.recordCount >
<cfreturn qQuery[arguments.column][1] />
</cfif>
@Macagare
Macagare / gist:5414370
Created April 18, 2013 17:00
Batch: Google Closure terminal command
java -jar compiler.jar --js input.js --js_output_file output.js --compilation_level WHITESPACE_ONLY --formatting pretty_print
@Macagare
Macagare / gist:5237311
Created March 25, 2013 14:02
CF: string lastIndexOf
<cfset myTeaser = "Some cool stories and news articles from yest...">
<cfset myObj = CreateObject("java", "java.lang.String")/>
<cfset myStr = myObj.init(myTeaser) />
<cfset news = mid(myTeaser,1,myStr.lastIndexOf(' ')) />
<!---
Parts of this are based on Tim Dawe's
http://amazonsig.riaforge.org
and
Joe Danziger's Amazon S3 REST Wrapper
http://amazons3.riaforge.org/
Written by Patrick Liess
@Macagare
Macagare / download.js
Created March 16, 2013 12:26
JS: download file via node.js
var http = require('http');
var url = require('url');
var fs = require('fs');
var XmlStream = require('xml-stream');
var config = require('./config.json'); // already parsed
var downloadFile = function( targetUrl ) {
var xmlItem = "";
var timestamp = parseInt( new Date().getTime() / 1000 );
var options = {
@Macagare
Macagare / server.js
Created March 16, 2013 11:30
JS: create simple node.js server
var http = require('http');
http.createServer( function( req, res ) {
res.writeHead( 200, { 'Content-Type' : 'text/plain' } );
res.end( 'Hello World\n' );
} ).listen( 1337, '127.0.0.1' );
console.log( 'Server running at http://127.0.0.1:1337/' );
@Macagare
Macagare / idle.js
Created March 5, 2013 10:23
JS: idle timer with callback
( function() {
var timeoutDuration = 30;
var mouseMoved = 0;
var keyPressed = 0;
var getDocument = function() {
if ( window ) {
return window.document;
}
@Macagare
Macagare / gist:5040487
Created February 26, 2013 17:49
CF: convert list to numeric list
/**
* convert list to a list with numeric elements
*
* @param required string numList source list with elements]
* @return list with numeric items
*/
string function toNumericList( required string numList ) {
var numListLen = listLen( arguments.numList );
var result = "";
if ( numListLen > 0 ) {
@Macagare
Macagare / gist:5037410
Last active December 14, 2015 05:48
OpenBD: query builder in cfscript
/**
* Build query string and parameter array by using the placeholders like "__name__".
* It is mandatory to use sqlQuery or sqlName. Otherwise no sql will be used!
*
* @param optional string sqlQuery pass a query string to read and convert
* @param optional string sqlName pass the name of the global sql struct property instead of sqlQuery
* @param optional struct params map struct with key to replace and value to use in sql properties array
* @return a struct containing the processes "sql" as string and the "params" as array
*/
struct function queryMake( string sqlQuery, string sqlName, struct params ) {
@Macagare
Macagare / gist:5036977
Created February 26, 2013 08:29
TERMINAL: search in files content for string
find . -iname '*.cfc' | xargs grep 'string' -sl
find . | xargs grep 'string' -sl