Skip to content

Instantly share code, notes, and snippets.

@jclausen
jclausen / Memento
Created April 26, 2017 21:23
Memento
/**
* Convenience method to retreive the default memento and rename the primary key in the struct, if necessary
*
* @renameKey boolean Whether or not to rename the primary key column of the structure to reflect the entity name (important for auto-population of new models)
* @recurse boolean Whether to recurse in to the `to-many` arrays and provide the PKs of those relationships
**/
public function asStruct( renameKey=false, recurse=false ){
var s = getMemento( recurse=arguments.recurse );
@jclausen
jclausen / EncryptionService.cfc
Created April 26, 2017 20:04
Encryption service object as wrapper for Bcrypt Module
/**
*
* @displayname Encryption Service Model
* @description This is a encryption Service Model
*
**/
component
singleton
{
property name="bCrypt" inject="BCrypt@BCrypt";
this.datasource = "myApp";
// ORM SETTINGS
this.ormEnabled = true;
this.ormSettings = {
// ENTITY LOCATIONS, ADD MORE LOCATIONS AS YOU SEE FIT
cfclocation=[ "models", "modules", "modules_app" ],
// THE DIALECT OF YOUR DATABASE OR LET HIBERNATE FIGURE IT OUT, UP TO YOU TO CONFIGURE
//dialect = "MySQLwithInnoDB",
// DO NOT REMOVE THE FOLLOWING LINE OR AUTO-UPDATES MIGHT FAIL.
dbcreate = "update",
@jclausen
jclausen / nginx.conf
Last active March 21, 2017 13:05
Dokku NGINX config with block to ensure unresolved hosts aren't routed to first config found
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
@jclausen
jclausen / haproxy.cfg
Created March 5, 2017 23:04
Haproxy - Load Balance All Domains with SSL Termination
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
maxconn 1024
@jclausen
jclausen / mysql-backup.sh
Created March 5, 2017 22:49
MySQL Backup Databases to S3
#!/bin/bash
source ~/.bashrc
cd /tmp
# get a list of all the databases
DBS=`mysql -u${MYSQL_USER} --password=${MYSQL_PASS} -e"SHOW DATABASES;" --batch -s`
# Loop through all the databases and create a dump of each one, followed by
# piping to gzip to create a compressed verison of the dump.
for db in $DBS; do
if [ "$db" != "information_schema" ] && [ "$db" != "performance_schema" ]; then
file=${db}-$(date +%Y-%m-%d)-$(date +%s).sql
@jclausen
jclausen / query-to-csv.cfm
Last active December 22, 2016 16:31
Query to CSV
<cfscript>
function downloadFile( required string filePath ){
var file_separator = '/';
var mimeType=getMimeType(arguments.filePath);
if(findNoCase("windows",server.os.name)){
file_separator = '\';
}
cfheader( name="Content-disposition" value="attachment;filename=#scrubFileName(listLast(filePath,file_separator))#" );
cfcontent( type="#mimeType#" file="#arguments.filePath#" deleteFile="true" reset="true" );
@jclausen
jclausen / sauser.cf
Last active February 16, 2023 21:01
ZCS SpamAssassin Default sauser.cf (Default required score)
use_bayes 1
skip_rbl_checks 0
dns_available yes
bayes_auto_learn 1
bayes_auto_learn_threshold_spam 5.0
use_pyzor 1
pyzor_path /usr/bin/pyzor
@jclausen
jclausen / railo2lucee.sh.txt
Last active August 29, 2015 14:14
Railo to Lucee In One Shot
# This series of commands was used to migrate an existing Railo installation to Lucee
# I didn't rename the railo_ctl shell so as not to muck with the existing auto-start configuration, but I'll update this later when I do
# You might want to run these one at a time on your own server - unless you're feeling brave :)
cd /tmp && \
tar -cvfz railo.bak.tar.gz /opt/railo && \
mkdir lucee_upgrade && \
cd lucee_upgrade && \
wget https://bitbucket.org/lucee/lucee/downloads/lucee-4.5.0.042-jars.zip && \
unzip lucee-4.5.0.042-jars.zip && \
httpd -k stop && \
@jclausen
jclausen / git-deploy.sh
Last active January 1, 2016 01:19
Basic Shell Script to Deploy Git Repository Using Middleman Local Repo Accepts -branch parameter
#!/bin/bash
# Staging Server Deployment script for Cygwin
branch=${parameter:-'HEAD'}
repo_dir="/srv/local-repos/myrepo.git"
dest_dir="/home/my-deployment-directory/wwwroot"
server_name="My Staging Server"
echo -e "Pulling latest repository updates from branch ${branch}...\n"