Tuesday, December 31, 2013

Using virtualenvwrapper

Going to start playing with virtualenvwrapper:

http://virtualenvwrapper.readthedocs.org/en/latest/index.html

Updating Python On Mac OS X

The Python that comes with OS X is a bit out of date, so I decided to update it.  After poking around the internet for a while, I came across some pretty good docs:


Basically, I ran:

$ brew install python

I got Python along with Pip and Distribute, which is awesome.  I heard both pieces of software helps you with installing and uninstalling other Python packages.

I then installed virtualenv, a handy dev tool that allows me to create virtual Python environments that do not interfere with each other.

$ pip install virtualenv

In order to see the new version of Python in action, I had to open a new terminal window.  Everything looks good.  My only complaint is that the version of Python I have now installed is 2.7.5 instead of 2.7.6, so it is a step behind the latest and greatest version.  I am going to have to investigate if this is a serious issue or not.  I heard 2.7.6 did fix some bugs in 2.7.5, but the user might have to install an updated version of Tcl/Tk to get IDLE working.

Thursday, December 26, 2013

DataSquid Screen Grabs

I have always been interested in data visualization, so for my final project I decided to explore D3.js.  After taking a bike ride on Venice Beach, I came up with the following name.



DataSquid allows a user to upload a JSON file that describes relationships with between various nodes.  DataSquid then uses D3.js to generate a fun, interactive force directed graph that users can then modify.



Looking forward to playing with D3.js and other data visualization tools some more!  Paper.js looks cool (http://paperjs.org/).

Saturday, December 14, 2013

Used JSFiddle For The First Time!

Created my first public fiddle on JSFiddle:

http://jsfiddle.net/cspears2002/vVL99/

A pretty useful tool.  I am using it to post my code on StackOverflow, so users can help me get to the bottom of the issue I have been having with implementing a fisheye distortion on the force directed graph.  For some reason, the nodes are distorting before the links.

Thursday, December 5, 2013

Stubbing Out A User For Your Rspec Test

How to stub out a user when testing a controller with rspec:

# for controllers
user = User.create(:name => 'user@example.com', :password => 'caplin')
ApplicationController.stub(:current_user).and_return(user)

Refactoring Rspec/Capybara tests (with a little help from FactoryGirl)

"We will encourage you to develop the three great virtues of a programmer: laziness, impatience, and hubris." - Larry Wall

I am writing a web app using BDD.  In order to do just about anything in my app, the user needs to log in, so I was encouraged to write a function that will sign the user every time a rspec test is run.  Basically, the code for the features test will end up looking like this:

DataSquid/spec/features/user_logs_in_spec.rb

require 'spec_helper'

feature "signing in" do
  before :each do
    @user = User.create(:name => 'user@example.com', :password => 'caplin')
  end

  scenario "user who logs in with correct credentials" do
    sign_in(@user)
    expect(page).to have_content 'Hi user@example.com'
  end
end


Unfortunately, the author did not point out that they used FactoryGirl to work.  In your Gemfile, add FactoryGirl:

# For testing
group :test, :development do
  gem 'rspec-rails'
  gem 'guard-rspec'
  gem 'capybara'
  gem 'selenium-webdriver'
  gem 'database_cleaner'
  gem "factory_girl_rails", "~> 4.0"
end

After running 'bundle install', you should be good to go.  I then made this file, which holds the sign_in function.

DataSquid/spec/support/features/session_helpers.rb

module Features
  module SessionHelpers

    def sign_in(user=nil)
      user ||= FactoryGirl.create(:user)
      visit '/authentications/new'
      fill_in 'Login', with: user.name
      fill_in 'Password', with:  user.password
      click_button 'Sign in'
    end

  end
end

From what I can tell, the code in the file below makes the code in the session_helpers.rb file available to all of the feature tests.

DataSquid/spec/support/features.rb

RSpec.configure do |config|
  config.include Features::SessionHelpers, type: :feature
end

Now I have a handy function I can call in my feature tests!  Here is the link to my conversation on Stack Overflow about this issue: http://stackoverflow.com/questions/20390072/trouble-with-refactoring-code-for-rspec-feature-tests-in-rails-4.

Wednesday, November 27, 2013

Hear Here

Man, I'm tired, but my team and I made a GA WDI project we can proud of:

http://hear-here.herokuapp.com/

Crazy front end by Randy Lee.  I worked primarily on the back end.

Sunday, November 10, 2013

Wrapping up Project 2 and Beginning Group Project 3 11/10/13

I was not happy with Urban Ephemera turned out.  I was not able to finish styling the project, and the user experience was awkward.  All of these issues can be tracked back to lack of experience with Rails.  Basically, UE was my first rails project, and it shows.

I am excited about my third project, which will be a group project. Hear Here is iTunes for sounds!  Got the user authentication up and running, and I managed to get paperclip working which wasn't too hard.

Friday, October 25, 2013

Urban Ephemera 10/25/13

Got lots accomplished today.  I deployed the program to Heroku today.  The major complication was dealing with the fact that my background images were not showing up.  I fixed this with image-path:

background-image: url(image-path('IMG_0003.png'));

Users can now make Stores.  The pages used to generate new Users and Stores are fully stylized with Bootstrap and raw CSS.  I now need Users to make Reviews that are owned by both Users and Stores.

I am using Thin for my web server instead of Webrick.  Thin is more robust in a production environment.

Christophers-MacBook-Pro:urban_ephemera christopherspears$ rails s
=> Booting Thin
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server

Added this to my Gemfile:

group :production do
  gem 'rails_12factor'
  gem 'thin'
end

The gem 'rails_12factor' should fix most of the asset pipeline issues.

Changed the command used to launch my web process by creating Procfile:

web: bundle exec thin start -p $PORT -e $RACK_ENV

Thursday, October 24, 2013

Urban Ephemera 10/24/13

Finally got the login working.  When the program launches, the user sees the authentication page because it has been set to root.  If the user does not exist in the db, I use a redirect to push the user to the page used to create new users.  After a new user is entered, I use the redirect to send the user back to root.  Along the way, I use the params function to pass the username value around so the username text field is autofilled.

Removing Turbolinks from your Ruby on Rails project

I was having major issues implementing a login in Ruby on Rails.  I ended up removing Turbolinks from my project:

In the Gemfile:

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
# gem 'turbolinks'

I then went into app/assets/javascripts/application.js and removed it there.

Apparently Turbolinks uses caching to speed up loading up webpages.

Tuesday, October 22, 2013

Testing on iPhone: xip.io

Might use this to test Urban Ephemera on my iPhone C: http://xip.io/

Monday, October 21, 2013

Urban Ephemera Oct 21, 2013

Added Store models, controllers, and views.  Modified the controllers and views on Users and Reviews, so no database entries can be made with the models for those classes.  Still have not figured out to create relationships between all of the classes.  Users should be able to make Stores and Reviews, and fields in Reviews should modify fields in Users and Stores.  Hopefully, we will get into this later in the week.

Sunday, October 20, 2013

Starting Urban Ephemera

I'm going to start recording my work on my second WDI project!  Really excited to start my first Ruby on Rails app.

Name: Urban Ephemera
This app will allow the user to locate and review indie bookstores and record stores. The data points will come from users. In the future, the app can be expanded to include coffehouses, art house movie theaters, used clothing stores, etc.
Features (in order of implementation): 
1. Log in and password verification 
2. Drop down menu that filters results 
3. Type in your location and bring up map with stores. 
4. Type in a store name and bring up map with store's location. 
5. Click on a store's marker once and get a little box with the store's name, speciality, and rating. 
6. Dbl click on a store's marker and get a page with a store's name, rating (incuding number of reviews), contact info, store speciality, and photo. Underneath this info will be a list of reviews. 
7. Click on the Review button on the first page and bring up a form where the user can type in a store's name, contact info, speciality, and review of the store. The user can upload a photo as well.

Here is what I have accomplished today.

Front End:

Downloaded, optimized, and resized photos.  Worked on the mockup for the index page.  Been testing the page on the iOS simulator.  Might want to add a header to the page.

To do:

  • mockups of other pages (map, page of reviews of a store, submit review page)
  • figure out how to test my web app using my iPhone C
  • maybe resize to 320?  Right now the index page is bigger than the iPhone screen.
Back End:

Started implementing models, controllers, and views for the User and Review classes.

To do:
  • Implement models, controllers, and views for the Store class.
  • Figure out how to set the number_reviews field in User by looking at the number of reviews that user created.

Friday, October 18, 2013

After a morning of learning how Ruby works with MongoDB, I was really glad to do 30 minutes of yoga.  Started coughing out clean LA air.

Monday, October 14, 2013

Kind of surprised at how creative some of these tic tac toe project are!  Gonna have to bring my 'A' game!

Saturday, October 12, 2013

Completed my first General Assembly Project!  Wrote a tic tac toe game to be played by two players on two devices.  The game was written in HTML, CSS, and Javascript and used the Angular JS framework with Angular Fire providing the backend.  Looking forward to Ruby and Rails next week!

Friday, October 11, 2013

Wednesday, October 9, 2013

Started using Firebase with Angular today!  Check out http://angularfire.com/!

Friday, October 4, 2013






A diagram depicting routing in Angular JS!
Got the basic game play for my Tic Tac Toe game up and running.  This weekend I want to refactor my code and add an "about.html" page.  Time told me to check out newTic/app/scripts/app.js.  This will get me involved in routing with Angular.

Thursday, October 3, 2013

After programming for around 12 hours, I think I am starting to wrap my head around Angular.  Need a beer...

Tuesday, October 1, 2013

Learning AngularJS today!  This stuff is pretty cool!

Wednesday, September 25, 2013

Monday, September 23, 2013

First day of my Web Development Immersive at General Assembly!

Wednesday, September 18, 2013

Just got back from my orientation for General Assembly's Web Development Immersive.  Looks like a good group.  Really excited.  Going to take the rest of the week off and relax.
Orientation tonight for my web development bootcamp!

Saturday, September 14, 2013

Finally completed my General Assembly Prework!  Going to relax a little before the bootcamp starts up!

Wednesday, September 11, 2013

Orientation for the web development boot camp next week!

Thursday, August 22, 2013

General Assembly gave me 50 hours of homework before the class even starts!

Tuesday, August 13, 2013

Got accepted to General Assembly's Web Development Immersive!

Wednesday, July 31, 2013

Finding "Two Scoops of Django" goes over my head quite a bit.  Oh well.  I am learning by looking up what is talked about in the book in the docs.

Wednesday, July 17, 2013

Going through the Django tutorial a second time turned out to be a good idea.  I'm learning a lot.  Unfortunately, I'm learning by screwing up a lot.

Thursday, July 11, 2013

Managed to hook up a django app to a postgreSQL database!
Got MySQL (including MySQL workbench) installed on my computer.  So far I am really impressed with this!  Does PostgreSQL have something similar to the workbench?

Wednesday, July 10, 2013

Wednesday, June 26, 2013

Installing and setting up Git today!  Going to see what all the fuss is about!

Monday, June 24, 2013

Here is how I started the postgresql server:

& 'C:\Program Files\PostgreSQL\9.2\bin\pg_ctl.exe' 
 -D "C:\Users\Chris\Documents\postgresql" -l logfile start
  
server starting
 

Thursday, June 20, 2013

Had a big adventure getting postgreSQL working on my laptop today!

http://dba.stackexchange.com/questions/44928/trouble-creating-a-database-with-postgreql/44981#44981

Just for notes, here is how I stopped the server:

PS C:\Users\Chris\Documents\test> & 'C:\Program Files\PostgreSQL\9.2\bin\pg_ctl.exe' -D "C:\Users\Chris\Documents\postgr
esql" -l logfile stop
waiting for server to shut down.... done
server stopped

Wednesday, June 19, 2013

Installed virtualenv and PostgreSQL on my laptop.  Not sure if I will need them, but I guess it's good to know that I have them.

Tuesday, June 18, 2013

Sunday, June 16, 2013

Finished all the lessons in Learning Python the Hard Way that are needed for review.

Saturday, June 15, 2013

Learn Python The Hard Way.  Gone through 37/52 classes.

Thursday, June 13, 2013

Completed the packaging tutorial!
Okay, I had to move the 'polls' directory out of 'mysite' and into the 'django-polls' directory.  See what happens when you don't read the instructions!
Well this is frustrating.

C:\Users\Chris\Documents\django_dev\django-polls>python setup.py sdist
running sdist
running egg_info
creating django_polls.egg-info
writing django_polls.egg-info\PKG-INFO
writing top-level names to django_polls.egg-info\top_level.txt
writing dependency_links to django_polls.egg-info\dependency_links.txt
writing manifest file 'django_polls.egg-info\SOURCES.txt'
error: package directory 'polls' does not exist

Looks like this might be a solution:

https://code.djangoproject.com/ticket/16671#comment:32
Needed to install distribute before starting the next django tutorial:

Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Users\Chris>pip install distribute
Requirement already satisfied (use --upgrade to upgrade): distribute in c:\pytho
n27\lib\site-packages
Cleaning up...

The package 'distribute' allows one to easily download, build, install, upgrade, and uninstall Python packages.

Wednesday, June 12, 2013

Was going to do a few more tutorials before taking a stab at creating a web app on my own.  However, a job interview today has really excited me!  Perhaps I should accelerate the time table?

Monday, June 10, 2013

Just finished the Django tutorial.  Boggles my mind how little I know.

Sunday, June 9, 2013

Got a really weird error when I tried to setup a django test environment:

Type "help", "copyright", "credits" or "license" for more information.
>>> from django.test.utils import setup_test_environment
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\django\test\__init__.py", line 5, in <modu
le>
    from django.test.client import Client, RequestFactory
  File "C:\Python27\lib\site-packages\django\test\client.py", line 21, in <modul
e>
    from django.db import close_connection
  File "C:\Python27\lib\site-packages\django\db\__init__.py", line 11, in <modul
e>
    if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 53, in __ge
tattr__
    self._setup(name)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 46, in _set
up
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but se
ttings are not configured. You must either define the environment variable DJANG
O_SETTINGS_MODULE or call settings.configure() before accessing settings.

The issue is django does not know what you are working on.  This resolved it:

C:\Users\Chris\Documents\django_dev\mysite>python manage.py shell
Python 2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.test.utils import setup_test_environment
>>>

I guess that is a django interactive shell?
Started using Team Treehouse today to learn HTML and CSS.  Overall, my opinion is positive.  The site is fun and easy to use, and I enjoy the quizzes and code challenges that are used to drive the lectures home.

Friday, June 7, 2013

Went to the Los Angeles Tech Happy Hour and found some interesting training sites:

Code School
http://www.codeschool.com/

Team Tree House
http://teamtreehouse.com/

Wednesday, June 5, 2013

This looks like a promising way to learn Django:

Test-Driven Development with Python

I am really curious about how he uses Selenium to test the web app.  You can buy the book from O'Reilly or read it for free by clicking on the link.  Might be worth checking out...
This page is a good place to start learning Django:

https://docs.djangoproject.com/en/dev/intro/
Hi!

My name is Chris Spears, and for about eight years I have worked in the visual effects industry.  However, recent events in that industry have got me thinking about a career change, so now I am trying to learn web development focusing (but not limited to) on using python and Django.  I created this blog as a diary to chart my learning process.