Skip to content

Instantly share code, notes, and snippets.

Takashi Nojima nojimage

Block or report user

Report or block nojimage

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nojimage
nojimage / bootstrap_cli.php
Last active Oct 30, 2019
Bake Entity with column comment
View bootstrap_cli.php
<?php
// in bootstrap_cli.php
if (PHP_SAPI === 'cli' && Configure::read('debug')) {
// Bake書き換え
EventManager::instance()->on('Bake.beforeRender', static function (Event $event) {
$view = $event->getSubject();
/* @var $view View */
// for Bake Entity
if ($view->get('propertySchema') && $view->get('table') && $view->get('name')) {
// propertySchemaを書き換えてスキーマコメントを付与する
View hash_get.js
function hash_get(key, haystack) {
const keys = key.split('.');
if (!Object.prototype.hasOwnProperty.call(haystack, keys[0])) {
return null;
}
const matched = haystack[keys[0]];
if (keys.length === 1) {
return matched;
}
@nojimage
nojimage / ChunkInsertTestFixture.php
Last active May 17, 2019
CakePHP 3 TextFixture for many records
View ChunkInsertTestFixture.php
<?php
namespace App\TestSuite\Fixture;
use Cake\Datasource\ConnectionInterface;
use Cake\TestSuite\Fixture\TestFixture;
/**
* ChunkInsertTestFixture
*/
abstract class ChunkInsertTestFixture extends TestFixture
View ControllerResolver.php
<?php
/**
* Copyright 2018 Takashi Nojima.
*/
namespace App\Routing;
use Cake\Controller\Controller;
use Cake\Http\ControllerFactory;
use Cake\Http\Response;
@nojimage
nojimage / .gitlab-ci.yml
Last active Dec 4, 2018
Exclude run CI job on "WIP:" or "@wip" in the commit message
View .gitlab-ci.yml
(...snip...)
- vendor/bin/phpunit --coverage-text --colors=never --exclude-group=external
except:
variables:
- $CI_COMMIT_MESSAGE =~ /(?:^WIP:)|@WIP/i
@nojimage
nojimage / Chrome.php
Last active Nov 5, 2019
Codeception / WebDriver / ChromeDriver でモバイルエミュレーションする
View Chrome.php
<?php
/**
*
* Copyright 2018 ELASTIC Consultants Inc.
*
*/
namespace Helper\MobileEmulation;
use Codeception\Module;
@nojimage
nojimage / CakeFixture.php
Last active Dec 8, 2017
CakePHP Fixture Module for Codeception
View CakeFixture.php
<?php
namespace Codeception\Module;
use Cake\TestSuite\Fixture\FixtureManager;
use Codeception\Module;
use Codeception\Test\Cest;
use Codeception\TestInterface;
use Exception;
use stdClass;
@nojimage
nojimage / FileLog.php
Created Oct 3, 2017
CakePHP3 のログで$contextを宜しくロギング
View FileLog.php
<?php
/*
*
* Copyright 2017 ELASTIC Consultants Inc.
*
*/
namespace Elastic\ContextLogEngine\Log\Engine;
use Cake\Http\ServerRequest;
View ClearCacheShell.php
<?php
App::uses('Shell', 'Console');
/**
* ClearCache
*
* CakePHP 2.0
* PHP versions 5
*
@nojimage
nojimage / AppModel.php
Created Jan 20, 2017
CakePHP 2.x findEach
View AppModel.php
<?php
/**
* 検索結果に対して処理を行う
*
* example:
* $model->findEach(['conditions' => ['status' => 1]], function ($data) {
* // $data = ['Model' => [ ... ]]
* debug($data);
* });
*
You can’t perform that action at this time.