Skip to content

Instantly share code, notes, and snippets.

View robertz's full-sized avatar

Robert Zehnder robertz

View GitHub Profile
@robertz
robertz / gist:5088049
Created March 5, 2013 04:38
Railo connector for nginx
location / {
# Rewrite rules and other criterias can go here
# Remember to avoid using if() where possible (http://wiki.nginx.org/IfIsEvil)
try_files $uri $uri/ @rewrites;
}
location @rewrites {
# Can put some of your own rewrite rules in here
# for example rewrite ^/~(.*)/(.*)/? /users/$1/$2 last;
rewrite ^/(.*)? /index.cfm/$1 last;
component output="false" {
public any function init(){
variables.Stripe = createObject("Java", "com.stripe.Stripe");
Stripe.apiKey = "<YOUR SECRET KEY HERE>";
return this;
}
// https://github.com/jeisenlo/ColdFusion-Stripe-CFC
private numeric function timeToUTCInt(required timestamp date) {
<cfoutput>
<cfscript>
Stripe = new data.Commerce.Stripe();
card = {
"number": "4242424242424242",
"exp_month": "12",
"exp_year": "2015",
"cvc": "123",
"name": "Java Bindings Cardholder",
"address_line1": "140 2nd Street",
@robertz
robertz / gist:5667954
Created May 29, 2013 04:22
CFChat (old version) Core
<cfcomponent>
<cfscript>
variables.instance = structNew();
instance.chatHistory = arrayNew(1);
instance.clients = arrayNew(1);
instance.messageTotal = arrayLen(instance.chatHistory);
</cfscript>
<cffunction name="init" access="public" returntype="chat">
<cfreturn this/>
component name="ChatService" accessors="false" scope="application" {
property name="Logger" inject="logbox:logger:{this}";
property name="AntiSamy" inject="coldbox:plugin:AntiSamy";
public ChatService function init(){
variables.history = [];
variables.clients = [];
variables.messageCount = 0; // The ID of the last message
variables.birth = Now();
@robertz
robertz / endpointChat.cfc
Created June 3, 2013 21:54
Handler for the API endpoint
component
accessors=false
extends="coldbox.system.EventHandler"
{
property name="Logger" inject="logbox:logger:{this}";
property name="ChatService" inject="model";
// Posts a message to the stack
public void function put(Event, RC, PRC){
@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){
@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 / 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;
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");