Skip to content

Instantly share code, notes, and snippets.

@isapir
isapir / OAuthRequestExt.java
Created February 3, 2012 23:49
this class extends OAuthRequest to provide a public send() method in the class itself for compatibility with ColdFusion and other languages that interact with Java via reflection
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package s21.net.scribe;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.scribe.model.OAuthRequest;
import org.scribe.model.Response;
@isapir
isapir / UnusedCfFilesDetector.cfc
Created February 23, 2012 05:09
this component scans a folder of CFML and compares it with the /WEB-INF/railo/cfclasses to detect files that are in the source folder but were not compiled to a Java class, essentially showing old / obsolete / seldomly used cf source files
<cfcomponent output="false"
hint="this component scans a folder of CFML and compares it with the /WEB-INF/railo/cfclasses to detect files that are in the source folder but were not compiled to a Java class, essentially showing old / obsolete / seldomly used cf source files">
<!--- requires: Railo 3.x
/** Attention: this component Does Not delete any files; it merely points out
* which files were not compiled so that you can inspect them and
* decide if they can be safely removed.
*
* Warning: be sure to back up all of your source files before you make any
@isapir
isapir / GetRequestUrl.java
Created March 14, 2012 08:42
creates a Railo function for GetRequestUrl()
package net.twentyonesolutions.railo.functions;
import javax.servlet.http.HttpServletRequest;
import railo.loader.engine.CFMLEngineFactory;
import railo.runtime.PageContext;
import railo.runtime.exp.PageException;
import railo.runtime.ext.function.Function;
/** creates a Railo function for GetRequestUrl() (requires function definition file of type .fld) */
@isapir
isapir / classpath.cfm
Created June 23, 2012 21:53
prints a list of jars found in a class path of a class loader
<cffunction name="printClassLoaderUrls" output="true">
<cfargument name="classLoader">
<cfset var Local = {}>
<cfset PAD = "&nbsp;&nbsp;&nbsp;&nbsp;">
@isapir
isapir / sysproperties.cfm
Created June 23, 2012 22:26
prints out all the system properties for the JVM
<style>
tr td { border-bottom: 1px dotted gray; vertical-align: top; margin-top: 2px; padding-left: 0.5em; }
tr td:first-child { text-align: right; padding-right: 0.5em; border-right: 1px dotted #CCC; }
table { border: 1px solid gray; width:90%; }
</style>
<cfoutput>
@isapir
isapir / dbsample.cfm
Created July 10, 2012 05:31
Basic Database Connection, Random Query, Display Result, equivalent to PHP script at http://css-tricks.com/snippets/php/basic-database-connection-random-query-display-result/
<!--- first select from db !--->
<cfquery name="qTestinmonials">
SELECT testimonial, author
FROM recommendations
ORDER BY rand() LIMIT 1
</cfquery>
<!--- now output the data !--->
<cfoutput query="qTestinmonials">
<cfsetting requesttimeout="300">
<cfparam name="nIterations" default="5">
<cfparam name="nMultiple" default="1">
<cfset iTarget = 10000000 * nMultiple>
@isapir
isapir / web.xml
Created July 16, 2012 04:50
Boilerplate web.xml for Railo servlet settings. This file should go into your site's /WEB-INF/ folder.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Railo4</display-name>
<servlet>
<servlet-name>CFMLServlet</servlet-name>
<description>CFML runtime Engine</description>
@isapir
isapir / BufferContent.cfm
Created July 25, 2012 03:25
a custom tag for buffering content to be rendered at a later time, for example buffering all JS code to be rendered before the closing body tag.
<!---
usage:
<cf_BufferContent BufferId="beforeBodyEnd">
javascript code goes here...
</<cf_BufferContent>
@isapir
isapir / CFMLWriterWhiteSpacePre.java
Created August 24, 2012 01:50
a class that can extends CFMLWriterWhiteSpace.java to allow for pre-formatted text in PRE tags and TEXTAREAs
import java.io.IOException;
import java.io.PrintStream; // TODO: this is for test purpose only; remove it when ridding of this.out
/**
* this class that can extends CFMLWriterWhiteSpace.java to allow for pre-formatted text in PRE tags and TEXTAREAs
*/
public class CFMLWriterWhiteSpacePre extends javax.servlet.jsp.JspWriter {
/* snippet begin */