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
| public static function addview($tid) { | |
| $viewed = Session::get('viewed', array()); | |
| if ( in_array($tid, $viewed) ) | |
| { | |
| $viewed[] = $tid; | |
| Theme::where_id($tid)->increment('views'); | |
| } | |
| Session::put('viewed', $viewed); | |
| } |
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 | |
| Route::get('protected', array('before' => 'auth|role:admin', function() { | |
| return "Only admins can see this"; | |
| })); | |
| Route::filter('role', function ($role) { | |
| if ( ! Auth::user()->has_role( $role ) ) | |
| { | |
| return Response::error("401"); // not authorized |
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 News_Controller extends Base_Controller | |
| { | |
| public $restful = true; | |
| public function __call($name, $args) | |
| { | |
| $matches = array(); | |
| preg_match('/(action|get|put|delete|post)_(\d+)/', $name, $matches); | |
| if ($matches) { |
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 // 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}!"; | |
| } |
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
| $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 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
| 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 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
| @layout('single-column') | |
| @section('content') | |
| Whatever | |
| @endsection |
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 | |
| Route::any('(:bundle)/(:any?)', function($method='index') | |
| { | |
| return Controller::call('admin::admin@' . $method); | |
| }); |
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 | |
| Route::get('(:bundle)', 'admin::admin@index'); | |
| Route::Controller('admin::admin'); |
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 Foobar(object): | |
| ... CONSTANT = 'test' | |
| ... def test(self): print self.CONSTANT | |
| ... | |
| >>> Foobar.CONSTANT | |
| 'test' | |
| >>> f = Foobar() | |
| >>> f.CONSTANT | |
| 'test' | |
| >>> f.test() |