How Fifty Shades of Grey could have been a less boring movie

fifty-shades1Here is my review for the movie everyone is buzzing about this Valentine’s Day. I read the three books a while ago. The movie was not a total waste of money but I could think of several ways it could have been less boring:

– It could have gone down a darker route, like The girl with a dragon tattoo or Gone girl, instead of the romantic route like Twilight. In fact, Jamie Dornan’s millionaire playboy with the a fancy penthouse and private helicopter is enticing but is nowhere near magnetic as brooding vampire Edward Cullen.

– Anastasia mumbled her way throughout the movie. They should have at least given her some narration like Bella, so she could express some of her virginal thoughts and desires in ways other than flashing her nipples and biting her lips.

– I was not too impressed with the cast from the beginning but Dakota Johnson’s body turned out to not be a bad choice. However, call me brainwash by Photoshop and Hollywood movies, Jamie Dornan’s physique is not that impressive. He’s not supposed to be too buff but, as this is a movie about fantasies, I expect to be wowed with a body like Chris Hemsworth’s in Thor or Channing Tatum’s in Magic Mike.

– Again, they could really amp up the dark side of Christian or tease for the next movies by giving some flashbacks of his prostitute mother or of him being whipped by Mrs Robinson. There’s no evidence of this character’s fucked up psychology other than the fact he has a playroom filled with some scary looking instruments. Boring! Even the piano playing scene has no emotion or depth to it.

– Anastasia’s mother is unusually attractive, but the young cast is weird looking: from roommate Kate to Christian’s brother with the creepy Elliot blonde beard. Mia appears for (literally) two seconds with a severe 1920s black bob because she ‘lives in Paris’, which is weird and not as cute as Alice’s pixie cut. Personally I found Christian’s chauffeur Taylor more attractive. His involvement is almost entirely cut out in the movie, even though they could have used the relationship to play up Christian’s controlling personality.

Basically, 50 shades of grey is a cliched romance flick with nudity, not a sexy movie about the BDSM lifestyle, which is a shame. I’d say the only winner from this franchise is The Weeknd with this seductive soundtrack:

How to deploy a Rails app and not destroy your production database

rails deploymentTraditionally there’re a few ways to set up your Rails database:
rake db:create db:migrate
Create a new database and run migrations
rake db:schema:load
Drop database if it exists and create tables according to your schema.
rake db:setup
Will run both rake db:schema:load and rake db:seed

db:schema:load is problematic. It is suggested in Rails schema.rb file that this is an efficient way (compared to db:migrate) to set up your database. However, it assumes that a) you have a database dedicated to the Rails app, b) have no existing data. But what if you want to create tables for your Rails app in an existing database with other important data?

Here’s a guide I’ve come up with on how to integrate your Rails app into an existing database by forgoing migrations:

 1. Create tables in your production database
Feel free to namespace them like this: myproject_users instead of the usual users.

2. Edit database.yml
Specify the name of your database and the user/password that has access to it under the corresponding environment setting (development or production).

3. Void migration files
Under db/migrate, either comment out the files’ content or change their extension to .txt.

4. Schema dump
db/schema.rb is auto generated by running migrations. Since you don’t plan to run them, rake db:schema:dump will update schema.rb and allow it to be used with ActiveRecord

5. Set custom table names
If the name of the tables are different from ActiveRecord convention (e.g.: you namespace the tables), add this to the model self.table_name = "[custom table name]". This will help Rails find the tables and avoid error.

Hope that was somewhat helpful. I’m also looking into deploying with Capistrano and submitting a pull request that would give a warning when you try to run rake db:schema:load.

Thoughts on Manhattan Love Story getting axed

   MLS4
A fragile fate

I checked weekly for new episodes of Manhattan Love Story (MLS) on Hulu for a month and didn’t see anything. Suddenly this weekend, 7 new episodes appeared out of thin air. So naturally I binged on them.

This morning, I realized that the MLS was cancelled in late October and episode 5 never even made it to the air (!) Apparently the last episode on air hit an all-series low of 2.6 million viewers, and that was the last drop. It’s very unfortunate because the third episode, which introduced Dana’s gay British boss, was truly hilarious.

Even though MLS received poor critical ratings, the fact that the network decided to drop it completely from air based on Nielsen ratings strikes me as strange. Personally I don’t watch any show when it airs (and I watch a fair amount). Do other forms of viewership (online/streaming) hold no weight? What’s worse is that ABC attempted to replace MLS with a back-to-back episode of Selfie, which is even more boring and less funny in my opinion.

On the plot and characters
I was rather excited when I saw MLS trailer in the summer. How could I not? I’m a sucker for rom coms, especially those that involving the superficial, flaky, fascinatingly cut-throat NYC dating scene.

MLS2Here’s how the show is realistic:
– The awkward run-in between Dana and Peter when he’s on a date with a regular hottie.
– Dana feigns dating ‘other’ people and not showing too much enthusiasm at Peter’s invitations to hang out.
– Dana and Peter both being invited to a party to which he had previously invited another date as a plus one.
– Amy’s huge SoHo loft in simply  is explained by the fact that she’s born rich and doesn’t have to work.

Why it fell short of living up to its promise:
– The two main characters are too stereotypical and have no depth. Dana, a small-town girl who gets a ‘dream job’ at a publishing company, is very flighty, unrealistically clumsy and doesn’t have much going in her work place besides being shunned by bitter old-timers, making copies and fraternizing with her dashingly handsome boss slash gay BFF. In the trailer scene, she is simply heard lusting after designer purses even though her character is not portrayed as being that into or involved with fashion.

MLS3– Peter is none other than ‘that guy’ – the bro, the douche bag and womanizer. The longest relationship he’s ever had is 10 months long despite being well into his twenties. He is that guy who is only nice looking (compared to other TV’s leading males!) but is ‘that hot’ in the dating pool just because he has somewhat of a sense of style and social skills around women.
– Such cliched, overwrought dating ploys and mishaps, e.g.:
+ Struggling to find date to an event to impress the other person you’re seeing
+ Not being able to consumate their relationship due to food poisoning
+ Freaking out about him proposing although you’ve obviously only dated for 3 months (monogamously 2 at most)
…………….

Entertaining points
– Some of the supporting cast are way more interesting than what goes on in Dana’s and Peter’s heads. Amy is pretty funny – she’s the essential smart, put-together, overly controlling know-it-all in every show. On Peter’s side, his step sister Chloe is the most down-to-earth, logical voice of the whole family. They provide some rationality and relief to the ridiculous, non-sense mess made by our leads.

– Of course, the wardrobe of the show is amazing. I plan to dedicate a separate post to it.

MLS1

The Absolute Beginner’s Guide to Capybara/RSpec

Sometimes the biggest challenge of using a new tool is not the syntax (there are always many examples for that) but getting set up. This is especially true and sometimes challenging for Rails, which is a convention-over-configuration kind of framework.

The situation

I need to write functional (aka integration or end-to-end) tests for a one-page app that relies entirely on AJAX to interact with a REST API.

Picking the tool

At the beginning I considered Cucumber. But I started seeing a lot of documentation for using Capybara in conjunction with RSpec, which I’m somewhat familiar with. It’s said to have an [intuitive API](http://rubydoc.info/github/jnicklas/capybara) and uses an easy to understand DSL (domain-specific language). So I decided on using Capybara/RSpec.

Running into problems

It was rather challenging to figure out how to configure the two gems and where to put the tests inside the ‘/spec’ folder. After about 2 hours and running ‘rspec’ unsuccessfully 30 times, I narrowed down the *key* steps in setting up Capybara test framework in a Rails app:

1. Gemfile

group :development, :test do
  gem 'rspec-rails'
  gem 'capybara'
end

2. spec/spec_helper.rb

require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rails'
require 'capybara/rspec'
require 'capybara/dsl'

The first two lines are automatically generated when you do ‘rails g rspec:install’. However, you need to require the capybara pieces manually.

3. Config the gems in spec/spec_helper.rb

Apparently selenium is the default driver for Capybara but I set it explicitly to be safe (actually I was trying everything I could get my hands on).
Capybara.default_driver = :selenium

You also need to include Capybara::DSL module so you can use phrases like ‘visit ‘/’ ‘, ‘fill_in’, ‘click_button’ in the tests.
RSpec.configure do |config|
  config.include Capybara::DSL
end

4. Where to put spec files

For RSpec, tests go under ‘spec/lib’. However, with Capybara, I have seen tests being put both under ‘spec/features’ and ‘spec/integration’. I went with the latter: ‘spec/integration/name_spec.rb’

5. Require spec_helper

At the top of each of your test file, put ‘require ‘spec_helper’ ‘

6. Test syntax

According to documentation I have come across, you can write tests either with RSpec or Capybara conventions:

describe 'log in process' do
  it 'lets user log in' do
   # Test goes in here
  end
end

I went with the Capybara way:
feature 'log in process', :js => true do
  scenario 'lets user log in' do
    # Test goes in here
  end
end

`:js => true` is supposed to help you switch to the Capybara.javascript_driver (instead of the selenium default). However, my app ended needing to use selenium web driver.

7. Capybara DSL syntax

feature 'log in process', :js => true do
  scenario 'lets user log in' do
    visit '/sessions/new'
    fill_in 'Email', :with => 'user@example.com'
    fill_in 'Password', :with => 'password'
    click_button 'Sign in'
    expect(page).to have_content 'Success'
  end
end

8. Capybara selectors

For ‘click_link’ you can select the element by id or text. But for ‘click_button’ or ‘fill_in’, you have to select by the button value or input placeholder value.
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click_on('Link Text') # clicks on either links or buttons
click_on('Button Value')

You can also find element by its id or html tag:
find_field('First Name').value
find_link('Hello').visible?
find_button('Send').click
find("#overlay").find("h1").click

9. Web driver!

Last but not least, after I set up everything else correctly and was able to run rspec without getting `undefined method` error for Capybara, my terminal told me I was missing this gem:
gem 'selenium-webdriver'

Success

As promised, when you successfully execute Capybara, the test will open up a browser and fill out username and password in the field you told it to and decide whether it fails or succeeds.

This blog post barely touches the surface of testing with Capybara. But getting to this point was a great accomplishment for me, and writing the rest promises to be easier with the help of documentation.

My day hacking Google QPX Express airfare API

qpx express When my classmate and I previously attempted to use the Google Feed API for our group project, I have realized that Google documentation is not great for “beginners,” in our case inexperienced developers. It seems to be simple in theory, make a HTTP post request to this url ('https://www.googleapis.com/qpxExpress/v1/trips/search') with json in the request body. But the learning curve is high and here are the struggles I’ve gone through:

1. API key setup: I think this is worth mentioning because the page to do this isn’t straight forward. Googling “Google developers console” will take you to the page where you can enable the API you’re trying to use and obtain a key for it.

3. Ruby wrapper: My mentor suggested that I could use Google’s Ruby wrapper for the API so I can make the request server-side. I was able to find documentation on how to create the API client (which is common to all of Google’s APIs). BUT there is one line of documentation specific to QPX, and I couldn’t figure out how to specify the request body so I gave up.

3. 403 “Access not configured”: I put my API key in the header as instructed but was getting this error. It was a combination of 2 things. I solved my problem but didn’t know which fix did it.
+ Initially I had specified under allowed IP the IP address of my apartment’s internet access but I was working from another one. This post suggests that you have to register your v6 and not v4 IP. I don’t even know what that is so I just leave it blank as one post recommends to allow requests from any IP.

+ Still getting the error. I had to restart my rails server and it changed to a 400 status code.

3. 400 “Bad request”: I was fumbling for a while because I didn’t know how to investigate what went wrong. Luckily going under the Network tab (Chrome developer console)
Parse Error. This API does not support parsing form-encoded input

With the help of this stackoverflow thread, I set contentType: 'application/json' in my ajax request.

4. 200 with empty response body: for a while I got a 200 status with nothing in the response body. Even more unhelpful than the two previous errors. I don’t know why this went through, but I started hitting the API and encountered 400 again.

5. 400 “Parse error”: This error is similar to the third one but I figured the cause was different because of the different message. It was a bit vague and difficult to search for but I finally found this thread that nails the problem in the head. My json was not really json but a javascript object, very close but not really. I had to simply use JSON.stringify(object) to turn it into valid json. The reason I was so slow to figure out this issue (nearly 1 hour) is because a) I’ve mainly used the opposite method, JSON.parse to read response body and rarely done a post request with such a big request body; b) I’ve mostly made ajax requests to my own Rails server, which accepts an object with no problem.

The “victory” wasn’t that great but it was really, really worthwhile to get back the response object in the console since I’ve spent all day hacking this API with basically no help. I guess I helped myself to Google and Stackoverflow.

qpx-response

From Fashion to Tech

The past three months has changed my life drastically. I decided to abandon my uninspiring marketing job to come to the Web Development Immersive boot camp at General Assembly. I knew the course was going to be challenging but I had no idea how and how much it would change me until it happened.

I will not lose my interest in fashion and design but I’ve developed a new obsession in the name of coding. Every day, every hour, learning, coding, terminal commanding, deploying, trouble shooting, debugging…. Lots and lots of debugging.

I wouldn’t say the course has made me “smarter”, though it did equip me with a lot of knowledge. The most important aspect of this experience is that it helped me fulfill my Potential, something I have always had. Since this is still a fashion blog, I’m posting link to my first-ever web application that I built with Ruby on Rails:

 Note to self: Heroku restart will reveal a lot of errors otherwise hidden.

H&M bustier, H&M peplum top, H&M knit sweater

Black is the New Black: H&M Haul

H&M bustier, H&M peplum top, H&M knit sweater

H&M peplum top $34.95 – H&M low-cut bustier $24.95 – H&M knit sweater $24.95

“You know you’re a New Yorker when you need a flashlight to see what’s in your closet” – Dress Monsta.

I admit that since two years ago, I could never get enough black clothes. Everything, from dresses, skirts, blouses to pants, tights and booties, just look better in black to me. Anyway I ventured to H&M the other day to spend my $50 Christmas gift card.

I hadn’t been to H&M for two months (Foursquare told me), which is like 6 months in fashion year. Either this store near Bryant Park has really good stuff or H&M has improved the quality of their clothing. And there wasn’t a huge tourist crowd like usual. Jackpot!!

I found three pieces that must be leftover from previous weeks’ stock. In my size! So style. Much fortune. Wow.

I’ve been on a search for sexy crop tops I can wear in the club. Honestly I have a clubbing uniform, an outfit that consists of skinny pants/tights and a crop top, usually all black in different material. The reason I stick with this is because I feel comfortable and can show off my asset (thin waist). Bodycon dresses, while look good on me, are often too short and rise up when I try to dance or even walk.

1. The peplum crepe top in size 2 is a but snug but it will do. In the back it has three hooks and the peplum part is open. It is quite girly and flirty. I will need high-waist pants to go with it, although you can also style it with high-waist pencil skirt.

2. The bustier I got is actually all black, not pinstriped, and had double straps. Size 4 is pretty snug on me, which MUST be vanity sizing because I am barely a size 4 in tops. To clarify, this top is extremely LOW-CUT. It is even more revealing on me that on the model, and I have AA cups. Hmm, anyone larger than a B cup shouldn’t attempt to wear this in public.

3. This sweater is a coarser, loose knit that has almost of a sheer effect when layered over something else. I got a similar oversize sweater of the same material in burgundy (unfortunately it became fitted after being thrown into the dryer load) and loved it. So naturally I have to get it in black. Size Small was a bit too long in the black, since this has a high-low hem, so I went for XS instead. This sweater can be paired with leggings and easily layered over tank tops or blouses.

This was quite a successful, stress-free shopping trip. Until next time, stay warm and wear black.