Skip to content

Instantly share code, notes, and snippets.

@dvessel
dvessel / r-em-sizing.scss
Last active October 30, 2018 09:59
font-size in rem and a tool for absolute to em conversion. http://css-tricks.com/snippets/css/less-mixin-for-rem-font-sizing/
// 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
@ProLoser
ProLoser / alerts.html
Last active October 9, 2019 18:38
AngularJS Bootstrap implemented without any additional code
<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>
@rsliter
rsliter / gist:4196841
Created December 3, 2012 18:18
Closures in Ruby
# 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
@worker8
worker8 / how they work.rb
Created October 16, 2012 06:57
how they work
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
@Jauny
Jauny / gist:3869758
Created October 11, 2012 02:13
Hash#sort

#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

@shereefb
shereefb / gist:3862388
Created October 10, 2012 00:25
Scopes breakout
class Cookie
MAX_CHIPS = 100
end
class PeanutButterCookie < Cookie
MAX_CHIPS = 100000
end
my_pbc = PeanutButterCookie.new
@kix
kix / cap.rb
Created October 5, 2012 08:04
Capistrano cheat sheet
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

Testing the speed of different RPN Calculator approaches

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
@jules27
jules27 / ruby_end_keyword.md
Last active October 13, 2021 14:46
Using the "end" keyword in Ruby

Introduction

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