Trendy, minimal active leggings

You know what I love? Leggings. I retired most of my low-rise jeans two years ago. When high-waist jeans became trendy, I started stocking up on black leggings. Being lucky to work in offices with casual dress codes, I can wear leggings instead of pants. They look just as good with suede high-heeled booties and lace-up boots as they do high-top sneakers. Win win!

Recently I also became more active, doing pole, aerial silk and yoga. The last two require long, form-fitting pants, so I’d been obsessed with hunting for the perfect pair of trendy leggings that fit with my personal minimal style. What I truly hate most about shopping for yoga pants are all the crazy prints, tie-dye colors, and super busy patterns. Why?!?!? Thankfully I was able to narrow down to these two candidates:

leggings-onzie-mesh

Onzie Mesh Leggings

1. Onzie track mesh leggings

Mesh cut-out leggings suddenly became really hot this season. I see them a lot on the street and am inexplicably drawn to them. A few stores carry this style, but the cutouts aren’t always tasteful. This Onzie pair has a large sheer area but is also very streamline. Most importantly they look flattering.

2. Outdoor Voices colorblock leggings

One day I saw a yoga teacher at Sky Ting Yoga (Lower East Side) wear these amazing light grey colorblock pants, and immediately went online to search for them after class! I found a very similar pair online at Outdoor Voices, which turns out to be a boutique store in SoHo.

The funny thing is that I discovered later on that Outdoor Voices merchandise is sold at the studio. So I must’ve found the exact pair the instructor was wearing. This just goes to show that minimal is not always easy. It’s really hard to find a store that offers a design similar to this right now. I’m waiting for the pants to get back in stock so I can splurge on them!

htgawm3

Disappointing How to Get Away with Murder season 2 finale

htgawmWords cannot describe how sensational season 1 was to me. It was sexy, refreshing and just the right amount of shocking, episode after episode. But everyone knows, what goes up must come down. In season 2, the show started showing signs of losing momentum.

In order to get away with murder, there has got to be even more murders. Even though we know they can’t get away with it, the show has to go on with a more and more complicated web of victims, killers, lies and deceit.

I think the worst part about season 2 is that it doesn’t wrap up the main murder case like season 1 did. We still don’t know how exactly the Hapstall parents died, as we found out who killed Lila, even though the latest evidence pointed to a shady liaison between Catherine and Philip. Are the producers afraid they would run out of ideas for the next season and thus try to keep this plot under wrap?

Below are the high and low moments from season 2:

htgawm3.jpgHighs:
– Frank and Laurel getting together – steamy!
– Bonnie’s abusive past, what she’s capable of doing and her bonding with Asher over tragedy.
– Nate’s wife’s death and his coming back to Analise.
– Catherine’s and Caleb’s incestuous kiss.

Lows (and things that just don’t make sense):
– Wes being pushed to sidelines this season. The best part was the season premiere, where it was ominously implied that he shot Analise. Thankfully we’re going to find out more about him next season, as the very final flashback of the season hinted at the circumstance of his mother’s death.

– Asher’s involvement in the Trotter Lake incident. Being a covered up case that was used against him and his father by DA Sinclair, it turned out to be serious but still unclear whether Asher took part in raping the girl at all.

– Caleb’s romantic interest. Apparently he and Catherine have been in love growing up, yet suddenly started hooking up and having feelings for Michaela? They’re gorgeous together but the setup doesn’t make a lot of sense.

– The involvement Philip Jessup. The character was brought in mid-season and is a cliched socially awkward cyber geek type. It’s a typical red herring to make you think the weird guy did it, but his character and back story (if at all) has been poorly exploited.

– Blaming Sinclair’s murder and Analise’s gun shot on Catherine. The motive behind killing Sinclair is super dubious and the injury doesn’t even match her cause of death. Furthermore, Frank drugged and dropped the girl unconscious in the middle of the woods with no blood or DNA on her from the supposed victims. I just don’t see how this is going to work.

So what’s going to happen next season? I hope the pace picks up again, truly.

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. Sign into Google developers console, click on the project/app => APIs and Auth => Credentials => Click on the Credentials tab. Here you can add and remove API keys.

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