Simple and safe random getters to copy-paste
string randomBytes( int $length )
int randomInt ( int $min , int $max )
string randomUuid ( void )| <?php | |
| class Foo | |
| { | |
| private $foo; | |
| private $bar; | |
| private $baz; | |
| } | |
| $hydrator = function(array $data) { |
| <?php | |
| class UrlManager extends CUrlManager{ | |
| /**File:: protected/components/UrlManager.php (Yii v1.1.14 compatible . May be less...) | |
| ::RUSSIAN DESCRIPTION:: | |
| В Yii наши URL по-умолчанию выглядят так http://site.com/index.php?param1=a или http://site.com/index.php/param1/a, но обычно мы хотим избавится от имени входного скрипта(index.php) в URL. | |
| И для этого устанавливаем в настройках параметр 'URLManager'=>array(...,'showScriptName' => false,...), но этот способ работает только для формирования и приема URL(http://site.com/param1/a). | |
| Но по-прежнему позволяет обращаться к нашему адресу по его старому значению http://site.com/index.php/param1/a . | |
| ЭТОТ СКРИПТ закрывает эту маленькую огрешность - т.е. не разрешает обращаться к URL в котором по-прежнему присутствует имя входного скрипта после site.com |
| <?php | |
| /** | |
| * DuplicateFilter prevents Yii from exposing URLs starting with /index.php/ when showScriptName is false. Such | |
| * URLs are automatically redirected to proper ones. | |
| * | |
| * To use add the following to your controller: | |
| * | |
| * ```php | |
| * public function filters() { | |
| * return array( |
Note: This was written using elasticsearch 0.9.
Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:
$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
"_id": 1,| function random_text( $type = 'alnum', $length = 8 ) | |
| { | |
| switch ( $type ) { | |
| case 'alnum': | |
| $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
| break; | |
| case 'alpha': | |
| $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
| break; | |
| case 'hexdec': |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> | |
| <style type="text/css"> | |
| #line{ | |
| width: 100%; | |
| margin: 20px 0; | |
| height: 300px; | |
| background: #eee; |
| Here is a simple jQuery plugin to make a table header fixed on top when window is scrolled. | |
| Using the code from twitter bootstrap documentation page, this code is customized for table header. | |
| Create the table with following layout - | |
| <table class="table-fixed-header"> | |
| <thead class="header"> | |
| <tr> | |
| <th>Column 1</th> | |
| <th>Column 2</th> | |
| <th>Column 3</th> |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.