This is the app we made! Basically we finished it in two days which is a huge improvement from our previous rock paper scissors app. It's called ATX Hot Spots, and is a Yelp like app but you find restaurants on the map. We downloaded a database of all the restaurants in Austin and their addresses and converted that data into tables we could work with in PostgreSQL. We had three tables, placelist (<--), reviews, and users. You can sign up and sign in. If you sign up with an email address that is linked to Gravatar, your picture is automatically referenced and pops up (so you don't have to manually upload one!). Each user's data (username, password, and email) is saved into the database with the password encrypted for security. Once you sign in, a session ID is created and also saved into that database so that you don't have to log in every time you refresh the page. We used a map API (Open Street Map) and leaflet.js to drop the pins at the restaurants. We started out with data from all restaurants in Austin (19,000 rows in the DB) because we downloaded the info from health inspections. To get rid of duplicates (multiple inspections at the same restaurant), we simply combined psql and ruby code to iterate through and delete extra data with the same facility ID. We used the latitude and longitude coordinates of the places so that we could use it to drop the pins. You can click through the slideshow above to see how it works. Once you click on a pin, the restaurant name and a link to their reviews show up. That link will take you to all of the reviews of that restaurant in addition to showing how many stars each person gave. In the right hand form, you can write and rate a restaurant and it'll show up in the reviews!
0 Comments
What a busy week. We had so many different projects all at the same time but surprisingly I wasn't too stressed out. We built a task-manager app with just Ruby and learned how to modularize our code to keep the user interface and business logic separated. We also made a web app which was a simple tic-tac-toe game but I had the most trouble with that. Using CSS, HTML, javascript and jquery all in one application confuses me a lot, but it's pretty fun because you can see how the code that creates the game interacts with the presentation. We also got introduced to Sinatra which we'll dive into this upcoming week. For algorithms, we had to make a war app (like the card game) and loop through the game to figure out on average how many turns it takes for someone to completely win (get all 52 cards). This basically took all weekend because I started out writing the code in a complicated way and was too stubborn to start over from the beginning. Also, using RSPEC to write tests is super helpful but also a nightmare because I tend to change around stuff and break every passing test from the past... But after about 30 hours of me getting confused by my own code I finally got the play_game method to work! I made my computer play the game 10,000 times and the lowest amount of turns it took for one player to get all 52 cards was 52 times and the highest was 2076 times. Now all I have to do for tomorrow is refractor it and shorten the runtime.... Ready for another week!!!
It's crazy to think that our first week has already come to an end. Seriously, it went by so fast! But the weird thing is at the same time I feel like I already know the instructors and the people in my cohort really well. Today we finished up our sass project and I finished my web design for Yogate. It's super simple because all I had were the images put up on their facebook page and it doesn't look good but it was a good way to learn all of the CSS functions and how premade frameworks like bootstrap and foundation are made. For the backend stuff, we learned how to use RSPEC and stubbing for test-driven development. It really does save you so much time when you use RSPEC because you don't have to go into irb and make random instances of classes just to check if the methods are working. Also, the git commands are slowly coming together for me hahaha. This is how far I got on one of the ruby projects we started today. (vagrant, ruby file, then rspec file) A typical day this week kind of went like this:
-7AM : wake up, get ready, eat -8AM : start walking to MakerSquare! -9AM: classes on backend stuff (Ruby) and problems to work through -NOON : lunch time, I usually bring food and eat on the couches there or while I do work -1PM : Patrick teaches us algorithms and data structures :D -2PM : Clay teaches us frontend stuff basically worked on sass and web design using a framework -5PM : Class is over but people usually stick around for an hour -7PM : Get home. Shower, eat. -8PM : Go next door to the annex and have our nightly coding party. -9PM : Basically we all sit in a circle in the living room burried under our laptops (Sachin brings out his monitor HAHA) I'm either freaking out because my tests are failing or super happy that my methods worked (pretty bad mood swings!) -midnight : go back to my part of the house and bedtime Today was the second day of MakerSquare, and I feel like I've known everyone in my cohort for weeks already. It's probably because I'm with them for 8 hours a day during class and we all go home and code together until bedtime. Also, I'm loving it so far :) . There are about 20 people in my cohort and everyone is super friendly, very healthy, and all have a passion for coding. It's about 15 men and 4 women mostly around the age of 27. The instructors and staff are also amazing, they are very helpful and fun to be around. We made our library app yesterday and started some CSS and SASS today. This new shoestring project is pretty difficult for me, we're trying to recreate something similar to bootstrap. Even though my brain is pounding trying to absorb every thing that we are exposed to, surprisingly it's not torturous. It's actually pretty enjoyable!
Anyways, I was having trouble with the clearfix function so I found this reading online that refreshed my memory on floats and clear http://css-tricks.com/all-about-floats/ Because moodle might stop working for me soon, I'll keep note of some useful resources I used while auditing a computer science class at Colgate before it's too late.
These resources focus on Java but it really helped me understand overall concepts that are probably shared with all programming languages not just Java (like stack and heap, run time differences, etc.)
Also, in learning new concepts throughout the course I realized that always keeping track of the run times of each bit of code and constantly thinking of how to rewrite it in an effort to shorten the time was one of the most important factors in writing good code. Unfortunately, I thought this was the hardest part and requires a lot of practice. I found a great wikipedia article that lists all of the different types of time complexities in algorithms and detailed explanations of each which everyone should check out!! I'll make a VERY condensed summary though. Time complexity
Examples 1. constant time (O(1)) An algorithm is in constant time if the value of T(n) (max time) is not determined by the size of input. An example would be accessing a single element in an array because one operation is performed. 2. linear time (O(n)) An algorithm is in linear time if the size of the input determines the run time. The running time increases linearly with the size of input (but usually for very large inputs). In contrast to constant time, finding the minimal value in an unordered array is considered to be in linear time because we need to scan over each element in the array to determine the minimal value. If the array was ordered, it can be considered constant. 3. logarithmic time T(n)=O(log n) An algorithm is said to take logarithmic time if T(n) = O(log n). Because computers use the binary numeral system the base of the log is generally base 2 (log2 n) but in big-O notation it is usually discarded because the change in base number only changes the runtime by a constant multiplier. Logarithmic time algorithms are usually found in operations on binary trees or binary searches. An O(log n) algorithm is highly time efficient because the operations per instance required decrease with each instance. A simple example would be an algorithm that cuts a string in half. 4. polynomial time T(n) = O(nk) for some constant k An algorithm is said to be polynomial if its running time is upper bounded by a polynomial expression in the size of the input. Examples of these algorithms are the quicksort and basic arithmetic operations. Today, I skyped with my prework coordinator Nick to go over my answers to the ruby assessment I took on Sunday. There were some useful methods that I completely forgot about but are very useful. I'm writing down the parts I got wrong for the future.
#1. Iterate through 'names' and return a new array with each name capitalized. names = ["nick", "mike", "shehzan", "gilbert"] my answer was to make a new empty array and use the .each method to iterate through each item in the array and push the capitalized version into the empty one but I could use a more simple approach by utilizing the .map method. names.map{|x| x.capitalize} ^ which will return the new array we want #2. Return the cast members of The Sopranos as a single string separated by commas. tv_shows = { "Mad Men" => {:network => "AMC", :cast => ["John Hamm", "John Slattery", "Elizabeth Olson"]}, "Dexter" => {:network => "Showtime", :cast => ["Michael C. Hall", "Jennifer Carpenter", "CS Lee"]}, "The Sopranos" => {:network => "HBO", :cast => ["James Gandolfini", "Michael Imperioli", "Edie Falco"]} } my answer was to first get inside the first hash and access the third key value pair and then access the value of the key :cast, then create an empty string and use the .each method again to go through each and recursively concatenate to the string but a simpler way is to use the .join method. tv_shows["The Sopranos"][:cast].join(",") ^it's basically the opposite of the .split method And review some object oriented programing stuff I don't know why but I always have trouble with github. It really should be the easiest part but I always mess up and get errors and plus I can't memorize the simple commands. So I finally took notes to refer back to when I get stuck again.
1. Go inside your file that you want to initialize 2. Git init 3. git add ~/code/mks/html_css/Eterna-using-foundation 4. git commit -m "Write whatever you want" 5. go to github and create a repository, set the repo name to something and create, then save the url 6. go back to terminal make sure you are in the file ( cd~/code/mks/html_css/Eterna-using-foundation) 7. git remote add origin "url" 8. git push -u origin master So one of the projects we have to do for the prework is to replicate the screenshot of a website from scratch. It's so interesting how much more you actually learn when you have no step-to-step guidance. This was the midpoint progress, I actually got it to look like the screenshot! Now the final stretch is to finish up some jQuery and Javascript :D Also, I recently get super excited talking to people if they mention start-ups and coding stuff. One person told me about a weekly ruby meet-up in Boston where people from the ruby community come together and either help each other out or just talk about entrepreneurship and how awesome ruby is. How cool is that! Another kid invited me to a hackathon this upcoming week and was telling me about how fun they are. He also showed me his blog which basically teaches you how to become a developer on your own (he's actually in finance and taught himself everything!) which seemed pretty helpful
I just used my first API on a webpage! This is pretty exciting since all of my app ideas require the use of APIs but I never really understood what they were exactly or how to integrate them. Using the goggle maps API was very simple, all I had to do was sign in with my google account and obtain an API key, select which mode I wanted (place, directions, search, or view) and type in the location. The iframe html tag was:
<iframe width="600" height="450" frameborder="0" src="https://www.google.com/maps/embed/v1/place?key=API_KEY &q=Space+Needle,Seattle+WA"> </iframe> in which we can change the bolded parts. Source: https://developers.google.com/maps/documentation/embed/guide Yesterday was graduation!!!! I can't believe I am actually an alum now. I moved out yesterday but it really hasn't hit me yet, it feels like I'm just leaving for the summer. The past 3 weeks were very hectic, because I had to finish my research and write my thesis (it's about genetics! Maybe I'll upload my abstract later because I'm pretty proud of it :D), study for and take my finals, drive to South Carolina for senior week, and graduate. I'll definitely miss all of my roommates and friends but it's exciting to start a whole new lifestyle.
Some notes from javascript that I thought I should take because the for-in loop used to confuse me... var nyc = { fullName: "New York City", mayor: "Bill de Blasio", population: 8000000, boroughs: 5 }; for (var property in nyc) { console.log(property); } ^this prints out all of the properties in the nyc object (fullName, mayor, population, boroughs) we can print out all of the values of the properties with for(var property in nyc) { console.log(nyc[property]); } Also, making a class : function Animal(name,numLegs){ this.name= name; this.numLegs= numLegs } And inheritance: |