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
<?php | |
use Doctrine\DBAL\Types\Type; | |
use Doctrine\DBAL\Platforms\AbstractPlatform; | |
/** | |
* My custom datatype. | |
*/ | |
class EnumType extends Type | |
{ | |
const ENUM = 'enum'; |
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
<?php | |
/** | |
* Doctrine::HYDRATE_SCALAR without component alias at the beginning. | |
* For key names it takes columns and aliases from SELECT statement. | |
* First column/alias from statement is used as key for whole row. | |
*/ | |
class Doctrine_Hydrator_FlatArray extends Doctrine_Hydrator_ScalarDriver { | |
public function hydrateResultSet($stmt) | |
{ |
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
jQuery.fn.whenLoaded = function(fn){ | |
return this.each(function(){ | |
// if already loaded call callback | |
if (this.complete || this.readyState == 'complete'){ | |
fn.call(this); | |
} else { // otherwise bind onload event | |
$(this).load(fn); | |
} | |
}); | |
} |
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
@articles = Article. | |
select('articles.*, (SUM(votes.vote = 1)/COUNT(votes.vote)) votes_ratio, COUNT(votes.vote) votes_num'). | |
joins(:votes). | |
group('articles.id'). | |
having('votes_num >= 5 AND votes_ratio >= 0.8'). | |
order('votes_ratio DESC, votes_num DESC'). | |
paginate(:page => params[:page], :per_page => Article.per_page) |
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
<?php | |
class FooClass { | |
public function foo_method() { | |
function foo_func() { | |
echo "it works, really"; | |
} | |
} | |
} | |
$foo = new FooClass; |
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
var i:int = 0, l:int = points.length; | |
while (i < l) { | |
i+=1; | |
} |
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
# Source: http://sinatra.inf.ug.edu.pl/rails4/konfiguracja | |
# File: ~/.irbc | |
require 'rubygems' | |
require 'wirble' | |
require 'hirb' | |
Wirble.init | |
Wirble.colorize | |
Hirb.enable | |
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER') | |
require 'logger' |
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
def interpret_status(status) | |
Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s | |
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
fontconfig=yes | |
subcp=cp1250 | |
subfont-text-scale=4 |
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
class Comment | |
include Mongoid::Document | |
field :name | |
# do not generate object_id | |
# for mongoid <=2.0rc7 (in newer mongoid use Mongoid.embedded_object_id = false) | |
def identify | |
end |
OlderNewer