Skip to content

Instantly share code, notes, and snippets.

@joelevering
joelevering / sampletable.txt
Created September 9, 2016 19:11
Sample definition in Redshift
Table "public.reverb_event_usersignedup"
Column | Type | Modifiers
---------------------+-----------------------------+-----------
timestamp | timestamp without time zone |
event_source | character varying(1024) |
newsletter_opt_in | character varying(1024) |
user_id | character varying(1024) |
registration_source | character varying(1024) |
referer | character varying(1024) |
aid | character varying(1024) |
@joelevering
joelevering / columns.go
Last active September 9, 2016 19:04
Aggregate column information for a Protobuf
// Determine what fields should be created for a specific event
func FetchFields(event string) ([]SchemaField, error) {
var fields []SchemaField
messageType := proto.MessageType(event)
if messageType == nil {
return fields, fmt.Errorf("schema does not exist: %s", event)
}
fields = FetchFieldsForStruct("", messageType.Elem())
return fields, nil
}
@joelevering
joelevering / table.go
Last active September 9, 2016 18:54
Create Table From Protobuf
func (d *DB) createTable(table string) {
if d.tableExists(table) {
return
}
var cols []string
for _, col := range defaultCols { // e.g. timestamp, uid
cols = append(cols, fmt.Sprintf(“%s %s”, col.Name, col.PGType()))
}
allCols := strings.Join(cols, “, “)
cmd := fmt.Sprintf(“CREATE TABLE %s (%s)”, table, allCols)
@joelevering
joelevering / user.proto
Created September 9, 2016 18:51
Example Protobuf
message UserSignedUp {
optional bool newsletter_opt_in = 1;
optional string user_id = 2;
optional string registration_source = 3;
optional string referer = 4;
optional string aid = 5;
optional string url = 6;
optional string country_code = 7;
}
module Reverb
module Google
module ShoppingV2
class RemoveEndedOrSoldOutProducts
def self.remove
new.remove
end
def remove
@joelevering
joelevering / carousel.js
Created October 17, 2013 21:00 — forked from ksolo/carousel.js
Image Carousel
@joelevering
joelevering / form-validator.js
Last active December 25, 2015 19:39 — forked from ksolo/form-validator.js
Form Validation
// shorthand for $(document).ready();
$(function(e){
//Your code...
function appendError(message){
$("#errors").append("<li>" + message + "</li>");
}
$('form').on("submit", function(e) {
var email = $('input[name=email]').val();
var password = $('input[name=password]').val();
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
// DRIVER CODE: Do **NOT** change anything below this point. Your task is to implement code above to make this work.
//------------------------------------------------------------------------------------------------------------------
@joelevering
joelevering / index.html
Created October 17, 2013 15:10 — 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>
/* 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.
*/