Skip to content

Instantly share code, notes, and snippets.

View robertz's full-sized avatar

Robert Zehnder robertz

View GitHub Profile
component {
property name = "SQSService" inject = "model";
public function sendMessage(required string message) {
SQSService.sendMessage(queue = "test", message = arguments.message);
return;
}
public function startQueue() {
cfthread(name = "sqs-poll", action = "run", SQSService = SQSService) {
@robertz
robertz / gist:39a144fee330cd5c491f
Created September 16, 2014 12:36
Fixing da errors
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Simple Chat</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
<div id="messageContainer" style="display: none;">
@robertz
robertz / gist:4ba6cdc6b4005ada384c
Created August 25, 2014 17:07
RequestContextDecorator example
component extends="coldbox.system.web.context.RequestContextDecorator" {
public void function configure(){
var rc = getRequestContext().getCollection();
var prc = getRequestContext().getCollection(private = true);
if(!structKeyExists(session, 'memberGUID')){
session['memberGUID'] = getController().getSetting('defaultMemberGUID');
}
@robertz
robertz / gist:b62561d896a92fe6800e
Created August 17, 2014 00:53
WhosonTracker.cfc
component name="WhosonTracker" {
function init(){
variables.clients = [];
return this;
}
function trackHit(required Event){
var updateFlag = 0;
var userCount = arrayLen(variables.clients);
@robertz
robertz / gist:51a87ce9e31f87f36fce
Created August 17, 2014 00:44
Interceptors configuration
//Register interceptors as an array, we need order
interceptors = [
//SES
{class="coldbox.system.interceptors.SES",
properties={}
}
//WhosOn
,{class="whoson.ColdBoxInterceptor",
properties={}
}
@robertz
robertz / gist:2ec64e9e8e80fe78c31d
Created August 17, 2014 00:17
ColdboxInterceptor.cfc
component {
void function Configure() {}
boolean function afterAspectsLoad(required any event, required struct interceptData){
var Tracker = new whoson.WhosonTracker();
getColdboxOCM().set('WhosOn', Tracker, 0);
return false;
}
public function get(string objectid = '') {
var queryUser = new query();
var hasParams = len(arguments.objectid) && isNumeric(arguments.objectid);
var sql = 'select objectID, username, password, bAdmin, ratingLimit from user';
if(hasParams){
sql = sql & ' where objectid = :objectid';
}
queryUser.setSQL(sql);
if(hasParams){
queryUser.addParam(name="objectid",value="1",cfsqltype="INT");
@robertz
robertz / gist:6a8cb4f83531adc4966f
Created June 30, 2014 03:00
Lookup movies with tmdb.org
/*
* Interface with themoviedatabase.org
*/
component name = "TMDBService" accessors = "false"{
property name = "Logger" inject = "logbox:logger:{this}";
property name = "api_key" inject = "coldbox:setting:apiKey";
public TMDBService function init(){
return this;
@robertz
robertz / gist:6917656
Last active December 25, 2015 04:29
Nginx server configuration for SSL-enabled site
server {
listen 80;
server_name domain.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443 ssl;
server_name domain.com;
client_max_body_size 50M;
access_log /var/logs/domain.com_access.log buffer=32k;
@robertz
robertz / chatdemo.js
Created June 3, 2013 21:55
Javascript object for the chat demo
var engine = {
delay: 5000
,currentID: 0
,init: function(){
window.chat = {};
window.chat.data = {};
$('#send').on('click', engine.sendMessage);
$('#setName').on('click', engine.setUser);
$('#message').on('keypress', function(e){
if(e.which == 13 && $('#message').val().length){