Skip to content

Instantly share code, notes, and snippets.

@chriseppstein
chriseppstein / SassMeister-input.sass
Created October 20, 2014 17:32
Generated by SassMeister.com.
// ----
// Sass (v3.4.6)
// Compass (v1.0.1)
// ----
.button-base
background-color: #f0f0f0
border-radius: 20px
border: 1px solid #ccc
color: #333
@chriseppstein
chriseppstein / SassMeister-input.scss
Created November 20, 2014 23:22
Generated by SassMeister.com.
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// ----
@function extract-keyword-arg($argname, $args...) {
$kwargs: keywords($args);
@return map-get($kwargs, $argname);
}
require 'ignoring_diff'
Hash.send(:include, IgnoringDiff)
h = {:foo => :bar}
h.diff({})
# => {:foo => :bar}
h.ignore_difference_for(:foo)
h.diff({})
# => {}
@chriseppstein
chriseppstein / number.cpp
Last active August 29, 2015 14:20
Experimenting with using properties instead of methods.
#include <nan.h>
#include "number.h"
#include "../create_string.h"
using namespace v8;
namespace SassTypes
{
Number::Number(Sass_Value* v) : SassValueWrapper(v) {}
@chriseppstein
chriseppstein / Directory Structure
Last active August 29, 2015 14:24
Simple Eyeglass Assets Example
.
├── assets
│   ├── images
│   │   ├── foo
│   │   │   └── image1.png
│   │   └── unused.gif
│   ├── js
│   │   └── app.js
│   └── scss
│   └── app.scss
@chriseppstein
chriseppstein / tracer.rb
Created August 21, 2008 22:44
Trace method entrances and exists. Requires ActiveSupport.
module Tracer
def trace(method)
method, ending = split_method_name(method)
define_method "#{method}_with_trace#{ending}" do |*arguments|
puts "called #{self.class}##{method}#{ending}(#{arguments.map(&:inspect).join(', ')})"
returning(send("#{method}_without_trace#{ending}", *arguments)) do |v|
puts "#{self.class}##{method}#{ending} => #{v.inspect}"
end
end
alias_method_chain "#{method}#{ending}", :trace
.compass { margin: 1em auto; position: relative; width: 16em; height: 16em; font-size: 24px; font-family: "Academy Engraved LET", "Papyrus"; }
.compass .n, .compass .s, .compass .e, .compass .w { position: absolute; width: 4em; height: 4em; text-align: center; vertical-align: middle; }
.compass .w { left: 0px; }
.compass .n.w, .compass .s.w { left: 2em; }
.compass .n, .compass .s { left: 6em; }
.compass .n.e, .compass .s.e { left: 10em; }
.compass .e { left: 12em; }
.compass .n { top: 0px; }
.compass .n.w, .compass .n.e { top: 2em; }
.compass .w, .compass .e { top: 6em; }
module Anonymizer
def anonymize_attribute(attribute)
self.send(:include, Module.new do
define_method attribute do
a = @attributes[attribute.to_s]
a && attribute.to_s.ends_with?("_id") ? a.to_i : a
end
define_method "#{attribute}_with_anonymous" do
send("#{attribute}_without_anonymous") unless anonymous?
end
module ContentForHelpers
def content_for?(name, options = {}, &block)
has_content = (!instance_variable_get("@content_for_#{name}").strip.blank? rescue nil)
should_process = options[:negate] ? !has_content : has_content
if should_process && block_given?
concat(capture(&block), block.binding)
end
return should_process
end