This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/time' | |
require 'active_support/testing/time_helpers' | |
require 'rspec/expectations' | |
include ActiveSupport::Testing::TimeHelpers | |
include RSpec::Matchers | |
class Person < Struct.new(:birthday) | |
def age | |
Date.today.year - birthday.year | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# After reading this comment | |
# http://avdi.org/devblog/2010/08/02/using-and-and-or-in-ruby/#comment-1098 , | |
# | |
# I became aware of a cool idiom for Ruby. | |
# | |
# I've seen this in a lot of cases: | |
if (variable = expression_or_method(options)) | |
variable.calculate_something | |
do_other_stuff(variable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
$(document).ready(function(){ | |
$.stratus({ | |
links: 'http://soundcloud.com/foofighters/sets/wasting-light' | |
}); | |
}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.bended-shadow {position:relative} | |
.bended-shadow::before, .bended-shadow::after { | |
content: ''; | |
position: absolute; | |
width: 60%; | |
height: 20px; | |
-webkit-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5); | |
-moz-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5); | |
-ms-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def collect(&block) | |
inject([]) { |memo, obj| memo << block.call(obj) } | |
end | |
def detect(&block) | |
inject(nil) { |memo, obj| memo ||= obj if block.call(obj) } | |
end | |
def reject(&block) | |
inject([]) { |memo, obj| block.call(obj) ? memo : memo << obj } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday_middleware' | |
require 'hashie/mash' | |
# Public: GeoIP service using freegeoip.net | |
# | |
# See https://github.com/fiorix/freegeoip#readme | |
# | |
# Examples | |
# | |
# res = GeoipService.new.call '173.194.64.19' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Subject: [ruby-dev: 46350] RubySpec maintainer | |
From: Yukihiro Matsumoto <matz ruby.or.jp> | |
Date: Fri, 2 Nov 2012 10:43:12 +0900 | |
Yukihiro Matsumoto is | |
Dis was've been on a grand scale and to Brian Ford at RubyConf. | |
It is not matter since it's always on it (truth is | |
Specification originally not good), so less contribution from Japan to RubySpec | |
Checking to what it is not, the distinction between behavior and specifications of chance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pics at https://twitter.com/josh_cheek/status/681062928980783104 | |
# Gif at https://twitter.com/josh_cheek/status/686465757476065280 | |
# Based on https://www.youtube.com/watch?v=QAja2jp1VjE | |
require 'chunky_png' | |
require 'matrix' | |
include Math | |
def white | |
ChunkyPNG::Color.rgb(255, 255, 255) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a=b=c=(1..100).each do |num| | |
print num, ?\r, | |
("Fizz" unless (a = !a) .. (a = !a)), | |
("Buzz" unless (b = !b) ... !((c = !c) .. (c = !c))), | |
?\n | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.border-container { | |
width: 28%; /* border will be on the left on this container */ | |
float: right; | |
overflow: hidden; /* only needed if floating container */ | |
min-height: 600px; /* static height if you want your container to be taller than its content */ | |
-moz-box-shadow: inset 15px 0 5px -16px rgba(0,0,0,.1), -1px 0 0 #FFF; | |
-webkit-box-shadow: inset 15px 0 5px -16px rgba(0,0,0,.1), -1px 0 0 #FFF; | |
box-shadow: inset 15px 0 5px -16px rgba(0,0,0,.1), -1px 0 0 #FFF; | |
border-width: 0 0 0 1px; | |
-webkit-border-image: |
OlderNewer