This file contains 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
location / { | |
try_files $uri /app.php$is_args$args; | |
} | |
location ~ ^.+\.php(/|$) { | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_split_path_info ^(.+\.php)(/.*)$; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | |
fastcgi_param DOCUMENT_ROOT $realpath_root; |
This file contains 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
# SSH tunnel, so it's possible to connect to remote server services via SSH | |
# argument: local_port, dest_port, host | |
ssh_tunnel () { | |
lsof -i:$1 > /dev/null 2>&1 || ssh -fNg -L $1:127.0.0.1:$2 $3 | |
} | |
# sample: mysql | |
ssh_tunnel 3307 3306 HOST |
This file contains 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 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 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 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 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 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 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 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 |
OlderNewer