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
# Present | |
"brain".present? | |
#=> true | |
"".present? | |
#=> false | |
#Hash#fetch | |
items = { :apples => 2, :oranges => 3 } |
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
class LowCoverReport < ActiveRecord::Base | |
# This seems to be working fine, but is it the "right" way to achieve this ? | |
@@country_query = lambda{|o| {:conditions => ["country_id IN (#{o.countries.collect{|c| c.id}.join(', ')})"]} } | |
named_scope :for_user, @@country_query | |
named_scope :for_session, @@country_query | |
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
# this only gets cached in @admin if true | |
# how to cache this also in case of false? | |
def admin? | |
@admin ||= has_role? 'admin' | |
end | |
#is the following ok? |
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
// source: http://shaneriley.tumblr.com/post/3462508768/a-sass-mixin-for-cross-browser-css-background-gradients | |
= gradient-bg($color1, $color2) | |
background-color: $color2 | |
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=#{$color1}, endColorstr=#{$color2}) | |
background-image: -moz-linear-gradient(center top, $color1, $color2) | |
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from($color1), to($color2)) | |
background-repeat: no-repeat | |
#container |
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
@mixin shadow($a, $b, $color) | |
-webkit-box-shadow: $a $a $b $color | |
-moz-box-shadow: $a $a $b $color | |
box-shadow: $a $a $b $color | |
@mixin rounding($rad) | |
-moz-border-radius: $rad /* FF1+ */ | |
-webkit-border-radius: $rad /* Saf3-4, iOS 1+, Android 1.5+ */ | |
border-radius: $rad |
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
// Creates a jQuery UI dialog on the fly, every time a link .user-link is clicked, | |
// dialog content will be loaded from the url specified by the clicked link | |
$(function(){ | |
$(".user-link").live('click', function(){ | |
var link = $(this); | |
$("<div><img src='" + BASEPATH + "images/small-spinner.gif' /> </div>") | |
.dialog({ | |
autoOpen: true, //for info, true is default | |
modal: true, |
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
# These are my notes from the PragProg book on CoffeeScript of things that either | |
# aren't in the main CS language reference or I didn't pick them up there. I wrote | |
# them down before I forgot, and put it here for others but mainly as a reference for | |
# myself. | |
# assign arguments in constructor to properties of the same name: | |
class Thingie | |
constructor: (@name, @url) -> | |
# is the same as: |
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
// http://stackoverflow.com/questions/15829172/stop-chrome-back-forward-two-finger-swipe | |
$(document).on('mousewheel', function(e) { | |
var $target = $(e.target).closest('.scrollable-h'); | |
if ($target.scrollLeft () <= 4) { | |
$target.scrollLeft(5); | |
return false; | |
} | |
}); | |
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
# mix.exs file dependencies: | |
# defp deps do | |
# [ | |
# {:sweet_xml, "~> 0.4.0"}, | |
# {:json, "~> 0.3.0"} | |
# ] | |
# end | |
defmodule ElixirXml do | |
import SweetXml |