Skip to content

Instantly share code, notes, and snippets.

View clay-whitley's full-sized avatar

Clay Whitley clay-whitley

View GitHub Profile
@clay-whitley
clay-whitley / export_processor.md
Last active April 5, 2017 04:53
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.
<script type="text/javascript">
if (!affinova_user){
var _kmq = _kmq || [];
var _kmk = _kmk || '4283d6742d744fff4848dfddeb6e314a088398b0';
function _kms(u){
setTimeout(function(){
var d = document, f = d.getElementsByTagName('script')[0],
s = d.createElement('script');
s.type = 'text/javascript'; s.async = true; s.src = u;
f.parentNode.insertBefore(s, f);

#Routing in Rails

##Resources

In Sinatra applications, you may have noticed a pattern in the routes/controller actions (they are the same in Sinatra) you were creating. In Rails, the common routes of index, show, new, edit, create, update, and destroy are all contained in a "resource". You typically will want a resource for each model in your application you want to perform these actions on. For example, this would constitute a users resource:

HTTP verbPathController ActionUsed for
source :rubygems
# PostgreSQL driver
gem 'pg'
# Sinatra driver
gem 'sinatra'
gem 'shotgun'
# Use Thin for our web server
$(document).ready(function() {
$('form').on('submit', function(e){
e.preventDefault();
var formData = $(this).serialize();
// get data from form field
$.post('/grandma', formData, function(response) {
$('#grandma_message').text(response.grandma_response);
});
// create a new ajax request with data
// take response ajax call gives us and perform logic (inserting data we receive back into dom)
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the socrates website.
Enter them in the console to make sure it works and then save
your results here.
Choose a new pair for each. Add your names to the section you complete.
*/
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the socrates website.
Enter them in the console to make sure it works and then save
your results here.
Choose a new pair for each. Add your names to the section you complete.
*/
@clay-whitley
clay-whitley / index.html
Last active December 20, 2015 20:19 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
@clay-whitley
clay-whitley / file.rb
Created July 29, 2013 17:55
wax on/wax off
require 'csv'
module FlashCardDB
def self.parse
result = []
CSV.foreach("flashcards.csv") do |row|
unless row[0] == "definition"
result << {definition: row[0], term: row[1]}
end
class Vehicle
def initialize(args)
@status = :stopped
@color = args[:color]
@gas_capacity = 10
@gas = 5
end
def drive
unless needs_gas?