Skip to content

Instantly share code, notes, and snippets.

@adamcameron
adamcameron / query.cfm
Created April 12, 2023 14:34
Query using tag islands for param
View query.cfm
<cfscript>
query name="getData" {
```
<cfsavecontent variable="sql">
SELECT * FROM test WHERE id =
</cfsavecontent>
```
writeOutput(sql)
```
<cfqueryparam cfsqltype="CF_SQL_INTEGER" value="101">
@adamcameron
adamcameron / mixed.cfm
Created April 12, 2023 14:08
mix of script and tags in one statement
View mixed.cfm
<cfscript>
```<!---
make
hyper text
transfer
protocol
request
--->```
http
@adamcameron
adamcameron / daftery.cfm
Created April 12, 2023 13:39
Tag Islands par excellence
View daftery.cfm
<cfset level = 0>
<cfscript>
level++
```
<cfoutput>Hello from level #level#<br></cfoutput>
<cfscript>
level++
```
<cfoutput>Hello from level #level#<br></cfoutput>
<cfscript>
View isObjectLuceeBungnessTest.cfm
<cfscript>
function run() {
describe("Comparing behaviour of isObject across CF and Lucee", () => {
describe("Tests using isObject", () => {
describe("Tests when argument is scoped", () => {
var isObjectChecker = (component object) => isObject(arguments.object)
it("is a baseline happy path", () => {
var o = new Http()
expect(isObjectChecker(o)).toBeTrue()
@adamcameron
adamcameron / Numbers.cfc
Created October 9, 2022 14:51
This is the CFWheels controller I was building during my https://blog.adamcameron.me/2022/10/kotlin-tdd-writing-tests-for-small-web.html article
View Numbers.cfc
component extends=Controller {
function init() {
filters("getHeadersForRequest")
}
function getHeadersForRequest() {
variables.headers = getHttpRequestData().headers
}
View result.out
Tags
[#arguments.x#] [2]
Script
[#arguments.x#] [#arguments.x#]
View build.gradle.kts
val ktor_version: String by project
val kotlin_version: String by project
val logback_version: String by project
plugins {
application
kotlin("jvm") version "1.7.20"
id("io.ktor.plugin") version "2.1.2"
}
View trycf-gist-1663831519549-108be4c3-5b4d-d6dc-ca88-c0d8e48bcdb6.cfm
<cfscript>
s = "12345678901234567890"
writeDump([
"s" = s,
"val(s)" = val(s),
"s.getClass().getName()" = s.getClass().getName(),
"val(s).getClass().getName()" = val(s).getClass().getName()
])
d = 12345678901234567890
@adamcameron
adamcameron / code.cfm
Created August 28, 2022 10:57
Code review for Ookma
View code.cfm
function index( event, rc, prc ){
prc.pageTitle = "Reset Password";
if( isEmpty( rc?.user ) || isEmpty( rc?.token ) ) {
return event.setView( "resetpassword/malformedurl" );
}
var rows = getInstance( "User" ).firstWhere( "id", rc.user );
if( isNull( rows ) ) {
return event.setView( "resetpassword/malformedurl" );
@adamcameron
adamcameron / testHarness.cfm
Created May 18, 2022 19:33
Harness to pull in all the test Gists from github and then run them on trycf.com
View testHarness.cfm
<cfscript>
cfhttp(
method = "get",
url = "https://gist.githubusercontent.com/adamcameron/816ce84fd991c2682df612dbaf1cad11/raw/tinyTestFramework.cfm",
result = "frameworkCodeResponse",
throwOnError = true
);
frameworkCode = frameworkCodeResponse.fileContent;