Skip to content

Instantly share code, notes, and snippets.

@adamcameron
adamcameron / roundingVariants.cfm
Created December 28, 2023 14:29
Shows how various functions round in CFML. For comparing CF to Lucee
<cfscript>
numbers = [511.925,512.925,654.925,655.925]
functions = [
"decimalFormat(##x##)",
"right(dollarFormat(##x##), -1)",
'numberFormat(##x##, "9.00")'
]
</cfscript>
<cfoutput>
<table border="1">
@adamcameron
adamcameron / code.txt
Created September 6, 2023 08:23
php-fpm direct call code. TBC
export SCRIPT_NAME="/ping"
export SCRIPT_FILENAME="/ping"
export REQUEST_METHOD="GET"
cgi-fcgi -bind -connect localhost:9000
<cfscript>
data = [
{ org: "A0", path: [0,0,0] },
{ org: "A0->B1", path: [0,1,0] },
{ org: "A0->B1->C1", path: [0,1,1] },
{ org: "A0->B1->C2", path: [0,1,2] },
@adamcameron
adamcameron / query.cfm
Created April 12, 2023 14:34
Query using tag islands for param
<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
<cfscript>
```<!---
make
hyper text
transfer
protocol
request
--->```
http
@adamcameron
adamcameron / daftery.cfm
Created April 12, 2023 13:39
Tag Islands par excellence
<cfset level = 0>
<cfscript>
level++
```
<cfoutput>Hello from level #level#<br></cfoutput>
<cfscript>
level++
```
<cfoutput>Hello from level #level#<br></cfoutput>
<cfscript>
<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
component extends=Controller {
function init() {
filters("getHeadersForRequest")
}
function getHeadersForRequest() {
variables.headers = getHttpRequestData().headers
}
Tags
[#arguments.x#] [2]
Script
[#arguments.x#] [#arguments.x#]
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"
}