Skip to content

Instantly share code, notes, and snippets.

View mikegrassotti's full-sized avatar

Michael Grassotti mikegrassotti

View GitHub Profile
@mikegrassotti
mikegrassotti / blog1.json
Created October 4, 2011 19:50
Sample blog post json
# Comment on a blog post
{ "index" : { "_index" : "activities", "_type" : "comment", "_id" : "HBASE-ACTIVITY-ID" } }
{ "aggregation_id" : "HBASE-AGGREGATION-ID",
"activity_types" : ["comment", "type2", "etc..."],
"timestamp" : "2009-11-15T14:12:12",
"content" : {
"key" : "value" #(e.g json data describing the activity - an application can use this to display the activity)
},
"user" : {
"user_id" : "red rover user id"
@mikegrassotti
mikegrassotti / gist:2247065
Created March 30, 2012 05:55
Using sed to upgrade to Factory Girl 3
# FactoryGirl3ForYouAndMe
# The new syntax: http://robots.thoughtbot.com/post/19412394597/factory-girl-hits-3-0
#
# Where to learn sed?
# http://www.grymoire.com/Unix/Sed.html#uh-6
# http://www.markhneedham.com/blog/2011/01/11/sed-across-multiple-files/
#
# What needs to change?
find . -type f -name "*.rb" -print0 | xargs -0 grep "Factory.create"
find . -type f -name "*.rb" -print0 | xargs -0 grep "Factory.build"
require 'digest' unless defined?(Digest)
# Just in case this isn't a rails app
class Hash
def to_query
require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
map {|k,v| [k,v].map {|p| CGI::escape(p.to_s) }.join('=') }.join('&')
end
end
@mikegrassotti
mikegrassotti / gist:2712394
Created May 16, 2012 17:26
cohort activity
select DATE_FORMAT(u.created_at, '%Y-%m'), DATE_FORMAT(p.published_at, '%Y-%m'), count(*) FROM pfeed_items p, users u where u.id = p.originator_id and p.type IN ('Pfeeds::UserJoinedGroup', 'Pfeeds::UserLeftGroup', 'Pfeeds::UserInvitedUser', 'Pfeeds::UserSharedActivity', 'Pfeeds::UserMessagedGroup', 'Pfeeds::UserPostedItem', 'Pfeeds::UserAttachedTag', 'Pfeeds::UserCreatedBlogPost', 'Pfeeds::UserLikedItem', 'Pfeeds::UserFollowedItem') AND u.created_at > '2012-01-01' AND p.published_at > '2012-01-01' GROUP BY DATE_FORMAT(u.created_at, '%Y-%m'), DATE_FORMAT(p.published_at, '%Y-%m')
@mikegrassotti
mikegrassotti / gist:3029323
Created July 1, 2012 19:29
Masonry Grid using Ember StateManager
# TODO: Add the code
@mikegrassotti
mikegrassotti / fade.png
Created August 17, 2012 18:36
CasperJS (or PhantomJS) don't show modal content when using .fade
fade.png
@mikegrassotti
mikegrassotti / index.html
Created September 5, 2012 19:03
Testable emberjs apps
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bootstrap, from Twitter</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body>
@mikegrassotti
mikegrassotti / magic
Created November 21, 2012 16:18
Unix one liners to move files around and other magic...
# Change files around and other magic...
ls -d *.hbs | sed -e 's/.*/mv & &/'
@mikegrassotti
mikegrassotti / gist:4329541
Created December 18, 2012 16:40
Experimenting with gist capabilities
Just some text
@mikegrassotti
mikegrassotti / rails_debug.rb
Created December 21, 2012 06:20
Parse rails cookie
class RailsDebug
class << self
def show_session(cookie)
Marshal.load(Base64.decode64(CGI.unescape(cookie.split("\n").join).split('--').first))
end
end
end