Skip to content

Instantly share code, notes, and snippets.

View motin's full-sized avatar

Motin motin

View GitHub Profile
<?php
/**
* Runs the command.
* @param array $args the command-line arguments.
* @return integer the return code.
* @throws CException if the mysqldump binary cannot be located or if the actual dump fails.
*/
public function run($args)
{
list($action, $options, $args) = $this->resolveRequest($args);
@motin
motin / _bootstrap.php
Created July 17, 2014 10:36
Yii unit test _bootstrap for codeception
<?php
$_SERVER['SCRIPT_FILENAME'] = 'index-test.php';
$_SERVER['SCRIPT_NAME'] = '/index-test.php';
$_SERVER['REQUEST_URI'] = 'index-test.php';
// change the following paths if necessary
$yiit=dirname(__FILE__).'/../../../vendor/yiisoft/yii/framework/yiit.php';
require_once($yiit);
$main=require(dirname(__FILE__).'/../../../app/config/main.php');
@motin
motin / install-phundament4-sakila.sh
Last active August 29, 2015 14:07
phundament4-sakila-test
#!/bin/bash
set -x
set -o errexit
if [ ! -d "sakila-db" ]; then
wget http://downloads.mysql.com/docs/sakila-db.tar.gz
tar -xvf sakila-db.tar.gz
fi
@motin
motin / userapp.io-mock-api-blueprint.md
Last active August 29, 2015 14:13
Userapp.io Mock API Blueprint

FORMAT: 1A HOST: http://127.0.0.1:3000

Userapp.io Mock API

A simple mock api for Userapp.io that mocks api responses. For offline local development, install api-mock (npm -g install api-mock) and run:

git clone https://gist.github.com/c0812bc687804b526a2b.git userappiomock
api-mock userappiomock/userapp.io-mock-api-blueprint.md --port 3000 --cors-disable false

The local api is then available on http://localhost:3000/

@motin
motin / BehaviorActionControllerTrait.php
Created February 26, 2015 22:18
Yii 1. Allows controllers that use it to inherit actions from behaviors
<?php
/**
* BehaviorActionControllerTrait.php
*
* Allows controllers that use it to inherit actions from behaviors
* @author Brett O'Donnell <cornernote@gmail.com>
* Idea by Yii user Mimin and Kevin Higgins
* @link http://www.yiiframework.com/forum/index.php/user/9488-mimin/
* @link http://www.yiiframework.com/forum/index.php/user/24587-kevin-higgins/
* Relevant discussion in Yii Forum
@motin
motin / DataModel.php
Last active August 29, 2015 14:16
Sample giic configuration for yii-dna model generation
<?php
class DataModel
{
/**
* The corresponding qa state models used by yii-qa-state
* @return array
*/
static public function qaStateModels()
@motin
motin / composer.json
Created March 9, 2015 12:27
Composer example output - Your requirements could not be resolved to an installable set of packages
{
"name": "foo/project",
"description": "Foo project",
"keywords": ["yii", "web", "application", "cms"],
"type": "yii-application",
"license": "BSD-3-Clause",
"repositories": [
{
"type": "vcs",
"url": "git@github.com:neam/yii2-sir-trevor-js.git"
@motin
motin / ElasticsearchCommand.php
Created April 20, 2015 10:49
Old command from a project a couple of years ago to maintain elastic search indexes of contents stored in RDBMS tables using Yii 1
<?php
class ElasticSearchCommand extends AppConsoleCommand
{
public $model;
/**
* Fills ElasticSearch index from database contents
* @param <type> $modelRef
{
"query":{
"match_all":{}
},
"filter":{
"range":{
"population":{
"gt":10000
}
}
First, an ordinary node is started (the master):
[2011-05-30 14:15:54,997][INFO ][node ] [Wild Child] {elasticsearch/0.16.1}[24022]: initializing ...
[2011-05-30 14:15:55,000][INFO ][plugins ] [Wild Child] loaded []
[2011-05-30 14:15:58,714][INFO ][node ] [Wild Child] {elasticsearch/0.16.1}[24022]: initialized
[2011-05-30 14:15:58,714][INFO ][node ] [Wild Child] {elasticsearch/0.16.1}[24022]: starting ...
[2011-05-30 14:15:58,814][INFO ][transport ] [Wild Child] bound_address {inet[/0:0:0:0:0:0:0:0:9301]}, publish_address {inet[/xxx.xxx.xxx.xxx:9301]}
[2011-05-30 14:16:01,856][INFO ][cluster.service ] [Wild Child] new_master [Wild Child][q7s-536IQqCKyPo0w9Z-ug][inet[/xxx.xxx.xxx.xxx:9301]], reason: zen-disco-join (elected_as_master)
[2011-05-30 14:16:01,907][INFO ][discovery ] [Wild Child] elasticsearch_tripl_dev/q7s-536IQqCKyPo0w9Z-ug
[2011-05-30 14:16:02,081][INFO ][gateway ]