Thursday, November 27, 2014
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Solution : Install : MySQL Server DMG Installer for Mac OS 10.9.4
An error occurred while installing libv8 (3.11.8.13), and Bundler cannot continue
I was getting that error on Mac 10.9.4. I had to update the gems :
gem 'libv8', '3.16.14.7'
gem 'therubyracer', '~> 0.12.0'
to fix this problem.
Reference : An error occurred while installing libv8 – Mavericks
gem 'libv8', '3.16.14.7'
gem 'therubyracer', '~> 0.12.0'
to fix this problem.
Reference : An error occurred while installing libv8 – Mavericks
Monday, November 24, 2014
Deploying a Rails App on Google App Engine
Deploying a Rails Webapp on GAE should be a piece of cake right? Due to lack of good documentation, it is not that easy. I had to dig around to find the versions of the software installed for Ruby Stack One-Click Deploy.
Here is some useful information to access installed software components.
Apache web server: Configuration directory: /etc/apache2 Default website directory: /var/www Command to start Apache web server: sudo service apache2 start Command to stop Apache web server: sudo service apache2 stop Passenger: Help command: passenger --help Install directory: /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.48 MySQL: Command to access MySQL: mysql -u root -p Command to start MySQL service: sudo service mysql start Command to stop MySQL service: sudo service mysql stop RVM, Ruby and Rails: RVM Help command: rvm Rails help command: rails -h RVM install directory: /usr/local/rvm Ruby install directory: /usr/local/rvm/src/ruby-2.1.1 Rails install directory: /usr/local/rvm/gems/ruby-2.1.1/gems/rails-4.1.4 Git: Help command: git --help
Saturday, November 22, 2014
bin/rails:6: warning: already initialized constant APP_PATH
I was getting this error in Rails 4.2 beta when I started the rails server. Solution: run : rake rails:update:bin from rails project directory.
Tuesday, November 18, 2014
Friday, November 14, 2014
Stripe API Capybara Test Failures
I was getting Stripe::InvalidRequestError: You must supply either a card or a customer id error. To fix this, make sure js is true in your integration test like this:
feature 'Guest Checkout' do
scenario 'Complete purchase of one product', js: true do
visit products_show_path
click_link 'Buy Now'
fill_in "Card Number", with: '4242424242424242'
page.select '10', from: "card_month"
page.select '2029', from: 'card_year'
click_button 'Buy Now'
expect(page).to have_content('Receipt')
end
end
feature 'Guest Checkout' do
scenario 'Complete purchase of one product', js: true do
visit products_show_path
click_link 'Buy Now'
fill_in "Card Number", with: '4242424242424242'
page.select '10', from: "card_month"
page.select '2029', from: 'card_year'
click_button 'Buy Now'
expect(page).to have_content('Receipt')
end
end
Thursday, November 13, 2014
Base Ball Player Statistics
Overview: For this scenario, we have been asked to write an application that will be used to provide information about baseball player statistics. Approach this problem as if it is an application going to production. We don't expect it to be perfect (no production code is), but we also don't want you to hack together a throw-away script. This should be representative of something that you would be comfortable releasing to a production environment. Also, spend whatever amount of time you think is reasonable. If you don't get all the requirements completed, that's ok. Just do the best you can with the time that you have available. You may use whatever gems, frameworks and tools that you think are appropriate, just provide any special setup instructions when you submit your solution.
Assumptions: All requests currently are based on data in the hitting file. Future requests of the system will require data from a pitching file as well. Consider this in the design.
Requirements: When the application is run, use the provided data and calculate the following results and write them to STDOUT.
1) Most improved batting average( hits / at-bats) from 2009 to 2010. Only include players with at least 200 at-bats.
2) Slugging percentage for all players on the Oakland A's (teamID = OAK) in 2007.
3) Who was the AL and NL triple crown winner for 2011 and 2012. If no one won the crown, output "(No winner)"
Formulas:
Batting average = hits / at-bats
Slugging percentage = ((Hits – doubles – triples – home runs) + (2 * doubles) + (3 * triples) + (4 * home runs)) / at-bats
Triple crown winner – The player that had the highest batting average AND the most home runs AND the most RBI in their league. It's unusual for someone to win this, but there was a winner in 2012. “Officially” the batting title (highest league batting average) is based on a minimum of 502 plate appearances. The provided dataset does not include plate appearances. It also does not include walks so plate appearances cannot be calculated. Instead, use a constraint of a minimum of 400 at-bats to determine those eligible for the league batting title.
Data: All the necessary data is available in the two csv files attached:
Batting-07-12.csv – Contains all the batting statistics from 2007-2012.
Column header key:
AB – at-bats
H – hits
2B – doubles
3B – triples
HR – home runs
RBI – runs batted in
Master-small.csv – Contains the demographic data for all baseball players in history through 2012.
Please note: We are looking for you to demonstrate you knowledge related to common software practices to include reusability, portability, and encapsulation – to name a few. Work submitted should be in project form and implemented as you were implementing any production solution.
Tuesday, November 11, 2014
How to share files between Virtual Box Ubuntu with Mac OS host computer
1. Create a folder in your Mac home directory, let's say ubuntu-sf.
2. Install guest additions. Click Devices -> Guest Additions and run the installer.
3. Reboot VM
4. Select the Ubuntu image on VM, go to Settings -> Shared Folders
5. Browse to the folder on your Mac you want to share (ubuntu-sf). Name the shared folder (ubuntu-sf)
6. On Ubuntu terminal, run : sudo adduser your-username vboxsf
7. On Ubuntu terminal run: sudo mount -t vboxsf ubuntu-sf /home/bparanj/ubuntu-sf
Here ubuntu-sf is the name of the shared folder we created in step 5. /home/bparanj/ubuntu-sf is the folder in the
Ubuntu.
References
How to share files between Virtual Box Ubuntu and host computer
How to automatically mount a folder and change ownership from root in virtualbox
2. Install guest additions. Click Devices -> Guest Additions and run the installer.
3. Reboot VM
4. Select the Ubuntu image on VM, go to Settings -> Shared Folders
5. Browse to the folder on your Mac you want to share (ubuntu-sf). Name the shared folder (ubuntu-sf)
6. On Ubuntu terminal, run : sudo adduser your-username vboxsf
7. On Ubuntu terminal run: sudo mount -t vboxsf ubuntu-sf /home/bparanj/ubuntu-sf
Here ubuntu-sf is the name of the shared folder we created in step 5. /home/bparanj/ubuntu-sf is the folder in the
Ubuntu.
References
How to share files between Virtual Box Ubuntu and host computer
How to automatically mount a folder and change ownership from root in virtualbox
some of the partitions you created are too small ubuntu 12.04 LTS Precise Pangolin
I was getting this error during installation of Ubuntu on Virtual Box. Solution: Increase the hard disk size from default 8GB to something higher. It worked for 45GB.
Tuesday, November 04, 2014
How to get web_console working in Rails 4.2.beta4 project
1. Add the gem to Gemfile.
group :development do
gem 'web-console', '2.0.0.beta3'
end
2. bundle
3. You can go to the web console by going to the URL : http://localhost:3000/console
You will also see the web console on the bottom of the browser. You can experiment with the Rails environment loaded.
4. You can add "<%= console %>" to any views and play with the web console.
If you restart the server. You need to reload the page to get a new active console session.
For more details : Web Console Ruby Gem
group :development do
gem 'web-console', '2.0.0.beta3'
end
2. bundle
3. You can go to the web console by going to the URL : http://localhost:3000/console
You will also see the web console on the bottom of the browser. You can experiment with the Rails environment loaded.
4. You can add "<%= console %>" to any views and play with the web console.
If you restart the server. You need to reload the page to get a new active console session.
For more details : Web Console Ruby Gem
Problem installing nokogiri on Mac OS 10.7.5
Problem: Make sure that `gem install nokogiri -v '1.6.3.1'` succeeds before bundling.
Solution: bundle config build.nokogiri --use-system-libraries
Then run : bundle
Then run : bundle
libv8 and therubyracer installation problems on Mac OS 10.7.5
The error message is : Make sure that `gem install libv8 -v '3.16.14.7'` succeeds before bundling.
Solution: gem install libv8 -v '3.16.14.7' -- --with-system-v8
Make sure that `gem install therubyracer -v '0.12.1'` succeeds before bundling.
Solution : Change the Gemfile to specify the libv8 version:
gem 'libv8', '3.11.8.13'
and run bundle
Subscribe to:
Posts (Atom)