Skip to content

Instantly share code, notes, and snippets.

Takuro Hishikawa hissy

Block or report user

Report or block hissy

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
@hissy
hissy / app.php
Created Aug 8, 2019
#concrete5 Visualize rendering time of each blocks with DebugBar
View app.php
<?php
/**
* First, install the debug bar package. @link: https://github.com/concrete5cojp/concrete5_debugbar
* Then, add these code in your application/bootstrap/app.php
*/
Events::addListener('on_block_load', function ($event) {
$bID = $event->getArgument('bID');
$btHandle = $event->getArgument('btHandle');
Core::make('debugbar/time')->startMeasure(sprintf('block_%d', $bID), sprintf('Rendering %s block (bID: %d)', $btHandle, $bID));
});
@hissy
hissy / output.md
Last active Jul 12, 2019
#concrete5 Complete usage and output of Date Helper to localize date time format
View output.md
$dh = Core::make('helper/date');
Code en_US ja_JP it_IT ru_RU zh_CN
echo $dh->formatDateTime($date); 7/10/19, 7:28 AM 2019/07/10 7:28 10/07/19, 07:28 10.07.2019, 07:28 2019/7/10 上午7:28
echo $dh->formatDateTime($date, true); Jul 10, 2019, 7:28 AM 2019/07/10 7:28 10 lug 2019, 07:28 10 июл. 2019 г., 07:28 2019年7月10日 上午7:28
echo $dh->formatDateTime($date, false, true); 7/10/19, 7:28:21 AM 2019/07/10 7:28:21 10/07/19, 07:28:21 10.07.2019, 07:28:21 2019/7/10 上午7:28:21
echo $dh->formatDateTime($date, true, true); Jul 10, 2019, 7:28:21 AM 2019/07/10 7:28:21 10 lug 2019, 07:28:21 10 июл. 2019 г., 07:28:21 2019年7月10日 上午7:28:21
@hissy
hissy / README.md
Last active Jul 3, 2019
#concrete5 Ignore permission for rss feed
View README.md

By default, concrete5 checks the permission of all of the pages in the RSS feed. If all pages are not viewable by a guest user, RSS feed will return 404 error page.

With this override, concrete5 never check any permission of all pages in the feed. This is useful to provide an RSS feed from a members-only website, but please keep in mind that all published pages will be included in the RSS feed with any permission settings.

Tested on concrete5 8.5.1

@hissy
hissy / fizzbuzz-function.php
Created Jul 1, 2019
FizzBuzz 作例:functionを使う
View fizzbuzz-function.php
<?php
/**
* @param int $start
* @param int $end
* @return string
*/
function fizzbuzz(int $start, int $end) {
$output = '';
$numbers = range($start, $end);
@hissy
hissy / login.php
Last active Jul 29, 2019
#concrete5 Force specific authentication type by environment
View login.php
<?php
// Put this file on application/controllers/single_page/login.php
namespace Application\Controller\SinglePage;
use Concrete\Core\Routing\RedirectResponse;
use Concrete\Core\Support\Facade\Facade;
use Concrete\Core\Url\Resolver\Manager\ResolverManagerInterface;
class Login extends \Concrete\Controller\SinglePage\Login
@hissy
hissy / fizzbuzz.php
Last active Jul 3, 2019
FizzBuzz for PHP 出題ファイル
View fizzbuzz.php
<?php
/**
* FizzBuzz 問題
* * 3で割り切れる場合は Fizz と出力
* * 5で割り切れる場合は Buzz と出力
* * 3でも5でも割り切れる場合は Fizz Buzz と出力する
*
* Fork ボタンでフォークして作業開始
*
* スクリプトの実行方法 $ php fizzbuzz.php
@hissy
hissy / valet.app.php
Last active Jul 11, 2019
#concrete5 config file for local environment
View valet.app.php
<?php
/**
* Set default value for curl option
*/
return [
'http_client' => [
'connecttimeout' => 30,
],
];
@hissy
hissy / concrete.php
Last active Jun 20, 2019
#concrete5 Disable getting external news and help from concrete5.org
View concrete.php
<?php
/**
* Put this file at application/config/concrete.php
* Disable getting external news and help from concrete5.org
*/
return [
'marketplace' => [
'enabled' => false
],
'external' => [
@hissy
hissy / view.php
Last active Jun 19, 2019
#concrete5 Check the user already submitted on express form template
View view.php
<?php
defined('C5_EXECUTE') or die('Access Denied.');
$app = \Concrete\Core\Support\Facade\Facade::getFacadeApplication();
/** @var \Concrete\Core\User\User $u */
$u = $app->make(\Concrete\Core\User\User::class);
$answered = 0;
if (isset($renderer) && is_object($renderer) && $u->isRegistered()) {
$context = $renderer->getContext();
if (is_object($context)) {
@hissy
hissy / view.php
Created Jun 17, 2019
#concrete5 An example of the custom template for page list with Vue.js
View view.php
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$c = Page::getCurrentPage();
/** @var \Concrete\Core\Utility\Service\Text $th */
$th = Core::make('helper/text');
/** @var \Concrete\Core\Localization\Service\Date $dh */
$dh = Core::make('helper/date');
You can’t perform that action at this time.