Skip to content

Instantly share code, notes, and snippets.

@phil303
phil303 / How A Plane Wing Works.md
Created January 10, 2012 02:47
Hungry Academy Extended Response

How A Plane Wing Works

In fluid dynamics, there's this principle called Bernoulli's principle. Basically, it states that the pressure a fluid exerts on a body is inversely proportional to its velocity. In other words, as velocity goes up, pressure goes down.

Now, switch gears for a moment and imagine a wide, slow moving river that suddenly and quickly narrows. What happens? The water moves faster right? This is the same concept being applied to a plane wing. Think of a wing cross-section. It’s kind of flat on the bottom, and it grows fat on the top. This expansion on top juts into the air stream and effectively narrows it.

Here's the neat part. The air on top of the wing is now moving faster than on the bottom. With knowledge of Bernoulli's principle under our belt, we know that the pressure drops when the air speeds up. There’s now a different pressure on the top of the wing than what’s on the bottom, and we've just created the pressure difference we call lift! Using some

@phil303
phil303 / gist:2695858
Created May 14, 2012 19:24
amend-line with Pry
[1] (pry) main: 0> def good_star_wars_lines
[1] (pry) main: 0* puts "something, something, something, dark slide"
[1] (pry) main: 0* puts "something, something, something, complete" # Crap! I typo'd dark side.
[1] (pry) main: 0* show-input
# 1: def good_star_wars_lines
# 2: puts "something, something, something, dark slide"
# 3: puts "something, something, something, complete"
[1] (pry) main: 0* amend-line 2 puts "something, something, something, dark side"
[1] (pry) main: 0* end
# => nil
@phil303
phil303 / gist:2707150
Created May 16, 2012 03:41
edit command in multi-line expression
[3] (pry) main: 0> def one_ring
[3] (pry) main: 0* puts "to rule them all!"
[3] (pry) main: 0* edit
# your editor picks up right here and shows your method thus far
[3] (pry) main: 0* end
# => nil
@phil303
phil303 / gist:2707156
Created May 16, 2012 03:41
edit afterwards
[3] (pry) main: 0> def homer_says
[3] (pry) main: 0* puts "Do'h!"
[3] (pry) main: 0* end
# => nil
[4] (pry) main: 0> edit
# your editor shows the contents of your previous input buffer
@phil303
phil303 / gist:2707261
Created May 16, 2012 04:01
edit-method
# using our earlier homer_says method
[10] (pry) main: 0> edit-method homer_says
# into our editor of choice! Where we change "Do'h!" to something else.
[11] (pry) main: 0> homer_says
# Stupid Flanders
# => nil
@phil303
phil303 / gist:2713341
Created May 16, 2012 19:38
cd into context
[15] (pry) main: 0> cd Pry
[16] (pry) main / Pry: 1> ls
# Pry lists out every public method or instance variable defined on the current object, which is a ton.
# Let's add a switch to clean up our results
[17] (pry) main / Pry: 1> ls -m
# Pry gives us only the public methods. We can clean it up better still with grep flag.
[18] (pry) main / Pry: 1> ls -m --grep ^co
# => Pry.methods: color color= commands commands= config config=
[19] (pry) main / Pry: 1> cd ..
[20] (pry) main: 0>
@phil303
phil303 / gist:2713463
Created May 16, 2012 19:57
find-method
[22] (pry) main: 0> find-method homer
# => Object
# => Object#homer_says
[23] (pry) main: 0> find-method -c "Flanders"
# => Object
# => Object#homer_says puts "Stupid Flanders"
@phil303
phil303 / gist:2721042
Created May 17, 2012 19:13
gist a method
# gist a method (-m switch) homer_says and make it public (-p switch)
[24] (pry) main: 0> gist -m homer_says -p
# => Gist created at https://gist.github.com/2721042 and added to clipboard.
class Array
def new_count
count = 0
(1..self.length).each do |i|
count += 1 if yield(self[i-1])
end
count
end
end
gem 'oauth'
require 'rest_client'
require 'oauth'
require 'oauth/consumer'
# Instantiate consumer object
@consumer = OAuth::Consumer.new("mRoMvGuFliGOvCQTjSowLrEFjw8K5BbVp120jzsgRUG2D6y0Lq",
"ajRmJ4oWcyj9SusWAEIQLN6S400AqVgukUTEMhfvzZC7jljiA8",
site: "http://www.tumblr.com")