Going to start playing with virtualenvwrapper:
http://virtualenvwrapper.readthedocs.org/en/latest/index.html
Tuesday, December 31, 2013
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.
Looking forward to playing with D3.js and other data visualization tools some more! Paper.js looks cool (http://paperjs.org/).
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.
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)
# 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
First I read this article: http://robots.thoughtbot.com/rspec-integration-tests-with-capybara
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.
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.
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
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.
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
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.
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:
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
Monday, October 14, 2013
Saturday, October 12, 2013
Wednesday, October 9, 2013
Friday, October 4, 2013
Thursday, October 3, 2013
Wednesday, September 18, 2013
Saturday, September 14, 2013
Thursday, August 22, 2013
Wednesday, July 31, 2013
Wednesday, July 17, 2013
Thursday, July 11, 2013
Wednesday, June 26, 2013
Monday, June 24, 2013
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
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
Sunday, June 16, 2013
Thursday, June 13, 2013
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
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.
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
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?
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?
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/
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...
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...
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.
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.
Subscribe to:
Posts (Atom)