Skip to content

Instantly share code, notes, and snippets.

View kivanio's full-sized avatar
🏠
Working from home

Kivanio Barbosa kivanio

🏠
Working from home
View GitHub Profile
@kivanio
kivanio / KM-instructions.md
Last active January 28, 2016 19:00 — forked from kippjb/KM-instructions.md
Instructions for downloading, compiling, and parsing KISSmetrics data exports by event

##Instructions for downloading, compiling, and parsing KISSmetrics data exports by event

####Summary: The KISSmetrics data export feature does not allow users an easy way to analyze data by event. This Gist outlines instructions for downloading and parsing KISSmetrics data for event-level analysis.

#####Step 1: Export data from KISSmetrics

Set up AWS S3 bucket.

@kivanio
kivanio / export_processor.md
Created January 28, 2016 19:00 — forked from clay-whitley/export_processor.md
km-export-processor Documentation

km-export-processor gem

The purpose of this gem is to consume the JSON that KISSmetrics exports to an S3 bucket, and transform it in a variety of useful ways.

The core features are:

  • JSON compiler : Aggregates all KISSmetrics JSON files in a directory, into a single (nonstandard) file.
  • JSON to JSON converter : Converts a nonstandard JSON file into standard format.
  • JSON to CSV converter : Converts a nonstandard JSON file into a CSV file, where each row is an event/property/alias.
  • Reimporter : Takes a nonstandard JSON file, and an API key, and sends the data in the JSON file to the product using the KMTS gem.
ActiveAdmin.register Product do
permit_params :name, :category_id, :description, :text, :slug, :in_slider, :tag_ids => []
filter :category
filter :base_tags
filter :name
filter :text
filter :created_at
filter :updated_at
ActiveAdmin.setup do |config|
# == Site Title
#
# Set the title that is displayed on the main layout
# for each of the active admin pages.
#
config.site_title = "Balance Cafe"
# Set the link url for the title. For example, to take
ActiveAdmin.register Article do
filter :site
index do
column ("Site") { |article| article.site.name }
column ("Author"), sortable: :author do |article|
article.author
end
column ("Title"), sortable: :title do |article|
ActiveAdmin.register Shipment do
def generate_shipment(shipment)
# Generate Shipment
Prawn::Document.generate @shipment.shipment_location do |pdf|
# Title
pdf.text "Shipment ##{shipment.code}", :size => 25
# Sender info
pdf.text shipment.sender.first_name
pdf.text shipment.sender.address
# app/models/OnlyAdminsAuthorization.rb
class OnlyAdminsAuthorization < ActiveAdmin::AuthorizationAdapter
def authorized?(action, subject = nil)
classname = (subject.is_a? Class)? subject.name : subject.class.name
account = Account.current
# check if expired
module ActiveAdmin
module Reports
module DSL
def enable_reports
action_item only: :index do
link_to("Download", {action: :report, params: params}, {method: :post, data: { confirm: "Are you sure you want to generate this report?"}})
end
collection_action :report, method: :post do
module ActiveAdmin
module Inputs
class FilterNumericRangeInput < ::Formtastic::Inputs::StringInput
include FilterBase
def to_html
input_wrapping do
[ label_html,
builder.text_field(gt_input_name, input_html_options(gt_input_name)),
template.content_tag(:span, "-", :class => "seperator"),
# Add Action button on the top navigation menu. Useful for resource with nested resources
action_item :only => :show do
link_to('Show Users', admin_group_users_path(resource))
end
# Custom show page with children items
show do