Skip to content

Instantly share code, notes, and snippets.

@121onto
121onto / yelp-ratings-to-array.js
Last active April 13, 2016 03:54
Display ratings on a yelp page as an array
// 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 March 7, 2016 18:26
Example migration for changing paperclip storage path
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)