Skip to content

Instantly share code, notes, and snippets.

@cache_id=nil,
@file=
#<Cloudinary::CarrierWave::CloudinaryFile:0x007fb9ca6dbb28
@filename="j8geq7jnr1p0o4v9eddd.jpg",
@format="jpg",
@identifier="v1400870278/j8geq7jnr1p0o4v9eddd.jpg",
@public_id="j8geq7jnr1p0o4v9eddd",
@resource_type="image",
@storage_type=nil,
@uploader=#<ImageUploader:0x007fb9c7bf7cb8 ...>,
/Users/leslielai/.rvm/gems/ruby-2.1.1@apartmentlist/gems/activerecord-3.2.17/lib/active_record/connection_adapters/postgresql_adapter.rb:1163:in `exec': PG::UndefinedTable: ERROR: relation "referrals" does not exist (ActiveRecord::StatementInvalid)
LINE 5: WHERE a.attrelid = '"referrals"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"referrals"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
~/apartment_list/apartmentlist (dev)$ wget "http://deploy.local:8080/files/al-production-pgbackups/a057.dump"
--2014-03-27 16:08:11-- http://deploy.local:8080/files/al-production-pgbackups/a057.dump
Resolving deploy.local... 10.33.31.247, 10.33.31.247, fe80::129a:ddff:fe45:83d9, ...
Connecting to deploy.local|10.33.31.247|:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7805229401 (7.3G) [application/octet-stream]
Saving to: 'a057.dump'
100%[=================================================================================================================>] 7,805,229,401 44.8MB/s in 2m 33s
grouping by ids or listings
.group_by_type
includes all listing classes as keys
groups listings
.rids_by_type_includes?
return true if the listing exists
return false if the listing does not exist
.find_all_by_rental_id_for_srp
/Users/leslielai/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/bigdecimal/util.rb:39: [BUG] Segmentation fault at 0x00000000000000
class User < ActiveRecord::Base
def compatible?(another_user_id)
other = User.find(another_user_id)
if orientation == 's' && other.orientation == 'g'
return false
elsif orientation == 'b' && other.orientation == 'b'
return true
elsif (orientation == 's' || orientation == 'b') &&
(other.orientation == 's' || other.orientation == 'b')
return gender != other.gender
class TransactionStats
def initialize(transactions, date_range)
@transactions = transactions
@date_range = date_range
end
def total_sales_between_dates
total_sales(transactions_between_dates)
end
class Customer
attr_reader :referrer
def initialize(name, referrer)
@name = name
@referrer = referrer || NullReferrer.new
end
def referrer_name
referrer.name
class Customer
attr_reader :referrer
# Every customer has a name, but only some customers have a referrer.
def initialize(name, referrer = nil)
@name = name
@referrer = referrer
end
def referrer_name
<div class="row">
<div class="col-md-offset-3" >
<form class="add_choice" action="/surveys/<%= @survey_id %>/questions/<%= @question_id %>/choices" method="post">
<div>Choice: <input name ="choice" type="text"></div><br>
<div class="another_choice"><button type="submit" class="btn btn-primary btn-xs add_c">Add Choice</button></div>
</form><br>
@ltlai
ltlai / form-validator.js
Last active December 21, 2015 03:58 — forked from ksolo/form-validator.js
Form Validation
// shorthand for $(document).ready();
$(function(){
$('button').click(function(e) {
var email = $(':input[name="email"]').val();
var password = $(':input[name="password"]').val();
var errors = []
if (invalidEmail(email)) {
errors.push(invalidEmail(email));
};