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
# To try and fix the sort order, switching to an integer instead of time. | |
integer :listed_at do |item| | |
original_listed_at_time = nil | |
original_item = item.original_item if item.original_item_id.present? && item.payout_policy == "upfront" | |
if original_item && original_item.created_at < Time.parse("April 1 2014") | |
original_listed_at_time = original_item.listed_at | |
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
# A. Puting a file to dropbox | |
@db_session.client.put_file("/Some Shared Dropbox Folder the User has access to/my_data_file.csv","#{Rails.root}/tmp/my_data_file.csv") | |
# B. Getting a file from dropbox (from dropbox site) | |
contents, metadata = @db_session.client.get_file_and_metadata('/magnum-opus.txt') | |
open('magnum-opus.txt', 'w') {|f| f.puts contents } | |
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
# 1. Create a new record (account email is optional) | |
@db_session = MyDropboxSession.create({app_key: MyDropboxSession::APP_KEY, | |
app_secret: MyDropboxSession::APP_SECRET, | |
account_email: "[email protected]"}) | |
# 2. Get the authorization url and visit it in your browser and then authorize the Application | |
@db_session.authorization_url | |
# 3. After authorizing in the browser, complete the authorization | |
# - This gets the access token, serializes the session and saves it in the database |
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 CreateMyDropboxSessions < ActiveRecord::Migration | |
def change | |
create_table :my_dropbox_sessions do |t| | |
t.string :app_key | |
t.string :app_secret | |
t.string :account_email | |
t.boolean :authorized, default: false | |
t.text :serialized_session | |
t.timestamps |
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
require "dropbox_sdk" | |
class MyDropboxSession < ActiveRecord::Base | |
# This can obviously live anywhere you store your credentials or settings. | |
APP_KEY = "*********" | |
APP_SECRET = "%%%%%%%%%" | |
scope :authorized, where(authorized: true) |
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
ItemEvent.where("item_events.created_at > ? AND item_events.created_at < ?",Time.parse("January 15 2013"),Time.parse("January 16 2013")).select("COUNT(DISTINCT item_events.item_id) AS cnt").first.cnt | |
=> 1979 | |
Item.where("items.created_at > ? AND items.created_at < ?",Time.parse("January 15 2013"),Time.parse("January 16 2013")).count | |
=> 2739 |
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
| InnoDB | | | |
===================================== | |
120920 22:53:10 INNODB MONITOR OUTPUT | |
===================================== | |
Per second averages calculated from the last 49 seconds | |
----------------- | |
BACKGROUND THREAD | |
----------------- | |
srv_master_thread loops: 46401 1_second, 45420 sleeps, 4635 10_second, 70 background, 70 flush | |
srv_master_thread log flush and writes: 48122 |
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
+------------------------------------------+-------------+ | |
| Variable_name | Value | | |
+------------------------------------------+-------------+ | |
| Aborted_clients | 7287 | | |
| Aborted_connects | 0 | | |
| Binlog_cache_disk_use | 45 | | |
| Binlog_cache_use | 1130102 | | |
| Binlog_stmt_cache_disk_use | 0 | | |
| Binlog_stmt_cache_use | 0 | | |
| Bytes_received | 4714 | |
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
[ | |
{ "type": "add", | |
"id": 153001, | |
"version": 1, | |
"lang": "en", | |
"fields": { | |
"adjustable_waist": 0, | |
"brand_id": 141, | |
"brand_name": "Gymboree", | |
"brand_tier_id": 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
{ | |
bag: { | |
id: "888888", | |
code: "01-IND-999999-888888" | |
} | |
address: { | |
name: "John Smith", | |
line1: "570 Market St", | |
line2: "4th Floor", | |
city: "San Francisco", |
NewerOlder