Web Fu

Quest for Web Functionality

About Me

Ahoy smallfry!
My name is Wesley Carr. I am a 20 year-old Delaware native spending the summer of 2013 at General Assembly in NYC. The reason being: Web Development.
On this Octo-blog, I hope to display new techniques learned, struggles overcome and solutions found. Other than that, I will also post a fair amount of things I personally find exciting or entertaining… maybe even a personal post as well.
Thanks for routing by!!

recent public projects

Status updating…

found on

Making an App - Insta-Outside

- - posted in API, Gems, Projects, Rails, Ruby, WDI

Ah, Apps

It’s the end of week 4 and our assignment for the upcoming week is to complete and deploy our first application using Rails. We presented our ideas in class on Thursday, and I was so impressed. The entire class had a wide range of unique ideas from food-truck-tracking to making music even more enjoyable by turning it into a game. Honestly, it became even more evident how fortunate I am to be part of such an awesome group.

My own application will deal with a particular interest of mine, Instagram, a social photo-sharing app launched back in October of 2010. I started using the app myself about a year ago, and I’ve really enjoyed the feedback I get from the community at large.

The app will use both the Instagram API and possibly the google maps API. Essentially, what a user will do on the site is a search. It’s going to enable a user to search for photos which fit into the category of ‘nature’ in any desired area. For instance, the user wants to see the natural elements around Tibet. They will search ‘Tibet’ and the search will go over to Tibet itself and fix the window onto the country’s boundaries, then populate the map with images of nature (mountains, river, flowers, earth, etc).

Authentication

In order to retrieve data from the user and unlock the full features of the API, Instagram requires a client_id and an access_token. The way to pass this is to send the visitor to the authorization URL which prompts the user to authenticate the app. If granted access, the app’s URL will then return the authentication_token in the redirect URL which is then grabbed and we’re good to go. The URL looks like this:

1
https://api.instagram.com/oauth/authorize/?client_id='CLIENT-ID'&redirect_uri='REDIRECT-URI'&response_type=code

If succesfully authenticated, the URL will appear similarly to this:

1
http://your-redirect-uri#access_token=11290717.f59def8.b3f3141e22b14e1da08a0c9313cc6c4d

I can tell it’s going to be a really enjoyable project after looking at the API. I’ve always been interested in utilizing another application’s interface to my own customization, it’s just been too intimidating not having the knowledge or expertise to actually do it any justice. Also, I’m really looking forward to sharing the process and the end result with a class such as my own at General Assembly… and possibly others.

Updates and walkthroughs to come!

Running Rails

- - posted in App, Homework, Rails, WDI

Our homework assignment for last night [7.8.2013] was to make our first Rails app. The requirements were basically to make a To-Do application using Ruby, Rails and Active record.

I had to leave earlier during class (had to withdraw my rent, like the adult that I am), but I was relatively comfortable with the commands to get a Rails app up-and-running.

The App ‘story’:

  • Create Todo
  • View all Todos
  • Link all pages
  • Edit & Delete Todos

Tools:

  • Ruby
  • Active Record
  • **Rails**
    • Model
    • Views
    • *Routes*
      • rake db:migrate
      • config/routes.rb
      • rake routes

Got Git

- -

Quick post here. After trying for hours to customize some third party themes to this Octopress, I’d made a mess out of my source files. So I went into the terminal and typed Rake-T to see if there was any quick way about removing old files and clearing the sass cache. There was and it’s simple enough: rake clean. Running that command did exactly what I’d hope it would and I saw this lovely trash bin of sorts waiting to be removed from GitHub. Only I didn’t know how to remove the rubbish.

I tried git rm . (thought of the opposite of git add .) but rm . was attempting to remove hidden files. Not the right move. A quick search came up with- git rm $(git ls-files —deleted) and presto, they’re correctly taken from git hub. The command might be different from Windows users, but fortunately it worked for me and I’ll continue to use it after I clean out the sass cache.

Side note- My theme is broken right now, but I’ll have it fixed by tomorrow. I tried to install and customize FoxSlide but the customization is a bit over my head at the moment. So much sass…

Tweaking It

- - posted in Blog, Octopress,, Styling,

Not a long post here, but I wanted to note my progress on the layout & customization of this here Octopress dubbed: Web Fu. Obviously the title has changed (previously the captivating “My Octopress Blog”), but I’ve imported Google Fonts as well to add some custom spice to my life. Honestly though, as if the people at Gizoogle didn’t impress me enough… their font-directory over at Google Fonts is ridiculously good-looking.

A quick note and +1 to Google is their release of Google Flights. It rivals the international app Skyscanner and provides a clean interface when selecting cheaper air-fare. It looks as though Google’s acquisition of ITASoftware back in 2010 has finally paid off. Here’s a link to the Matrix database ITA created http://matrix.itasoftware.com

Anyways, I’m looking to style this theme a bit more before next week once my class dives into the Rails framework. So in the meantime, I’m going to browse through some themes and of course… stay on the path towards enightenment with Ruby Koans

Active Record

- - posted in API, Active Record, Gem, WDI

Week 3 Day 5

Over the past two days we were assigned a homework project involving the Sunlight API Gem. Sunlight provides various methods for obtaining information on members of congress, legislator IDs, and ‘look-ups’ between places and the politicians that represent them. The project involved the latter search method. By providing the user with a search form, a zipcode is entered and then routed to (using Sinatra). Here is an example of the search method we used to GET the politicians from Sunlight and present them on another page:

1
2
3
4
5
6
get '/:zipcode' do
  @zipcode = params[:zipcode]
  #Defining instance variable with Sunlight app
  @politicians = Sunlight::Legislator.all_in_zipcode(@zipcode)
  erb :politicians_in_zipcode
end

From that page (erb :politicians_in_zipcode) we were encouraged to add the ability to favorite or like certain politicians and then list them back on the index page where the search form exists. In addition to a like button, each poltician’s party is identified by their parties color.

Democrat = Blue | Republican = Red | Independent = Purple

1
2
3
4
5
6
7
8
9
10
  <%color = '#9A2EFE'%>
      <% if party == "D" %>
        <% color = '#2E64FE' %>
      <% elsif party == "R" %>
        <% color = '#FE2E2E' %>

    <% end %>

    <h3 style = "color: <%=color%>">
    <%=person.firstname%> <%=person.lastname%>

An example from my home zipcode yields only members of the Democratic party. So, in order to display the working color code I used 11209, an area code assigned to Brooklyn, NY. The highest difficulty I experienced in building this app was adding selected politicians to a “liked” list (essentially passing them into the ActiveRecord Database) while retaining the information provided by Sunlight. For accessiblity purposes, the form entry for liking a politician requires the press of a button. Here is the form I made:

1
2
3
4
  <form action = '/like' method = 'post'>
    <input type = "hidden" name = "votesmart_id" value="<%= person.votesmart_id%>">
      <button> Like </button>
  </form>

What occurs when the user presses the Like button, is a transfer of the value :person.votesmart_id (unique ID assigned to politicians) to the POST method in main.rb-

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  post '/like' do
    liked = Sunlight::Legislator.all_where(:votesmart_id => params[:votesmart_id]).first

    Politicians.create(
                    :firstname => liked.firstname,
                    :lastname => liked.lastname,
                    :party => liked.party,
                    :state => liked.state,
                    :twitter_id => liked.twitter_id,
                    :in_office => liked.in_office,
                    :votesmart_id => liked.votesmart_id
                    )
  redirect to('/')
  end

This calls for a minor adjustment to the index page in order to display all the ‘liked’ politicians. By writing @politicians = Politicians.all the liked politicians will be listed below the search form. The code displayed above was relatively challenging for me. I was constantly running into a Postgres error (database error) which could not find a politicians class. Although I am still unsure why it occured, it was explained to me that the error resided in my migration file. When creating a new entry into my “:politician” table ‘create_table :politician do |t|’, ActiveRecord was looking for a :politicians table. Meaning it should have been plural all along. I hope to learn why the table must be plural, but either way it’s obviously crucial to be hyper-aware of the syntax when creating a migration file. As of right now, the app is up and running.

Index Screenshot:

GitHub link- Here

Octopressing

- - posted in Test

After a couple (meaning 3) tries to launch my Octopress blog, I’ve risen, triumphant. The first tasks I’ve set for myself regarding this blog, is to add my own interface options instead of using the default theme. I feel comfortable enough with basic CSS elements to use an alternative template and then tweak / prune the style to something similar of my own.

But with all the work and new techniques we learn in class I’m sure (if I manage my time well enough) I’ll be able to fully customize and optimize what comes through my blog posts as well as how it’s received, visually.

!Test Post!