Skip to content

Instantly share code, notes, and snippets.

class Post < ActiveRecord::Base
class << self
alias_method :find_standard, :find
end
validates_presence_of :publish_from, :publish_to
before_create :validates_time
class Post < ActiveRecord::Base
cattr_accessor :state_from, :state_to
include ActiveSupport::Callbacks
define_callbacks :after_transition
#kod ....
#(...)
aasm_event :view, :enter => :enter, :exit => :exit, :success => :success do
transitions :to => :read, :from => [:unread]
require 'net/http'
require 'uri'
require 'rexml/document'
class GG
attr_accessor :token, :server, :port, :uin, :login, :pass, :content_type
def initialize(options={})
self.uin=options[:uin] unless options[:uin].nil?
self.pass= options[:pass] unless options[:pass].nil?
class CommentObserver < ActiveRecord::Observer
def after_create(comment)
GADU.message :to=> 3062261, :text => "Artykuł #{comment.post.title} otrzymał nowy komentarz\r\n#{comment.id} od #{comment.author}\r\nczytaj na: http://blog.baael.pl/#{comment.post.permalink}"
#for PULL
# "\r\nzaakceptować? [t/n] (||akceptuj:id)"
end
end
module I18n
module Backend
class PolishPluralization < Simple
def pluralize(locale, entry, count)
return entry unless entry.is_a?(Hash) and count
case locale
when 'pl'
key = :zero if count == 0 && entry.has_key?(:zero)
key = :one if count==1 && count%100!=11
key ||=((2..4).include?(count%10) && !(12..14).include?(count%100))? :few : :other
@Baael
Baael / pl.yml
Created January 9, 2009 20:28
Formula pluralization for I18n
# Formula pluralizations for I18n
# by Wojciech Zieliński (zielinskiwojciech@gmail.com, http://github.com/baael)
pl:
formula:
one: "{{count}}==1 && {{count}}%100!=11"
few: "(2..4).include?({{count}}%10) && !(12..14).include?({{count}}%100)"
default: "other"
test:
gry:
# teraz uzyjemy form_for bo mamy obiekt
<div><%= error_messages_for 'news' %></div>
<% form_for(@news, :url => {:controller =>'news', :action =>'create'}) do |f| %>
Temat:<%= f.text_field :subject %><br />
Skrót:<%= f.text_field :body_short %><br />
def can_edit? site
value=permissions.find(:first,
:conditions => ["`permissions`.content_id = ? and `permissions`.content_type = ?",site.id, site.class.to_s ],
:order => 'FIND_IN_SET(`owner_type`, "user,section"), `permissions`.rank DESC'
) || ((section)? section.permissions.find(:first,
:conditions => ["`permissions`.content_id = ? and `permissions`.content_type = ?",site.id, site.class.to_s ],
:order => 'FIND_IN_SET(`owner_type`, "user,section"), `permissions`.rank DESC'
) : nil )
<?
// install.sgz package should be in this directory
include("backup.php");
set_time_limit(0);
if(!is_writable("backup.php")){
echo "Plik backup.php nie ma uprawnień do zapisu!";
exit;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><%= yield :title %></title>
<script type="text/javascript" src="/jquery-1.3.2.js"></script>