This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Concerns | |
module Gmoney | |
extend ActiveSupport::Concern | |
included do | |
def self.gmoney(*attrs) | |
attrs.each do |attr| | |
define_method(:"#{attr}=") do |money| | |
if money.blank? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BigDecimal | |
include ActionView::Helpers::NumberHelper | |
def inspect | |
to_s('F') | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def subscribe_to_ticker | |
@ticker_thread = Thread.new do | |
@ticker_connection = WampClient::Connection.new(uri: 'wss://api.poloniex.com', realm: 'realm1', verbose: false) | |
@ticker_connection.on_join do |session, details| | |
session.subscribe('ticker', method(:ticker_handler)) | |
end | |
@ticker_connection.on_disconnect do |reason| | |
puts "DISCONNECTED: #{reason}" | |
end | |
@ticker_connection.open |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:gotoline() | |
let file = bufname("%") | |
let names = matchlist( file, '\(.*\):\(\d\+\)') | |
if len(names) != 0 && filereadable(names[1]) | |
exec ":e " . names[1] | |
exec ":" . names[2] | |
if foldlevel(names[2]) > 0 | |
exec ":foldopen!" | |
endif | |
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Conversation < ActiveRecord::Base | |
belongs_to :initiator, :class_name => '::User' | |
belongs_to :recipient, :class_name => '::User' | |
has_many :messages | |
has_one :last_message, -> { order("created_at DESC") }, :class_name => '::Message' | |
scope :visible, -> do | |
joins("LEFT OUTER JOIN blockings b ON (b.blocker_id=conversations.initiator_id AND b.blocked_id=conversations.recipient_id) OR (b.blocked_id=conversations.initiator_id AND b.blocker_id=conversations.recipient_id)").where("b.id IS NULL") | |
end | |
scope :between, ->(user1,user2) { with(user1).with(user2) } | |
scope :with, ->(other) { where("? IN (initiator_id,recipient_id)", other.id) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def spiral(array,ans=[]) | |
return ans unless array.any? | |
ans += array.shift | |
spiral(array.transpose.reverse, ans) | |
end | |
array = [ | |
[1,2,3,1], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Sizes::CupSize < Size | |
US = %w[A B C D DD/E DDD/F DDDD/G DDDDD/H] | |
EU = %w[A B C D E F G H] | |
UK = %w[A B C D DD E F FF] | |
[:us, :uk, :eu].each do |region| | |
class_eval %Q" | |
def #{region} | |
by_region(:#{region}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started GET "/photos/12" for 127.0.0.1 at 2013-08-13 23:29:24 -0500 | |
Processing by PhotosController#show as HTML | |
Parameters: {"id"=>"12"} | |
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1 | |
User Exists (0.4ms) SELECT 1 AS one FROM `users` WHERE (`users`.`username` = BINARY 'trappist' AND `users`.`id` != 1) LIMIT 1 | |
Photo Load (0.3ms) SELECT `photos`.* FROM `photos` WHERE `photos`.`published_at` IS NOT NULL AND `photos`.`id` = 12 LIMIT 1 | |
Album Load (0.3ms) SELECT `albums`.* FROM `albums` INNER JOIN `album_memberships` ON `albums`.`id` = `album_memberships`.`album_id` WHERE `album_memberships`.`photo_id` = 12 ORDER BY `albums`.`id` ASC LIMIT 1 | |
(0.1ms) BEGIN | |
SQL (0.3ms) UPDATE `photos` SET `views_count` = 13, `updated_at` = '2013-08-14 04:29:24' WHERE `photos`.`id` = 12 | |
(0.9ms) COMMIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scope :conjoins, -> { joins("LEFT JOIN connections ON connections.initiator_id=users.id OR connections.recipient_id=users.id") } | |
scope :friends_with, ->(other) { conjoins.where("(connections.initiator_id=:uid OR connections.recipient_id=:uid) AND users.id != :uid", :uid => other.id) } | |
scope :blockjoins, -> { joins("LEFT JOIN blockings ON blockings.blocker_id=users.id OR blockings.blocked_id=users.id") } | |
scope :blocked_from, ->(other) { blockjoins.where("(blockings.blocker_id=:uid OR blockings.blocked_id=:uid) AND users.id != :uid", :uid => other.id) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
product image is sometimes product_image, sometimes image_url | |
include product data (name?) in meta data of get_link | |
7.2 million designers, most of them obviously bogus | |
additional data, especially name, returned via oauth... also did you know this exists? https://github.com/leknarf/omniauth-rewardstyle | |
would be a big overhaul but designers, advertisers etc. should have ids which we'd use to filter in search, product feed etc. |
NewerOlder