Skip to content

Instantly share code, notes, and snippets.

@121onto
121onto / yelp-ratings-to-array.js
Last active Apr 13, 2016
Display ratings on a yelp page as an array
View yelp-ratings-to-array.js
// get array of ratings
var ratings = $("i.star-img")
.map(function(){return $(this).attr( "title" )})
.map(function(){return this.split(/[ ,]+/)})
.map(function(){return Number(this)})
.filter(function(){return this >= 0})
.toArray()
// print summary stats
console.log("LEN: ", ratings.length)
@121onto
121onto / 20160307172445_change_paperclip_attachment_path.rb
Created Mar 7, 2016
Example migration for changing paperclip storage path
View 20160307172445_change_paperclip_attachment_path.rb
class MoveAttachmentsToNewLocation < ActiveRecord::Migration
def initialize(name = self.class.name, version = nil)
access_key = Rails.application.secrets.g3_access_key_id
secret_key = Rails.application.secrets.g3_secret_access_key
storage = Fog::Storage::Google.new google_storage_access_key_id: access_key,
google_storage_secret_access_key: secret_key
@bucket_name = Rails.application.secrets.g3_bucket
@bucket = storage.directories.get(@bucket_name)
super(name, version)