Skip to content

Instantly share code, notes, and snippets.

Avatar

Tom King neokoenig

View GitHub Profile
View gist:4614fd933bb7b9e9fc05f56f1e9274a7
<cfprocessingdirective pageencoding="utf-8">
<cfheader name="Content-Disposition" value="attachment; filename=myworddoc.doc" charset="utf-8">
<cfcontent type="application/msword; charset=utf-8">
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<style>
<!--[if gte mso 9]>
View gist:77f8dbc750cca35caa8d7062f7592150
public string function getIPAddress() {
local.rv = "";
try {
try {
local.headers = getHttpRequestData().headers;
if (structKeyExists(local.headers, "X-Forwarded-For") && len(local.headers["X-Forwarded-For"]) > 0) {
local.rv = trim(listFirst(local.headers["X-Forwarded-For"]));
}
} catch (any e) {}
if (len(local.rv) == 0) {
View gist:cd54c870007845fd500e7c624d1b9a63
// If a plugin has a jar or class file, automatically add the mapping to this.javasettings.
this.wheels.pluginDir = this.wheels.rootPath & "plugins";
this.wheels.pluginFolders = DirectoryList(this.wheels.pluginDir, "true", "path", "*.class|*.jar|*.java");
for (this.wheels.folder in this.wheels.pluginFolders) {
if(!structKeyExists(this, "javaSettings")){
this.javaSettings={};
}
if(!structKeyExists(this.javaSettings, "LoadPaths")){
View gist:a375b54a24ff79c5ec3dcac182c9c3aa
component extends="tests.Test" hint="Unit Tests" {
function setup(){
super.setup();
params = {controller="dummy", action="dummy"};
loc.controller = controller("dummy", params);
}
function teardown(){
super.teardown();
}
View Test.cfc
component extends="wheelsMapping.Test" hint="Unit Tests" {
include "../wheels/test.cfm";
function setup(){
}
function teardown(){
}
}
View Locations.cfc
component extends="app.controllers.Controller" hint="Locations Controller"
{
// Name of your model:
this.modelName="location";
// Optional nested properties to include:
// this.includeNestedProperties = "somethign";
function config() {
super.config();
}
function index(){
@neokoenig
neokoenig / index.cfm
Created Jun 27, 2018
ArrayFind vs ArrayFilter as Member functions
View index.cfm
<cfscript>
products = [
{"sku": "prod_one", "title": "Product One"},
{"sku": "prod_two", "title": "Product Two"},
{"sku": "prod_three", "title": "Product Three"},
{"sku": "prod_four", "title": "Product Four"}
];
skuToFind="prod_two";
View gist:c0603a6eec2187401050049d68d91dc9
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
sass:{
@neokoenig
neokoenig / routes.cfm
Created Jun 18, 2017
CFWheels 2.x routing
View routes.cfm
mapper()
.resources("users")
.root(to="wheels##wheels", method="get")
.end()
@neokoenig
neokoenig / routes.cfm
Created Jun 18, 2017
Old CFWheels 1.x style routing
View routes.cfm
addRoute(name="users", pattern="/users/[action]/[key]", controller="users");
addRoute(name="users", pattern="/users/[action]/", controller="users");
addRoute(name="users", pattern="/users/", controller="users", action="index");