Truth
wallacepolsom
No title available
noise dept.
todays bird

tannertan36
hello vonnie
Xuebing Du
h
TVSTRANGERTHINGS
ojovivo
KIROKAZE
Stranger Things
Aqua Utopia|海の底で記憶を紡ぐ

blake kathryn

Andulka

❣ Chile in a Photography ❣
sheepfilms

#extradirty
Sweet Seals For You, Always
tumblr dot com
seen from United States

seen from Poland

seen from Malaysia

seen from Germany

seen from United States
seen from Netherlands

seen from United States

seen from Türkiye

seen from Malaysia
seen from United States

seen from China

seen from Malaysia

seen from Italy
seen from Germany

seen from Germany
seen from Brazil

seen from Malaysia

seen from Malaysia

seen from United States
seen from United States
@therealphillondon
Truth
Joan Didion in front of her Stingray, Hollywood, CA
In 1970, Julian Wasser photographed Joan Didion for the release of her new book, Play It As It Lays. The novel’s main character, Maria, is addicted to L.A. freeways, being sedated by their rhythms and currents, not going anywhere, but driving with the radio at high volume. In her dreams, “the great signs soar overhead at 70 miles an hour, Normandie ¼ Vermont ¾ Harbor Fwy 1.” In Wasser’s photograph, Didion looks s
omewhat disdainful, standing in front of her white Corvette, smoking her cigarette. Her terse writing style, and car, correspond to Maria and her driving obsession, “So that she would not have to stop for food she kept a hard-boiled egg on the passenger seat of the Corvette.”
-Craig Krull Gallery @ Bergamot Station Arts Center
Please stop using 'posts' to Learn How to POST
This is mostly a post for DBC, post my DBC experience.
When learning how to submit a POST and GET request at Dev Bootcamp we were often asked to make some sort of blog type application with some of the following user stories:
Users can sign up, login, and logout
Users can submit a post
Users can edit their posts (CRUD)
Users can only edit their posts
Eventually, after making at least 10 CRUD apps that basically all did 1-3 up there, I got pretty good at it. More importantly I also learned how to utilize POST and GET requests. Before I actually made the apps, friends had described what POST and GET both did. They would say something like, “Well a post submits information to the server and a get retrieves information from the server”. Which yeah, now makes perfect sense, but when learning it without doing it I was admittedly pretty lost.
Now, go back in time to before you learned about POST and GET requests. If you are reading this and you don’t know what a POST or GET request is, we’ll talk about it in a sec. But if you already get it, try and restate your brain to the same level as those for which the previous sentence applies.
Great! Now that we are all on the same page, let’s go back and take a look at our second user story. Users can submit a post. Let’s start off by stating what a post is in the context of the user. Let’s just say that a post is a block of text (255 characters lets say) that a user can write, read, update, and delete. Think of it like a tweet (the classic example). So as a web developer, all you have to do for your awesome app is have a form with an input text field and a submit button. Maybe your view looks something like this:
<form action=”/posts” method=”POST”> <input type=”text” name=”post[body]”> <input type=”submit” value=”Post!”> </form>
and your controller looks something like this:
require ‘sinatra’
get ‘/posts/new’ do erb :new end
post ‘/posts’ do @post = Post.new(params[:post]) end
My point is, there are so many 'posts' in even this simple example that it's hard to keep track of what's arbitrary and what's vital. When you’re learning something for the first time, your understanding is inconceivably small compared to whatever it is your trying to learn. So when you’re learning a new concept for the first time, you become hyper aware of everything, you don’t know what to filter out and what to pay close attention to, you give importance to everything because well, you don’t know any better. That’s why I think submitting a post when you’re first learning how to submit a POST request is a terrible idea. The two concepts get con fuddled and you feel totally lost.
When I was at DBC I gave this feedback to them. They were always great about listening to feedback and making changes, but I’ve just been thinking about that confusion a lot lately and thought it would be good to share this with everyone.
Thanks!
Functions vs. Methods in JavaScript
I've been spending a lot of time on the codecademy Q&A forum lately. I do this for a few reasons. First, it's nice to see how far I've come since I started my own programming adventure 9 months ago with codecademy. Secondly, it helps solidify everything I've learned from codecademy, Dev Bootcamp, and books like POODR, JavaScript The Good Parts, and High Performance JavaScript (just to name a few). Another reason I like to contribute answers is because it's great to get feedback on your answers. You really feel like that student is your student, and that you've actually helped someone and given back to this awesome community.
Now, let's talk some JavaScript. One of the forums I frequent the most is the JavaScript track, and the Object Oriented JavaScript section in particular. If you haven't completed the JavaScript track yet, go do it now! It's a great place to start if you want to brush up on your JavaScript, or even if you don't know the difference between Java and JavaScript.
One of the questions I've noticed students asking a lot is: What is the difference between a function and a method in JavaScript? Usually followed by "?" * 10 + "!" * 10 (ruby reference).
In JavaScript, a method is a function that is the property of an object. First, read that sentence five times. I've highlighted the main terms, now let's break them down piece by piece.
What is a function in JavaScript? Well you know what a function is. It's just an object that does something. Let's say hello. Put this in your console and call it with sayHi():
function sayHi() { console.log("Hello from Phil"); }
We just created a function that does one thing and does not take any arguments. All sayHi() can do is print out "Hello from Phil". Not a very helpful function, but a function nonetheless.
Now let's figure out what a property is. According to the W3C "Properties are the most important part of any JavaScript object." Sounds important!
So for example, if I, Phil, was a JavaScript object I'd probably be saved as var phil, I'd have a name of 'Phil London', I'd have an age of 23, and I'd have a favoriteColor of 'blue'. Let's see what that would look like. Put this in your console:
var phil = { name: 'Phil London', age: 23, favoriteColor: 'blue' }
As you can see, everything that I wrote above in bold (name, age, and favoriteColor) are all properties of phil, or, me as a JavaScript object.
Okay, that's great. "So what!", you're saying, I already know this, TEACH ME. Okay,well now comes the juicy stuff.
What if I wanted phil to be able to do something. How do we do things in JavaScript? We use functions. Remember? Let's say hi from Phil again:
var phil = { name: 'Phil London', age: 23, favoriteColor: 'blue', sayHi: function() { console.log('Hello from ' + this.name) } }
sayHi() is still a function, BUT now it's the property of an object. So we call it a method.
You can Read more about methods vs functions here:http://www.quora.com/JavaScript-programming-language/What-is-the-difference-between-a-method-and-a-function-in-JavaScript
And more about properties here:http://www.w3schools.com/js/js_properties.asp
Validating Votes in a Sinatra App
I've been working on an application for about a week now that I'm calling Delta. It's a Sinatra application that helps programmers learn a second, third, or fourth language. Basically, if you feel proficient in one language and you're trying to learn another it might help you visualize the change. User's can ask a question like "How do I write an each loop in JavaScript?" and other users can submit an answer. An answer consists of three parts: the solution in the original language (Ruby in this case), the delta change (in the form of a gif or other video screen capture), and the final solution. Ex. (http://thedelta.herokuapp.com/questions/5/answers)
Original:
Delta:
Final:
I'm using ActiveRecord and I was originally using three tables: Users, Questions, and Answers. Users have many questions and answers. A question has many answers. I decided early on that I wanted this to be a social application, and that users should be able to vote up or down an answer. So answers originally had a votes field that kept track of an answers vote count.
class CreateAnswersTable < ActiveRecord::Migration def change create_table :answers do |t| t.belongs_to :user t.belongs_to :question t.string :original_solution t.string :final_solution t.string :delta t.integer :votes, default: 0 t.timestamps end end end
This took care of voting as a basic functionality, however, I needed a way to validate voting. Obviously, this can't handle malicious users. At this point, nothing was stopping a user from voting up or down an answer to their hearts content. I was trying to think of the best way to do this without adding a votes table to the database. Eventually I decided on adding the table, but if their is another way to do this please drop me a line telling me how. First I remove the votes from the answers table:
class RemoveVotesFromAnswers < ActiveRecord::Migration def up remove_column :answers, :votes end def down add_column :answers, :votes, :default => 0 end end
Then I create a votes table:
class CreateVotesTable < ActiveRecord::Migration def change create_table :votes do |t| t.belongs_to :user t.belongs_to :answer end end end
Now that a vote belongs to a user and an answer I am able to tell answers that they have many users through votes using a has_many through relationship:
has_many :users, :through => :votes
Now for each answer I can check to see if that answer already has a vote from that user. If the user is included in answer.users, the vote count is not increased.
def up_vote(user) if !self.users.include?(user) self.votes << Vote.new(:user => user) end end def down_vote(user) if self.users.include?(user) self.users.delete(user) end end
Right now you can only vote down if you've voted up, like facebook, but I might change that down the road.
Sassy Stylin'
You don't realize how ugly your CSS is until you start working with SASS, or Syntactically Awesome StyleSheets. No matter how pretty or succinct your website may look on the outside, if you're using plain old CSS it probably looks pretty ugly on the inside. As my sites got more and more complex, I found it harder to keep my CSS organized. Everytime I take a break from my regular CSS code coming back to it is like reacquainting myself with a friend from middle school.
Here's some CSS without SASS:
header { height: 123px; position: fixed; left: 5%; width: 90%; background-color: #fffd00; -webkit-transition: 0.5s ease-in-out; z-index: 2; -webkit-box-shadow: 0px 3px 12px -5px #333; -moz-box-shadow: 0px 3px 12px -5px #333; box-shadow: 0px 3px 12px -5px #333; } header img { -webkit-transition: 0.5s ease-in-out; } header ul { text-align: left; position: relative; -webkit-perspective: 800px; } .panel { width: 10%; height: 70px; margin: 0% auto; text-align: center; font-size: 2em; position: relative; } .panel:hover .front { z-index: 1; -webkit-transform: rotateY(-180deg); -ms-transform: rotateY(-180deg); -moz-transform: rotateY(-180deg); transform: rotateY(-180deg); } .panel:hover .back { z-index: 2; -webkit-transform: rotateY(0deg); -ms-transform: rotateY(0deg); -moz-transform: rotateY(0deg); transform: rotateY(0deg); } .card { width: 100%; height: 100%; -o-transition: all .5s; -ms-transition: all .5s; -moz-transition: all .5s; -webkit-transition: all .5s; transition: all .5s; -webkit-backface-visibility: hidden; -ms-backface-visibility: hidden; -moz-backface-visibility: hidden; backface-visibility: hidden; position: absolute; top: 0px; left: 0px; }
Here's the same CSS using SASS with Bourbon mixins:
@import 'bourbon/bourbon'; $kinda-yellow: #fffd00; header { position: fixed; left: 5%; width: 90%; height: 123px; background-color: $kinda-yellow; z-index: 2; @include transition (0.5s ease-in-out); @include box-shadow (0px 3px 12px -5px #333); img { -webkit-transition: 0.5s ease-in-out; } ul { text-align: left; position: relative; @include perspective (800px); } } .panel { width: 10%; height: 70px; margin: 0% auto; text-align: center; font-size: 2em; position: relative; &:hover .front { z-index: 1; @include transform (rotateY(-180deg)); } &:hover .back { z-index: 2; @include transform (rotateY(0deg)); } } .card { position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; @include transition(all 0.5s); @include backface-visibility(hidden); }
We get a few new things with SASS that help us keep track of our code and help us stay organized. As you can see, we get stuff like variables, the ability to nest attributes inside other attributes and even the ability to do math in our stylesheets. All these features lead to overall cleaner and more readable code. Here are some good references for SASS to help you get started:
http://sass-lang.com/guide
http://alistapart.com/article/getting-started-with-sass
http://alistapart.com/article/dry-ing-out-your-sass-mixins
http://bourbon.io/
http://refills.bourbon.io/
On developing a Git workflow
Here is my gitworkflow:
create a new repo
clone the repo
create a new branch prefixed by either feature/, chore/, bug/
make your changes
add the changes to be committed
commit the changes
push to origin branchname
submit a pull request
tell a team member it is ready to be reviewed
I've been using git recently because I've been working on more open source and team projects. I had been using git before, and had gotten a good workflow down, but my competency was skewed by the fact that I had only been working on personal projects. Because of that, I didn't have to worry about merge conflicts, submitting pull requests, writing clear and descriptive commit messages, or checking out branches.
The first team project I worked on was a git disaster. The app was simple, a random tweet generator; each tweet would be generated based on the collection of a users previous tweets. With an MVC framework in mind, 6 of us split up into groups of 2 and worked on the model, views, and controllers. We started working in the morning and reconvened in the evening, without checking in during the day to collaborate. Nobody was committing regularly, which meant nobody was pushing regularly, which meant nobody was pulling regularly, which meant nobody was coding the same application.
By the time we had to merge all of our respective files there were so many conflicts we were lucky the app even worked.
Things are different now.
Now whenever I work on a team project or an open source project I stick to the designated work flow. If an open source project does not specify a flow I stick to the https://help.github.com/articles/using-pull-requests.
Quick bits:
Why is it not a good idea to push to master?
- If you push your changes to master in an open source or team project, it won't be immediately clear what bug/chore/feature you've been working on. It's always a better idea to be descriptive in your code as well as in your commits.
How often should I commit and when?
- Commit early and often is the phrase, but commit when you feel like you're at a good stopping point. This judgment obviously changes over time, but if you feel like pumping your fist, it's probably a good time commit.
How and why to submit a pull request?
- Because I had been so used to working on my own projects, where the only branch I had was master and nobody was checking my work, I didn't ever have to deal with submitting a pull request. When I started working on projects the need to have my work checked and check others work became more and more apparent.
What should I do if I've made changes to master on my local system?
- Not all hope is lost, just checkout a new branch, add and commit the changes and return to master, git will remember those changes in your new branch, and know that master doesn't have them.
The difference between creating an instance of a class in Ruby and an object in JS
I've been using Ruby almost exclusively for the past couple of months. I've written a bunch of console applications, sinatra web apps, and messed around pretty extensively with active record. Almost all of my applications have required setting up classes and those classes have all been used to render instances of themselves. I was just starting to get comfortable with Object Oriented Ruby, the concept of inheritance, and the usefulness of modules (read this http://www.amazon.com/Practical-Object-Oriented-Design-Ruby-Addison-Wesley/dp/0321721330)...then JavaScript came along. Everyone is always boasting about how elegant a language Ruby is, and how it's one of the best languages for beginners because it's syntax is so easy to pick up.
Before learning about Object Oriented Javascript I had learned how to manipulate the DOM, and written basic scripts to activate and deactivate my cool CSS3 animations, but I had been using jQuery almost exclusively. It's methods reminded me of a bulkier Ruby, but I quickly saw it's potential after creating this simple script for changing every image on a page to Miley Cyrus (load in console: $('img').attr('src', 'http://hvngrymag.com/wp-content/uploads/2014/03/Miley-Cyrus-Is-Singing-to-Who1.jpeg')). Coming from Ruby, OOJS can seem kind of daunting. Let me show what convinced me that it's not.
Let's create a Person class in Ruby:
class Person def initialize(first_name, last_name) @first_name = first_name @last_name = last_name end def say_hi "hello there" end end
Sweet. We've just created a class with a few instance variables and a say_hi method. Now whenever we create a new person for our application we can just write:
phil = Person.new(“Phil”, “London”) #=> #<Person:0x007f863b08e968 @first_name=”Phil”, @last_name=”London”&rt
Now that we have a phil, an instance of our Person class, we can try to figure out some information about it:
phil.first_name #=&t; undefined method `first_name' for #<Person:0x007f863b12a408&rt;
Actually, we can't even figure out phil's first_name. The only thing we can do at this point actually is call the say_hi method. Let's do that:
phil.say_hi #=> "hello there"
If we want to figure out the first_name and the last_name attributes of phil, or any of our other objects created from this class, we need to add attr_reader methods before the initialize method. We could also use the attr_accessor method, which would allow us to edit and read the first_name and last_name attributes.
class Person attr_reader :first_name, :last_name
Now we can call say_hi, first_name, and last_name on phil, and any of the other objects that we create in the future.
Let's see what this whole thing would look like in JavaScript:
var createPerson = function(firstName, lastName) { return { firstName: firstName, lastName: lastName, sayHi: function() { return “hello there”; } } }
We have just created a function that can create an object, which has the properties firstName, lastName, and sayHi. sayHi is a property and it is also a function, pretty cool! If we want to create phil again we just say:
var phil = createPerson(“Phil”, “London”) phil > { firstName: 'Phil', lastName: 'London', sayHi: [Function] }
We now have all the same functionality from our OOJS phil object that we do with our phil object that we created in Ruby. Our OOJS method createPerson is known as a factory method. We use factory methods when we know we'll be creating objects with the same interface, i.e, when we know each person will have a first and last name, and they'll be able to say hello!
Sudoku and Self Expression in Ruby
After the first week of DBC I am excited, but also drained. It is the most intense learning experience I've ever had, and it's so weird because no matter how many different people tell you that it doesn't sink in until your facedown on the keyboard and your eyes are bloodshot from staring at the same problem for 8 hours. There is nothing that can prepare you for DBC, except experience. If you're headed to DBC, or even thinking about applying, don't read Hartl's tutorial, or start by learning whatever you can about Big O, because it won't matter unless you can express yourself in Ruby. The most powerful tool when it comes to writing Ruby programs is your ability to eloquently express yourself using Ruby's syntax. Learn how to traverse nested arrays, start to think about things between levels. A good program is 2d, and a great Ruby program is 3d. What separates the good programmers from the great programmers are those that can think about things in terms of space and time, not just, well, this program runs and adds and subtracts and returns, I'm done. Learn to read Ruby documentation, spend some time going through the docs everyday and trying out each function you find interesting. Figure out how it works and look forward to using it, even if it seems esoteric and unnecessary, there is a solid chance that if it's implemented in the language someone, somewhere has found it to be useful, you just don't see it yet. When you see it, it is totally beautiful and awesome.
The best part of Week 1 at DBC is Sudoku, I had never played before but I seriously enjoyed figuring out how the game worked, how my brain solved the game, and then how I could translate the solution into some bits and pieces of code so that the computer could figure it out instead of me. The trick for my pair and I was that each coordinate that is not filled in with a number can only have a certain number of possible values based on the other coordinates in its row, column, and box.
I'm starting to understand how to translate pseudocode from text books and algo websites into Ruby. Today I implemented binary search and bubble sort in 20 minutes. On Tuesday it took me almost 8hrs +. I got stuck working my way through merge sort, even with pseudocode it's still difficult for me to wrap my head around. I understand it conceptually, and this is what I mean by expressing yourself in Ruby. I'm sure there is some very elegant solution to merge sort in Ruby, and I would love to come up with it. I'm going to keep trying until I get it, and then refactor until it's really nice. The more you refactor the more everything starts to make sense, and the closer you get to the edge, the more you realize where something fits on the spectrum of CS.
The End of Phase 0
This is my story about how I started learning to program. It's about following creative sparks, immersing yourself once you've found your passion, and finding people with similar passions to hang out with and learn from.
8 months ago I was working as a summer intern at an investment management company in New York. It was the summer before my senior year of college. I had no real marketable skills, I enjoyed studying economics, but I was about to graduate and I hadn't the slightest clue what I was about to do next. All I knew was that I could not see myself wearing a gray suit sitting at a gray desk in a gray office for the rest of my life.
While I was at work I spent a lot of time daydreaming. They didn't have many projects for us to work on so I spent my free time reading up on the GRE or the business headlines. One day I came across a story about McDonald's workers going on strike. They were demanding a wage increase from 7.50/hr to 15.00/hr. The story stood out to me because here were these people working their asses off everyday to feed themselves and their families and here I was sitting in a fancy gray office in my gray suit reading about it and getting paid what they were asking for. Life is bullshit.
I had to get back to work, but I remained curious about the McDonald's workers throughout the day. I wanted to know if they would get the wage increase they were demanding, or at least some type of increase. So I came up with an idea for an application that could follow a story and send updates to the follower when a significant story broke. It would be different than google alerts because users could see the progression of the story, instead of snippets from the day. It would be a way to contextualize the news. It seems simple now, but it was this tiny creative spark that changed my life.
At the internship I had befriended an intern from the software engineering section of the office. I was so excited about my new idea and I wanted to build it out myself. But I knew literally NOTHING about computer programming, application development, web development. It all seemed like one giant mystery at the time, bundled up into a ball of unknowing. I remember asking my friend if I needed to be a math genius to learn HTML/CSS. He looked at me and laughed (I've been working with HTML/CSS for the past 8 months now and have only had to use math one time, and it was using an experimental CSS3 feature, but it was basic arithmetic, not an advanced algorithm).
Immediately after work I went to the closest Barnes and Noble and bought Head First HTML/CSS. I told myself, if I really want to learn this and get good at it, I'll have to do at least one hour a day of exercises/studying. It's called the Jerry Seinfeld approach, because he spends at least one hour everyday writing jokes, and everyday he marks it down in his calendar. I had taken the same approach to running and working out, and my body was looking good so I figured it would work with HTML/CSS too. Eventually, one hour turned into two, and then three and then four and then all I wanted to do was study web development related things. I started bringing the huge textbook wherever I went, and stopped seeing friends. I immersed myself completely in it. I had found my passion. If I had only studied once a week, I wouldn't be here today saying I learned HTML/CSS, I'd be saying I tried to learn once, but it wasn't for me. If you find your passion, do it/practice it/make it for at least for one hour everyday. Get a calendar and mark down with a highlighter everyday that you worked on getting better at it, whatever it is. If you're not sure what your passion is, keep trying different things until you find it, it's out there somewhere.
8 months and many yellow highlighter marks later I'm a week away from starting Dev Bootcamp. When I found out about Dev Bootcamp I wasn't excited because of the graduation to job rates they advertised. I was excited because I had found a place where there were others interested in learning as much about web development and computer programming as I was. I can't wait to see where I will be 9 weeks from now and what I will learn from all my new friends and teachers at Dev Bootcamp.
Phase 0 Unit 3 Week 7 - How to Build a Cool Nav Bar with CSS3
I decided to switch things up and teach instead of preach. The following are instructions for building buttons that activate a webkit transition. First of we will need three buttons (and I'm building this for a Dev Bootcamp exercise about a Pizza restaurant so bear with me on the names). The first button will be for the FOOD menu, the second for DRINKS, and the third for the DESSERT.
HTML
<div id="nav-bar"> <ul> <li style="padding: 48px 28px;">Food</li> <li style="padding: 48px 20px;">Drinks</li> <li style="padding: 48px 11px;">Dessert</li> </ul> </div>
CSS
#nav-bar li { list-style: none; display: inline-block; margin: 30px; margin-left: -5px; padding: 56px; font-size: 2em; background-color: red; border-radius: 600px; }
#nav-bar li:hover { background-color: red; border-radius: 600px; color: white; cursor: pointer; }
Now that we have our buttons we need to add the food menu, the drink menu, and the dessert menu. I'll use http://veggieipsum.com/.
<div id="menu-description"> <div id="food" class="description"> <h1>FOOD</h1> <p> Turnip greens yarrow ricebean rutabaga endive cauliflower sea lettuce kohlrabi amaranth water spinach avocado daikon napa cabbage asparagus winter purslane kale. Celery potato scallion desert raisin horseradish spinach carrot soko. Lotus root water spinach fennel kombu maize bamboo shoot green bean swiss chard seakale pumpkin onion chickpea gram corn pea. Brussels sprout coriander water chestnut gourd swiss chard wakame kohlrabi beetroot carrot watercress. Corn amaranth salsify bunya nuts nori azuki bean chickweed potato bell pepper artichoke </p> </div> <div id="drinks" class="description"> <h1>DRINKS</h1> <p> Turnip greens yarrow ricebean rutabaga endive cauliflower sea lettuce kohlrabi amaranth water spinach avocado daikon napa cabbage asparagus winter purslane kale. Celery potato scallion desert raisin horseradish spinach carrot soko. Lotus root water spinach fennel kombu maize bamboo shoot green bean swiss chard seakale pumpkin onion chickpea gram corn pea. Brussels sprout coriander water chestnut gourd swiss chard wakame kohlrabi beetroot carrot watercress. Corn amaranth salsify bunya nuts nori azuki bean chickweed potato bell pepper artichoke </p> </div> <div id="dessert" class="description"> <h1>DESSERT</h1> <p> Turnip greens yarrow ricebean rutabaga endive cauliflower sea lettuce kohlrabi amaranth water spinach avocado daikon napa cabbage asparagus winter purslane kale. Celery potato scallion desert raisin horseradish spinach carrot soko. Lotus root water spinach fennel kombu maize bamboo shoot green bean swiss chard seakale pumpkin onion chickpea gram corn pea. Brussels sprout coriander water chestnut gourd swiss chard wakame kohlrabi beetroot carrot watercress. Corn amaranth salsify bunya nuts nori azuki bean chickweed potato bell pepper artichoke </p> </div> </div>
CSS
.description { position: absolute; text-align: left; top: 60px; width: 70%; left: 15%; z-index: -1;}
If you're following along you'll notice that the descriptions are right behind our three buttons. They're behind because we have set the description classes z-index to -1. To hide the class until we click on the option we want to view, set the opacity to 0.
.description { position: absolute; opacity: 0; text-align: left; top: 60px; width: 70%; left: 15%; z-index: -1;}
Now to show the menus we'll need to use a little jQuery. So basically we want to access the element we want to click a button and then find the menu that corresponds to that button. That is why above I gave distinct id tags to food, drink, and dessert.
JS
$('#nav-bar li:nth-child(1)').on("click", function(){ $('#food').toggleClass('active'); $('#drinks').removeClass('active'); $('#dessert').removeClass('active'); }); $('#nav-bar li:nth-child(2)').on("click", function(){ $('#drinks').toggleClass('active'); $('#food').removeClass('active'); $('#dessert').removeClass('active'); }); $('#nav-bar li:nth-child(3)').on("click", function(){ $('#dessert').toggleClass('active'); $('#food').removeClass('active'); $('#drinks').removeClass('active'); });
CSS
.description.active { top: 270px; opacity: 1; }
Here what we're saying is, when I click the first list item element (a.k.a the food button), find the element with an id of food and give it the class "active", when I click it again remove the class. The class active is setting the new position of the description to 270px from the top of the page, and changing the opacity from 0 to 1. Now if we just stick to this we're fine. The user will be able to see all the menus at once one each click. However, if we want to feel smoother and enrich the user experience (which we should) we can add a transition: all 0.5s ease-in-out; to our .description class. This will give a nice smooth effect to our users clicks.
2/18/2014 Phase 0 Start of Unit 3
So Week 3 is underway and I'm glad to say that it's dedicated to HTML/CSS. It's partly a relief and partly a let down. I've had so much fun drastically altering my mind with Ruby and now I want to keep challenging myself instead of going back and reviewing past and easy material. Looking at this HTML/CSS stuff now is like reviewing the ABC's. I guess it's necessary, but I'd much rather be accessing the dom and traversing it rather than setting it up. I guess you have to build the building before you can add indoor pools and twirly slides in all the homes.
Last week I definitely learned a good amount. Something I was really happy with was when I figured out was using & with map. I'm still not 100% clear on how this works, but it's pretty freaking cool:
When working with arrays you'll often find that you end up with numbers separated within an array and of the class String. Like so, ["1", "2", "3"] etc, etc. This is because when you want to split up a number like 123 you have to first change it to a string (123.to_s) and then split it (123.to_s.split("")). Because it's current class is string we can't really do anything mathematical to it that would be interesting. To change them all back to an integer you could use map with the block |x| x.to_i.
123.to_s.split("").map do |x|
x.to_i
end
which would leave you with [1, 2, 3]. Or you could do the much more elegant and simple: 123.to_s.split("").map(&:to_i) and get the same result! Very cool.
Here's a plan I wrote to myself a few days ago about solving difficult and seemingly "impossible" challenges: When stuck on a problem just trust that it will all work out. Continue going to yoga even when you don't feel like it. Try writing more pseudocode before each challenge and keep doing codewars for fun. Always be looking for more Ruby code to work on so you can master it.
2/12/2014 Phase 0 Unit 2 Week 6
Read in Search Inside Yourself that keeping a journal makes you smarter because it allows you to reflect on what you've learned throughout the day. Start with prompts like "What I am feeling now is...", or "What motivates me is...", or "Today I aspire to...". This book is great and always makes me feel like I've just come out of a yoga class when I stop reading it. I especially appreciate what he says about our feelings. In our culture we put too much emphasis on how we feel in the moment. We say "I am angry" or "I am anxious", when that is not who we ARE, it's just how we're feeling in the moment. Next time I get frustrated with myself I'm going to remember that.
Today I learned a really interesting and useful method called method_missing. It's so cool because it means that you don't have to always have a method handy in your class. When a method is called on an object and the object does not identify that method, it won't fail and say noMETHODERROR, it'll just perform the method within method_missing.
def method_missing(meth, args, &block)
end
In which the method you pass (foo.bar) , #{bar} can be used as a variable, as well as the arguments and the block! Very cool.
I need to remember that when creating new methods for an existing class. Like for a string or an array, it is important to use self to modify the new methods, because self is the current object with which we are calling our new methods.
2/11/2014 Phase 0 Unit 2 Week 6
Spent some time with the discrete math book today. The author went over the binary system in an interesting way. He compared it to measuring gold dust. Where the gold dust distributor has blocks of measurement. 1 unit can measure exactly 1 unit, 2 units can measure 2 but with the first unit they can both measure 3. This continues forever with the units doubling each time. 1 2 4 8 16 32 64 etc. Which is the same as 2^0 2^1 2^2 2^3 2^4 2^5 2^6. We can use this to convert binary to decimal because if there is 1 of each of this, i.e one of the 32unit and one of the 8unit and 0 of the rest, our total is 40.
I spent awhile on the car class challenge today because I was making it way more complicated than it was. I was speeding up the car, and thinking about bezier curves (http://en.wikipedia.org/wiki/B%C3%A9zier_curve) and adding user input features. I wore myself out during the process of coming up with something too complicated for the purpose of the exercise. Sometimes I think
I may be bing too hard on myself. There are times to be hard on oneself and times to just give yourself space and room to improve. I think that being hard on yourself is good, in fact, you should set goals and try your best to accomplish them, but when you get in the way and start to doubt yourself you deprive yourself of a chance to grow.
2/10/2014 Phase 0 Unit 3 Week 6
Excited to be doing so many cool things. Had a great pairing session the other day that involved sorting through a bunch of tables with sqlite3. I felt pretty comfortable considering I had never tackled an actual sql challenge before, only the basic select methods that SQLzoo offered. I don't really like SQL as much as Ruby, there isn't that a-ha moment that I get when I pick the Primary key and connect it with a foreign key, but I can definitely see why it's useful to know.
CSS3 is getting more and more interesting. I made this today with using keyframe animation (http://codepen.io/plondon/pen/ItaLv). I want to keep going down that rabbit hole, just not sure CSS3 is as marketable as JS, even though CSS3 is so much nicer and smoother. However, I need to learn JS so I can mess around with angular and node. I should get on that.
2/3/2014 Phase 0 Unit 2 Week 5
Started learning SQL (structured query language) today. Just got some of the basic syntax down. Best part I thought was the ability to play with the column names. Like gdp/population = gdp per capita. Stuff like that. I guess I've already tackled one of the goals for this week: "Write select statements to extract data from one or more fields on a single table". I feel like this is the next logical progression after working with arrays and hashes for the past 4 weeks.
So, a DB's info is stored in tables, which have rows and columns. Columns can be enforced by column specs (I don't know how to write these yet). And a row is a single instance of data in a table. Here is the SELECT Statement Syntax:
SELECT [All | Distinct] column1, column2, column*
FROM table1, table2, table*
WHERE conditions
GROUP BY column-list
ORDER BY column-list
where select* shows all columns in the given table. Many other syntax rules. They're pretty straightforward and will become second nature as time goes on.
Probably the most interesting thing I learned today had to do with CSS3 and Bezier curves. Basically if a curve has negative values like
transition: all 1s cubic-bezier(0.26, -0.315, .685, 1.390);
Then it will create a "push pull effect". It will bounce back, spring forward, and then bounce into a stop. So cool, here's a website for playing around with it: http://matthewlein.com/ceaser/. Linear vs. ease has to do with the rate at which the transition takes place. Linear means that the angle increases or decreases in direct proportion to the specified time. But ease means that it changes slowly in the first moments of the transition, reaches a terminal velocity and then slows down in the final moments for a more realistic transition.
2/3/2014 Phase 0 Unit 2 Week 5
Last week I got a lot of good stuff done on the Project STAY website. Utilizing jQuery and CSS3 there are some really nice and smooth transitions that happen. I think they're good features but I'm worried the client won't appreciate. One thing I did notice was that using jQuery to add a class is really helpful, and it let's the CSS do the dirty work, which it is really better at doing than the jQuery because it doesn't have to load another request. CSS is happening directly in the browser, at least, that is how I understand it for now.
Finally got an accordion list to work and then realized I could have been taking advantage of the .siblings method the whole time. I need to refactor my code to show that change.
In terms of DBC the week went well, was intimidated by the objectives for the week but I guess I am understanding more than I think because the exercises were very straightforward. By far the most challenging exercise of the week was the get_diagonal method. I finally figured it out by breaking every piece of it down and using an if statement for every possibility, which of course is probably a horrible way of doing it. I tried to figure out some type of conditional to satisfy at least 2 so I could cut the if's in half, but to no avail.
Getting started on SQL and looking forward to it, going to be very useful to understand at least the basics of the language.