Skip to content

Instantly share code, notes, and snippets.

View rigelstpierre's full-sized avatar

Rigel St. Pierre rigelstpierre

View GitHub Profile
@rigelstpierre
rigelstpierre / artist_presenter.rb
Created March 31, 2016 14:56
artist_presenter.rb
class ArtistPresenter < BasePresenter
include DecoratorHelpers
def initialize(artist, options={})
super(artist)
@current_user = options[:user]
@score = options[:score]
end
def to_hash
@rigelstpierre
rigelstpierre / app.js
Created October 14, 2015 15:12
React App
import React from "react";
import Nav from "./nav";
require('./stylesheets/style.scss');
React.render(
<Nav />,
document.body
);
@rigelstpierre
rigelstpierre / spotify.rb
Created December 7, 2014 19:18
Spotify Auth
def spotify
self.validate_spotify_auth_token if self.spotify_auth_token.present?
config = {
:access_token => self.spotify_auth_token, # initialize the client with an access token to perform authenticated calls
:raise_errors => true, # choose between returning false or raising a proper exception when API calls fails
# Connection properties
:retries => 0, # automatically retry a certain number of times before returning
:read_timeout => 10, # set longer read_timeout, default is 10 seconds
:write_timeout => 10, # set longer write_timeout, default is 10 seconds
@rigelstpierre
rigelstpierre / gist:809e8e74f76840521320
Last active August 29, 2015 14:09
Create new track friends api

Path: /api/app/users/#{facebook_uid}/friends or /api/app/users/#{email}/friends

Method: POST

Params: :uids, :emails, :user

Expected Response: {"data"=&gt;{"tracked_friends_count" =&gt; "10"}

@rigelstpierre
rigelstpierre / tacky.rb
Created June 13, 2014 16:40
Tic Tac Toe Code Challenge
require "color_text"
class Tacky
def initialize
# all places that are possible wins
@columns = [
[:a1,:a2,:a3],
[:b1,:b2,:b3],
[:c1,:c2,:c3],
FF.calendarPosts = function() {
FF.el.calendar_post_list_item.click(function (e) {
e.preventDefault();
// set vars on this
var $this = $(this),
item_title = $this.data('title'),
item_permalink = $this.data('permalink'),
item_date = $this.data('date'),
case service_time.relation_to_sunday
when "Current"
previous_sunday
when "Before"
if date.wday == service_time.day_of_week
#use date and time
actual_service_time = service_time_with_offset(service_time, date, true)
return upcoming_sunday ? time >= actual_service_time : return previous_sunday
class Photo < ActiveRecord::Base
belongs_to :listing, :counter_cache => true
scope :by_landlord, lambda {|landlord_id| joins(:listing).where('landlord_id = ?', landlord_id)}
default_scope order('"photos"."index" ASC')
attr_accessible :index, :image, :image_url, :image_processing
attr_accessor :is_pre_listing
validates_presence_of :listing_id, :unless => :is_pre_listing
require 'digest/md5'
class RemoveDuplicateRecords < ActiveRecord::Migration
def self.up
addresses = {}
Listing.find_each do |listing|
digest = Digest::MD5.hexdigest("#{listing.street_address}#{listing.apartment_no}")
if addresses.include?(digest)
listing.destroy
else
require 'digest/md5'
class RemoveDuplicateRecords < ActiveRecord::Migration
def self.up
addresses = {}
for Listing.find_each do |listing|
digest = Digest::MD5.hexdigest("#{listing.street_address}#{listing.apartment_no}")
if addresses.include?(digest)
listing.destroy
else