| // Inspired by this post from CSS-Tricks. | |
| // http://css-tricks.com/snippets/css/less-mixin-for-rem-font-sizing/ | |
| // | |
| // Plays nice with compass/typography/vertical_rhythm | |
| // http://compass-style.org/reference/compass/typography/vertical_rhythm/ | |
| // | |
| // Calculates font size in `rem` (root em). | |
| // | |
| // Relative values depends on $base-font-size. Pixle value for font-size depends | |
| // on $legacy-support-for-ie6 or $legacy-support-for-ie7 or $legacy-support-for-ie8 |
| <h1>Alert</h1> | |
| <p>Bootstrap JS</p> | |
| <div class="alert fade in"> | |
| <button type="button" class="close" data-dismiss="alert">×</button> | |
| <strong>Holy guacamole!</strong> Best check yo self, you're not looking too good. | |
| </div> | |
| <p></p><a ng-click="alert=true">Open Alert (AngularJS)</a></p> | |
| <div class="alert fade" ng-class="{in:alert}"> | |
| <button type="button" class="close" ng-click="alert=false">×</button> |
| # Closures can be done in Ruby using both lambdas and procs. | |
| # Lambdas with closures: | |
| # A lambda can be declared so that it is created at runtime but evaluated only when it is called. | |
| class Person | |
| def initialize(age) | |
| @age = age | |
| end |
| def proc_return | |
| Proc.new { return "proc1"}.call | |
| return "proc2 I AM HERE!" | |
| end | |
| def lambda_return | |
| lambda { return "lambda1" }.call | |
| return "lambda2 I AM HERE!" | |
| end |
#Sorting a Hash I wanted to understand what happened under the hood when something like
hash.sort { |a, b| b[1] <=> a[1] }is called.
If you can't answer, you might want to read.
I'll be as basic as possible (I don't know much anyway...) so it should be understandable.
First let's begin by saying that we will be working on this hash
| class Cookie | |
| MAX_CHIPS = 100 | |
| end | |
| class PeanutButterCookie < Cookie | |
| MAX_CHIPS = 100000 | |
| end | |
| my_pbc = PeanutButterCookie.new |
| http://www.dizzy.co.uk/cheatsheets | |
| This work is licensed under the Creative Commons | |
| Attribution-NonCommercial-NoDerivs 2.0 License. To | |
| view a copy of this license, visit | |
| http://creativecommons.org/licenses/by-nc-nd/2.0/uk | |
| ########## Shell Commands ########## | |
| Installation: | |
| $ gem install capistrano |
The following table shows the speed results of six different approaches to creating a reverse polish notation calculator with Ruby. The code was written by five different incoming Dev Bootcamp students and one instructor.
| Approach | Time (ms) |
|---|---|
| First | 119.2 |
| Second | 295.6 |
| Third | 264.7 |
| Fourth | 274.3 |
After working through exercises for learning Ruby as part of preparation for the upcoming Dev Bootcamp (note: no longer exists), we had a friendly discussion about the exercise to implement a Reverse Polish notation calculator. At the end of discussion, one of the staff members, Jesse, posted his solution to students.
The solution is well-designed, clean, and easy to read. However, one line of code caught my eye:
tokenize(array).inject([]) do |stack, token|
<...>
end.pop