you are in: codestackercodes [RSS] → tag: leozera [RSS]

rails 3 two lines install Delicious Email

show/hide lines
   1  gem install i18n tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler
   2  
   3  gem install rails --pre
created by leozera — 20 February 2010 — get a short url — tags: rails embed

clean way to open a popup window Delicious Email

show/hide lines
   1  $('a.popup').live('click', function(){
   2  	newwindow=window.open($(this).attr('href'),'','height=200,width=150');
   3  	if (window.focus) {newwindow.focus()}
   4  	return false;
   5  });
created by leozera — 16 December 2009 — get a short url — tags: javascript jquery embed

seletores do jquery Delicious Email

http://docs.jQuery.com/DOM/Traversing/Selectors

show/hide lines
   1  $('h1') // elementos h1
   2  $('#meuID') // elementos com id "meuID"
   3  $('.minhaClasse') // elementos definidos com a classe "minhaClasse"
   4  $('[width]') // elementos que possuem o atributo width definido
   5  $('[width=500]') // elementos que possuem o atributo width definido como 500
   6  $('img[width=300]') // imagens que possuem largura = 300
   7  $('img[src$=png]') // imagens com final png
   8  $('a[href^=http://localhost]') // links que comecem com http://localhost
   9  $('a[href$=pdf]') // links com final pdf
  10  $('a[href*=www]') // links que contém www
  11  $(':empty') // elementos vazio
  12  $('div:empty') // elementos div vazios
  13  $(':has(p)') // todos elementos que tenham um parágrafo
  14  $('div:has(a)'); // elementos div que possuem link
  15  $("p:contains('dinei')") // parágrafos que contém a palavra "dinei"
  16  $("p:eq(0)") // seleciona o primeiro elemento p
created by leozera — 25 November 2009 — get a short url — tags: javascript jquery embed

i18n in labels Delicious Email

rails 2.3.4 doen’t have i18n support in labels
http://lawrencesong.net/2009/04/i18n-label-in-rails-monkey-patch/

show/hide lines
   1  module ActionView 
   2    module Helpers 
   3      class InstanceTag 
   4        def to_label_tag_with_i18n(text = nil, options = {}) 
   5          text ||= object.class.human_attribute_name(method_name) if object.class.respond_to?(:human_attribute_name) 
   6   
   7          to_label_tag_without_i18n(text, options) 
   8        end 
   9   
  10        alias_method_chain :to_label_tag, :i18n 
  11      end 
  12    end 
  13  end
created by leozera — 22 November 2009 — get a short url — tags: helper rails ruby embed

paperclip refresh all images Delicious Email

run this task

show/hide lines
   1  rake paperclip:refresh class=MyClass
created by leozera — 26 October 2009 — get a short url — tags: paperclip rails ruby embed

use default_scope to set up default find conditions such as order Delicious Email

show/hide lines
   1  class MyModel < ActiveRecord::Base
   2    default_scope :order => 'created_at desc'
   3  end
created by leozera — 04 October 2009 — get a short url — tags: rails ruby embed

humanized attributes Delicious Email

show/hide lines
   1  class User < ActiveRecord::Base
   2  
   3    HUMANIZED_ATTRIBUTES = {
   4      :email => "E-mail address"
   5    }
   6  
   7    def self.human_attribute_name(attr)
   8      HUMANIZED_ATTRIBUTES[attr.to_sym] || super
   9    end
  10  
  11  end
created by leozera — 22 August 2009 — get a short url — tags: rails ruby embed

copy to clipboard Delicious Email

show/hide lines
   1  function copyToClipBoard(id) {
   2      Copied = document.getElementById('id').innerText.createTextRange();
   3      Copied.execCommand("Copy");
   4  }
created by leozera — 22 August 2009 — get a short url — tags: javascript embed

back to top Delicious Email

show/hide lines
   1  <a href="#top" onclick="$('html, body').animate({scrollTop:0}, 'slow'); return false;">top</a>
created by leozera — 22 August 2009 — get a short url — tags: html javascript jquery embed

unobstrusive popup Delicious Email

http://www.quirksmode.org/js/popup.html

show/hide lines
   1     function popup(url) {
   2          newWindow = window.open(url, 'name', 'height=400,width=335,scrollbars=yes');
   3          if (window.focus) { newWindow.focus() }
   4              return false;
   5      }
   6  
   7  // <a href="link.html" onclick="popup('link.html');">Link</a>
created by leozera — 22 August 2009 — get a short url — tags: html javascript popup embed
Displaying records 1 - 10 of 156