This gist is no longer valid. Please see Compass-Rails for instructions on how to install.
This file contains hidden or 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
| function GM_getValue (key) { | |
| var value = localStorage.getItem('GM_'.key); | |
| if ('undefined' == typeof(value)) { | |
| return; | |
| } | |
| return value; | |
| } | |
| function GM_setValue (key, value) { | |
| localStorage.setItem('GM_'.key, value); |
This file contains hidden or 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
| # autoload concerns | |
| module YourApp | |
| class Application < Rails::Application | |
| config.autoload_paths += %W( | |
| #{config.root}/app/controllers/concerns | |
| #{config.root}/app/models/concerns | |
| ) | |
| end | |
| end |
This file contains hidden or 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
| doctype html | |
| /[if lt IE 7] | |
| | <html class="ie6"> | |
| /[if IE 7] | |
| | <html class="ie7"> | |
| /[if IE 8] | |
| | <html class="ie8"> | |
| /[if IE 9] | |
| | <html class="ie9"> | |
| | <!--[if (gte IE 9)|!(IE)]<!--> <html> <!--<![endif]--> |
This file contains hidden or 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
| # build scopes for owners, producers, and viewers. each scope can be used | |
| # with one, or more, users. for example: | |
| # | |
| # Organization.with_owners(jane, john) | |
| # | |
| { | |
| :owner => %w'owner', | |
| :producer => %w'owner producer', | |
| :viewer => %w'owner producer viewer' | |
| }.each do |name, roles| |
This file contains hidden or 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
| javascript:(function(){s1=document.createTextNode('.guidesOn::before { content:""; position:fixed; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAZdEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjVJivzgAAAAyUlEQVRoQ%2B2abQqAIBBEPW1X6CzdqTv1RUFIipi2o72gPyXV7uybKci5wDZM8xI6dz%2Buvs6pP2Dq81GI2qiiiJkiOzQ97EGHTXUF9XUwYsaI2o1LjyqjpaYwiqDI2YFs2HtI9Wjx2Z0R%2B1ADdmB%2FC7taB0uzCSNqCqOImSIkeyW7xLXMZvqjdzJcS01hFEGRSnbe3miR7JVGgWRXcxkUQRFgj%2F8Y8htGtkJHL%2FvGaGtKd6bU9Z4C%2FCiEZDeCPahIa%2FbbDSNX433mVkIrV5rTnhDyAAAAAElFTkSuQmCC) 50% 0; z-index:1; top:0; right:0; bottom:0; left:0; opacity:.3; pointer-events:none; } * { -webkit-user-modify: read-write; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; } a { -webkit-user-modify: initial; }');s2=document.createTextNode('#a1_z { background-color: #fff; background-color: rgba(255,255,255,.8); float: left; position: fixed; z-index:2; padding: 3px; bo |
This file contains hidden or 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
| ## DNS | |
| @dns = Fog::DNS.new(:provider => 'Linode', :linode_api_key => LINODE_KEY) | |
| if @zone = @dns.zones.all.find { |z| z.domain == ZONE } | |
| puts "Found zone #{@zone.inspect}" | |
| else | |
| @zone = @dns.zones.create(:domain => ZONE, :email => ZONE_EMAIL) | |
| puts "Creating zone #{@zone.inspect}" | |
| end |
Let's build a JavaScript class syntax from first principles. For the purpose of this exercise, let's assume that the purpose of the class syntax is to add much-needed sugar to common JavaScript idioms.
Let's start with how JavaScript "classes" work today:
// this is a constructor
Person = function() {
this // `this` is a new instance of Person
This file contains hidden or 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
| ## | |
| ## with raw object | |
| ## | |
| # create a new object | |
| o = Object.new | |
| # define methods on the object (precisely, the object's singleton) | |
| class << o | |
| def hello(thing) |
This file contains hidden or 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 'chronic' | |
| class PassengerProcess | |
| attr_accessor :pid, :uptime | |
| def initialize(passenger_status_line) | |
| values = passenger_status_line.match(/PID:\s(\d*).*Uptime:\s*(.*)$/) | |
| @pid = values[1].to_i | |
| @uptime = values[2] | |
| end |