Skip to content

Instantly share code, notes, and snippets.

View ivanionut's full-sized avatar
🎯
Focusing

Ivan Ionut ivanionut

🎯
Focusing
View GitHub Profile
@ivanionut
ivanionut / Application.cfc
Created March 8, 2017 22:40 — forked from roryl/Application.cfc
Sample Lucee Application.cfc
component {
// The application name. If you do not set this variable, or set it to the empty string, your CFC applies to the unnamed application scope, which is the Lucee J2EE servlet context. THIS.name = "foo";
this.name = "foo";
/*
this.applicationTimeout = createTimeSpan(0, 1, 0, 0); // Life span, as a real number of days, of the application, including all Application scope variables.
this.clientManagement = false; // Whether the application supports Client scope variables.
this.clientStorage = "registry"; //cookie||registry||datasource // Where Client variables are stored; can be cookie, registry, or the name of a data source. this.customTagPaths = ""; // Contains Lucee custom tag paths. this.datasource = ""; // Name of the data source from which the query retrieves data.

By now you've learned the basics of ColdFusion, script vs. tag syntax, scopes, how to deal with data, and even some code-reuse techniques. You're now able to write something useful, so it's time we introduce you to the Request Lifecycle.

You see, when someone requests a ColdFusion page, CF doesn't just start executing your code. There are several events that first take place, which you can be waiting for, and to which you can react. This is not strictly necessary, but you'll find that any complex application will eventually want to make use of some or all of these features, so it's best that you know about them. In order to react to these events, you need to have an Application.cfc file. ColdFusion has designated Application.cfc as a special component that it will automatically look for, and in which we can put our event listeners for request lifecycle events.

A Note on Terminolog
@ivanionut
ivanionut / dup-backup.sh
Created November 19, 2016 18:15 — forked from Silvenga/dup-backup.sh
For daily systemwide encrypted backups of Ubuntu servers to remote host of Google Drive (free 15GB of storage).
#!/bin/bash
# Place in /usr/share/backup/
# and make executable
# chmod 0744 dup-backup.sh
# install:
# apt-get install duplicity python-gdata python-gobject-2 python-paramiko
## Remeber to change Google drive user name and Google drive folder
## And change Email
# Must run as root for system wide backups
@ivanionut
ivanionut / S3Wrapper.cfc
Created October 27, 2016 07:19 — forked from nathfy/S3Wrapper.cfc
Amazon Web Services (AWS) S3 Wrapper for ColdFusion
/**
* Amazon S3 REST Wrapper
* Version Date: 2015-09-03
*
* Copyright 2015 CF Webtools | cfwebtools.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@ivanionut
ivanionut / gist:fe016427a0c81aefcf100dd046071f1b
Created September 27, 2016 07:03
CFML: UDF to highlight keywords in a string (useful for search result pages)
<cfscript>
/*
I highlight words in a string that are found in a keyword list. Useful for search result pages.
@param str String to be searched
@param searchterm Comma delimited list of keywords
*/
string function highlightKeywords( required string str, required string searchterm ){
var j = "";
var matches = "";
var word = "";
@ivanionut
ivanionut / nginx.conf
Created August 21, 2016 12:49 — forked from bradleyboy/nginx.conf
nginx rewrite setup for Koken
# Enable gzip. Highly recommending for best peformance
gzip on;
gzip_comp_level 6;
gzip_types text/html text/css text/javascript application/json application/javascript application/x-javascript;
# By default, do not set expire headers
expires 0;
# Set expires header for console CSS and JS.
# These files are timestamped with each new release, so it is safe to cache them agressively.
@ivanionut
ivanionut / nginx.conf
Created August 21, 2016 12:49 — forked from pyrmont/nginx.conf
This configuration file is designed to run the CMS Koken. If you just want a simple config file, use this instead: https://gist.github.com/pyrmont/6342859
daemon off;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /usr/local/etc/nginx/mime.types; # Update if necessary

Looping is employed by programming languages to repeat a behavior defined by a section of code either while a condition is maintained true (conditional looping), or a certain number of times (iterative looping). As with other programming languages, ColdFusion allows you to perform both iterative and conditional looping.

ColdFusion uses the cfloop tag to enable looping in tag-based syntax. cfloop permits you to loop over a variable such as a structure or array, loop while a condition remains true, or loop for a given iteration. ColdFusion permits looping in cfscript using for loops and do while loops.

Tag-based Looping

@ivanionut
ivanionut / passwordCheck.cfc
Created July 7, 2016 15:56
A ColdFusion component for testing the strength of a password, which is necessary for enhancing the security of an application.
<!------------------------------------------------------------------------------
|| Component : passwordCheck.cfc
|| Author : Jason Luttrell
|| Description : Functionality to test for password strength.
|| Public Methods : init()
|| : initialize component
|| isPasswordValid()
|| : returns boolean indicating whether or not the
|| password meets the minimum requirements.
|| getErrors()
@ivanionut
ivanionut / gist:6c8b77ef02c7d7a82058d1745d6f6971
Created June 21, 2016 12:28 — forked from alinpopa/gist:1281448
elasticsearch analyzer example - Test Queries
# Index
---------------------------------------------------------------------
curl -XPUT http://localhost:9200/pictures/ -d '
{
"settings": {
"analysis": {
"analyzer": {
"index_analyzer": {
"tokenizer": "standard",