Seeing your static project from your phone

Understanding how your application looks on mobile is a easy just fallow these steps.

First run in your command line:

ifconfig

and the ip address will be under the line:

en0:

as 

inet

One you have your ip address run:

python -m SimpleHTTPServer

then with the ip address type this into your phone’s browser:

YOUR.IP.ADDRESS.WITH.DOTS:THE PORT

ex 172.33.49.1:8000

Screen Shot 2015-07-25 at 8.20.16 PM

Running a Simple Script in Ruby

Hi Everyone!

So I recently had to write a script in Ruby at my job to scrape a webpage for information when I realized… Wait how do you run a ruby script? I was so use to using Rails Server command to run my programs in Rails and had no idea how to do this in a non rails/ Sinatra setting. So to do this of course after you have made your script with a “touch ‘your script name'”.

When you want to run you Ruby script you’d enter the command

ruby -r "./your_script_name.rb" -e "YourClassName.your_method_name 'any parameters in your method'"

So what is going on here when you run the code is your telling the terminal to use ruby then the “-r” tell the terminal to run this program that is followed by the file name which needs the correct location in your computer; in this case the file and location would be:

"./your_script_name.rb"

The “-e” tells the program to go into the the ruby file then run the class method in this case the class would be

"YourClassName"

And the method name would be (with any addional params. If the method has no params just don't include anything after the method call)

your_method_name 'any parameters in your method'"

I hope this would clear up the mystery in running your own simple scripts.

I made a App… again!

So I have been working on this really cool idea for a app ever since Tim Holman came to speak to my class. I created a working prototype of my App. What the App does is gets the user latitude and longitude using the geolocator gem.

Screen Shot 2015-06-03 at 3.17.01 PM

After the app has your latitude and longitude it can now use the forecast io api to get the weather from where the user is based on the lat and long.

Screen Shot 2015-06-03 at 3.24.12 PM

This information is in a JSON that the application can now parse for all the goodies needed to give . With those goodies the app can find a relevant picture for a hash that I created with urls of images related to that weather and make a call to the gify api to find a nice gif to boot.

Screen Shot 2015-06-03 at 3.27.59 PM

Then on the rendered html the background is sent to the back and the gify is embedded in day’s description using Tim’s Giflinks.

Screen Shot 2015-06-03 at 11.01.39 AM

Writing a Wrapper for Wyoutube… I mean Youtube

I the first rails application my team create Anime Chase. One of the coolest features the ability we had in the application was the ability to view Youtube videos that correlates with the anime on the show page.

AnimeChase Show Screen

Unfortunately, the gem we used for to grab the Youtube videos, YoutubeIt, stopped working. I had a choice either just let this cool feature die in our application or try to get the Youtube feature working again. In this journey, I found another person in the class that wanted to work on using the Youtube in their application, so we decided to work together on the getting those videos working. We figured the best way to solve both of our problem was to create a Ruby wrapper.

Broken Anime Chase

This is the Ruby wrapper that my classmate and I wrote to get Youtube videos. I will go over each method set by set:

Screen Shot 2015-05-14 at 4.29.30 PM

First, we created a reader for youtube and client that we will set in the initialize method:

Screen Shot 2015-05-14 at 4.29.59 PM

In the initialize method we created set the instance of client to a new Google::API call in which we pass in our authorization key that we from the google then we set set authorization set to nil and finally the API call takes in application name pointing to the name of your app (the one that you named to get your api keys).

The instance of youtube is the discovered_api method on the new client instance with the parameters of ‘youtube’ and the version currently it is ‘v3’:

Screen Shot 2015-05-14 at 4.30.16 PM

We then created a search method that took in a query then creates a hash that puts the query in the q value. We then preset the other options in the hash run execute. The part value in the hash needs to be set to snippet to generate videos. MaxResults is set the amount of video results you would like:

Screen Shot 2015-05-14 at 4.30.40 PM

After we have the parsed json we can just send the video id and render the embedded youtube video on the show page.

Screen Shot 2015-05-14 at 4.32.28 PM

The next set is to create my very first ruby wrapper that just handles searching youtube because I found that is is really hard to get a gem that just simply searches youtube.

Resources:

https://developers.google.com/youtube/v3/

Using Send Like a Boss

I would like to talk about how I solved the Email guesser lab using the send method.

Here is a small synapsis of the assignment:

EmailGuesser

So for this lab we had to dynamically guess users emails based on the pattern of other users emails with their same domain.

so what I did first was with the JSON of the the possible patterns that a user can have I created a new hash with all possible

emails based on the person’s name after I split the domain and name pattern.

Screen Shot 2015-05-01 at 12.37.35 PM

Then I wrote a method for each possible change for the email:

Screen Shot 2015-05-01 at 12.18.20 PM

Afterwords I took the name and domain passed in and based on the matching number in the hash I saved it to a variable.

I then made created an empty array to store the possible name results.

Then I used the send method to pass in the matching number pattern based on the domain key of the hash and turn that into a method used the send method.

What the send method does is basically sends my message to an object or ancestor until a method matches. In my program, found the possible with number that matched than called that method.

after that I iterated through the transformed name and put the actual domain on the end of the transformed name. Then I just presented that.

Screen Shot 2015-05-01 at 12.18.31 PM

How to make take the $$$ out of Expensive calls in Rails

I have been working tireless on my rails project Bucketlistr and I would like to show one cool trick to make rails applications less expensive when you’re calling on objects that are related to other objects. so normally we would call something like “Todo.first.comments.users” to grab the users from the todos comments. This normally would be an expensive query because we are going through the ActiveRecord Database once for the first todo then usually in a second database query to find the first todo’s comments then users from those comments. What this call does is grabs everything at the same time to quit multiply redundant queries.

So how I like to think of it is like a lazy person shopping at the grocery store. They have a list but it is unordered the the person goes through the list grabbing one item at a time in the order of the list. even if a item is right next to one-another. What using something like “Todo.first.comments.users” does is making that lazy person in the shopping list grab all the items the person needs in the same isle. then going to another instead of going a shopping list that would require the person to go into the same isle to grab different items in the same isle.

Resources:

http://guides.rubyonrails.org/active_record_querying.html

Git yo Stuff on Heroku

So I just deployed my first rails project Anime Chase on Heroku and I still am a surprised at how easy it was but I see many have yet to put their awesome projects on Heroku. I decided to write this post to understand the progress a little better of posting apps to heroku and to help my fellow, fellows in the journey of showing off what they worked so hard on last week.

So getting your stuff on Heroku is broken into about 6 steps and it feel very simliar to using git.

1. Sign up for a free Heroku account.

this step is very easy just go to https://www.heroku.com/ and follow the step in signing up for a free account.

Featured image

2. Create your Heroku app

to do this while in app simply enter on the terminal:

heroku create

Screen Shot 2015-04-15 at 8.07.21 PM

this creates your app as a heroku app putting the heroku.

mines looked like this:

heroku create animechase

This is also what your git config file should look like:

Screen Shot 2015-04-15 at 8.38.25 PM

3. Edit the gemfile if need be. This includes add your more lines if you are using the gem sqlite.

Screen Shot 2015-04-15 at 8.07.38 PM

4. Apply the changes if you edited your gem file in any way with typing this into your terminal:

bundle install --without production

Screen Shot 2015-04-15 at 8.08.05 PM

5. Do all of your migrations, rake tasks, git commit and push to heroku master

git push heroku master

♥ heroku run rake db:migrate

Screen Shot 2015-04-15 at 8.06.55 PM

figaro heroku:set -e production

6. Visit your sit by just typing this into the terminal:

heroku open

Things to note:

If you’d like to edit the app on heroku this is the process:

Screen Shot 2015-04-15 at 8.08.19 PM

If you have a free account be careful of going over the database limits at this moment you can only have 10K rows in your database. I personally had to scale down Anime Chase in order to keep it running on heroku.

understand and inform the api key providers, if need be, of where your app is hosted. I know things like facebook’s oauth would not work if you stated your app lived on localhost:3000 but you are making calls on the heroku domain name.

so if you would like more information on the subject matter read these lovely resources below

resources:

http://docs.railsbridge.org/intro-to-rails/deploying_to_heroku

https://github.com/laserlemon/figaro

https://devcenter.heroku.com/articles/getting-started-with-ruby#introduction

Rails Project Day 1: The Birth of Anime Hunt

Featured image

So at Flatiron today we started working on our first week long project in Rails. I was very nervous at the beginning about about the project because we learned rails for maybe two weeks then dove right into the projects. I understand programming and rails, but creating a idea from scratch from methods and arrays; thats still crazy to me!

However, doing my own idea for the project made me feel a lot better about the situation. We are doing a Anime Search program which will search for animes by titles and genres. I always felt as though I was missing out one cool animes that I have not heard of, so I wanted to create a project that would give me recommendations based on genres of anime I would like.

We first modeled the program on how things should flow and work. We learned that the model anime should hold the title description and should have many genres and the genre model should belong to a anime to search by in the future.

FullSizeRender (2)

The first problem we faced in the project was finding a way to gain all of the anime titles with such dated api’s on the inter-webs. Most anime app.s only render xml format to parse. However, after a long search we found a api that is relatively good and renders JSON. We found the Hummingbird api to search animes for our hunt app. Hummingbird takes all of the data from a searched anime on presents them in a readable json format.  This can then be keyed into to create the anime in the database.

# this is the method that all the magic happens

def create

# search_input is the input that the user enters into the search box. the info is than downcased to
@search_input = params[“anime”][“title”].gsub(” “, “-“).downcase

#responce calls on the Unirest which creates a get request to hummingbird version 1 api in which we put the user’s input at the end
@response = Unirest.get “https://hummingbirdv1.p.mashape.com/anime/#{@search_input}”,
headers:{

# this gives the ENV api keys that we needed to sign up for in order to use the hummingbird api
“X-Mashape-Key” => ENV[“HUMM_API_KEY”],

this creates the form as json
“Accept” => “application/json”
}

so then we created a conditional statement that stops if the search turned up a 404 page not found. If the info is found we create a anime in the database then render the show page which shows the page after.
unless @response.headers[:status] == “404 Not Found”
@anime = Anime.create(title: @response.body[“title”],
description: @response.body[“synopsis”],
score: @response.body[“community_rating”],
img_url: @response.body[“cover_image”])
#next i would like to build the genres through the anime here to give them that belongs to table relationship.
render “show”
end

that is it for now until next time the three people that read my blog.

Playing around with Unity 3D… No wait trying to fix Unity

So I started my coding career in the hopes of making a game one day. In my countless search of finding resources to help me in this journey I found  internships that had many elements of game development, workshops that were really expensive but informative, and online game design courses. I found all of these resources very informative, but one of the elements I found the most consecutive beneficial to me was the online resources this is were I learned most of my game development and programming skills before The Flation School. I don’t normally talk about this as much as I would like but I am really appreciative of The Flatiron School for giving me the opportunity learn code because I would either need to have a lot of money to go to bootcamps for coding or had to have been a woman to learn how to code without going into debt in college.  However, because I did a ton of videos without the foundation of programming I had no idea what I was doing so I went back to the code I wrote for some particular games to understand what is going on now that I have a better understanding of coding.

logo (1) n3-1Z5OV_400x400

So this was still relatively difficult because most of my coding with game was in programming languages like C# and GameSalad which uses a cover language to make objective C easier. one of the methods I would like to go over in this blog because there are a ton that I programmed, but I wanted to show one of the coolest I learned and that would be the explode method in C#. This method is a destructive method that can chain on other behaviors. in this game I chose to spawn piece of the player with the explosion. which creates an effect of the player being blown to pieces. So I would like show a demo of this and talk about it alone with it.

However, in the process of trying to get my demo working for class I realized that there was a major problem with unity’s new editor it could not handle translating old projects. I will finish this blog post when I figure out more on the subject

Screen Shot 2015-04-01 at 12.48.26 AM