Skip to content

Instantly share code, notes, and snippets.

Avatar

Patric M DelCioppo sevennineteen

View GitHub Profile
@sevennineteen
sevennineteen / template-helpers.js
Created Mar 9, 2013
Simple Handlebars helper to dump current context to screen for debugging
View template-helpers.js
define(['handlebars'], function (Handlebars) {
var templateHelpers = {
// Register all defined template helpers
load: function () {
// Render JSON representation of current context,
// e.g., {{{debug this}}}
Handlebars.registerHelper('debug', function (context) {
return new Handlebars.SafeString(
@sevennineteen
sevennineteen / example.json
Created Dec 28, 2012
Example using Jinja2 to populate a JSON payload template
View example.json
{ "path": "/content/geometrixx/my-first-jinja-page",
"properties": [
{ "name": "jcr:primaryType",
"value": "cq:Page" }],
"nodes": [
{ "path": "jcr:content",
"properties": [
{ "name": "jcr:primaryType",
"value": "cq:PageContent"},
@sevennineteen
sevennineteen / gist:2763408
Created May 21, 2012
Show HTTP request headers (Rack)
View gist:2763408
require 'sinatra'
get '/' do
@headers = env.reject {|k, v| k =~ /async*|rack*/}.sort.each
haml :index
end
@sevennineteen
sevennineteen / tree_activation.py
Created Jan 25, 2012
CQ5 tree activation example
View tree_activation.py
import httplib2
import urllib
import base64
from html2text import html2text
#----------------------------------------------------------
# INSTANCE-SPECIFIC CONSTANTS // customize before running
CQ_HOSTNAME = 'localhost'
CQ_SERVER = 'http://%s:4502' % CQ_HOSTNAME
USERNAME = 'admin'
@sevennineteen
sevennineteen / delta_monitor.py
Created Dec 18, 2011
Produce high-level summary of file system changes since a given date
View delta_monitor.py
import codecs, os, glob
from datetime import datetime
import time
from stat import *
#----------------------------------------------------------
BASE_DIR = r'C:\some_folder'
FILE_DIRS = [
'some_subfolder_a',
'some_subfolder_b',
@sevennineteen
sevennineteen / gist:1235375
Created Sep 22, 2011
Boilerplate to extend Day CQ's HTTP Polling Importer
View gist:1235375
package com.my.company.customimporter;
import java.io.IOException;
import java.io.InputStream;
import org.apache.sling.api.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.polling.importer.HttpImporter;
@sevennineteen
sevennineteen / gist:1224478
Created Sep 17, 2011
Set logger level on Heroku Sinatra app
View gist:1224478
require "logger"
configure do
LOG = Logger.new(STDOUT)
LOG.level = Logger.const_get ENV['LOG_LEVEL'] || 'DEBUG'
LOG.info 'I am logging something.'
end
@sevennineteen
sevennineteen / app.rb
Created Sep 10, 2011
Basic security check to prevent cross-site requests (using Sinatra)
View app.rb
require "rubygems"
require "sinatra"
require "json"
require "haml"
get '/' do
CURRENT_HOST = env['SERVER_NAME'] == 'localhost' ? "#{env['SERVER_NAME']}:#{env['SERVER_PORT']}" : env['SERVER_NAME']
haml :home
end