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
// css | |
.opacity { | |
opacity: .80; | |
filter: alpha(opacity=80); | |
-ms-filter: "alpha(opacity=$value)"; | |
-khtml-opacity: .80; | |
-moz-opacity: .80; | |
} | |
// sass |
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($color: #333333) { | |
-moz-box-shadow: 0px 1px 2px $color; | |
-webkit-box-shadow: 0px 1px 2px $color; | |
box-shadow: 0px 1px 2px $color; | |
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=90, Color='$color')"; | |
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=90, Color='$color'); | |
} | |
.shadow { | |
@include shadow(#111111); |
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
// css | |
.rotate { | |
-moz-transform: rotate(-30deg); | |
-o-transform: rotate(-30deg); | |
-webkit-transform: rotate(-30deg); | |
filter: progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11=0.154, M12=-0.988, M21=0.988, M22=0.154); | |
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11=0.154, M12=-0.988, M21=0.988, M22=0.154)"; | |
zoom: 1; | |
} |
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 gradient($first, $second) { | |
background: $second; | |
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='$first', endColorstr='$second'); | |
background: -webkit-gradient(linear, left top, left bottom, from($first), to($second)); | |
background: -moz-linear-gradient(top, $first, $second); | |
} | |
.gradient { | |
@include gradient(black, white); | |
} |
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
# return 4 urls, with and without trailing slash, with and without www | |
# useful for matching urls passed as params into some function, | |
# "does this url exist?"... need to make sure you check permutations | |
def url_permutations(url) | |
url, params = url.split("?") | |
# without_trailing_slash, with www | |
a = url.gsub(/\/$/, "").gsub(/http(s)?:\/\/([^\/]+)/) do |match| | |
protocol = "http#{$1.to_s}" | |
domain = $2 | |
domain = "www.#{domain}" if domain.split(".").length < 3 # www.google.com == 3, google.com == 2 |
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 'rubygems' | |
require 'active_model' | |
class BaseModel | |
extend ActiveModel::Callbacks | |
define_model_callbacks :save | |
before_save { puts "[save:before]"} | |
after_save { puts "[save:after]"} |
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 'rubygems' | |
require 'active_model' | |
# use this if you want to create before and after filters around a commonly used | |
# method, but still want to define the method in subclasses. | |
module SubclassableCallbacks | |
def self.included(base) | |
base.extend ClassMethods | |
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
ObjectSpace.each_object(Class).to_a |
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
# thanks to the answer here: | |
# http://stackoverflow.com/questions/3488203/how-do-i-see-where-in-the-class-hierarchy-a-method-was-defined-and-overridden-in | |
class Object | |
def self.overridden_methods(parent_class = Object, within_tree = true) | |
if within_tree | |
defined_methods = ancestors[0..ancestors.index(parent_class) - 1].map { |object| object.instance_methods(false) }.flatten.uniq | |
parent_methods = superclass.instance_methods | |
else | |
defined_methods = instance_methods(false) | |
parent_methods = parent_class.instance_methods |
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://nodejs.org/api.html#_child_processes | |
var sys = require('sys') | |
var spawn = require('child_process').spawn; | |
var filename = process.ARGV[2]; | |
if (!filename) | |
return sys.puts("Usage: node <server.js> <filename>"); | |
var tail = spawn("tail", ["-f", filename]); | |
sys.puts("start tailing"); |