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 | |
namespace Fuel\Migrations; | |
class Create_sessions { | |
public function up() | |
{ | |
\DBUtil::create_table('sessions', array( | |
'session_id' => array('constraint' => 40, 'type' => 'varchar'), |
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 bind(method, instance, klass = None, setbound = True, name = None): | |
if klass is None: | |
klass = instance.__class__ | |
bound = method.__get__(instance, klass) | |
if setbound: | |
setattr(instance, name or method.__name__, bound) | |
return bound |
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
class Service(object): | |
def __init__(self): | |
for method_name in dir(self): | |
method = getattr(self, method_name) | |
if callable(method) and hasattr(method, '__func__'): | |
for base in self.__class__.__bases__: | |
setattr(base, method_name, method.__func__) | |
class Foo(Service): pass |
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
>>> class Foobar(object): | |
... CONSTANT = 'test' | |
... def test(self): print self.CONSTANT | |
... | |
>>> Foobar.CONSTANT | |
'test' | |
>>> f = Foobar() | |
>>> f.CONSTANT | |
'test' | |
>>> f.test() |
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 | |
Route::get('(:bundle)', 'admin::admin@index'); | |
Route::Controller('admin::admin'); |
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 | |
Route::any('(:bundle)/(:any?)', function($method='index') | |
{ | |
return Controller::call('admin::admin@' . $method); | |
}); |
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
@layout('single-column') | |
@section('content') | |
Whatever | |
@endsection |
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
USER="backup" | |
PASSWORD="****" | |
OUTPUTDIR="/home/dbbackup/backups" | |
MYSQLDUMP="/usr/bin/mysqldump" | |
MYSQL="/usr/bin/mysql" | |
SKIP=(mysql information_schema performance_schema) | |
# get a list of databases | |
databases=`$MYSQL --user=$USER --password=$PASSWORD \ | |
-e "SHOW DATABASES;" | tr -d "| " | grep -v Database` |
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
$patterns = array( | |
'#(?P<category>[^\d\/]+)?\/?(?P<year>\d{4})?\/?(?P<month>\d{1,2})?\/?(?P<day>\d{1,2})?$#', // Listing | |
'#(?P<year>\d{4})\/(?P<month>\d{1,2})\/(?P<day>\d{1,2})\/(?P<slug>.*)#', // Entry | |
); |
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 // bundles/api_v1/controllers/example.php | |
class Api_V1_Example_Controller extends Controller | |
{ | |
public $restful = True; | |
public function get_hello($name='World') | |
{ | |
return "Hello, {$name}!"; | |
} |
OlderNewer